pull file
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
Close Stale Issues / close_stale_issues (push) Has been cancelled
repo-sync / repo-sync (push) Has been cancelled
auto-deploy-tencent-scf / pre-check (push) Has been cancelled
auto-deploy-tencent-scf / deploy serverless (push) Has been cancelled
This commit is contained in:
61
krew/pkg/cmd/get.go
Normal file
61
krew/pkg/cmd/get.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os/exec"
|
||||
|
||||
"github.com/RayWangQvQ/BiliBiliToolPro/krew/pkg/options"
|
||||
helper "github.com/RayWangQvQ/BiliBiliToolPro/krew/pkg/utils"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
getDesc = `
|
||||
'get' command get bilibilipro tool deployment.`
|
||||
getExample = ` kubectl bilipro get <--name deployment_name --namespace namespace_name>`
|
||||
)
|
||||
|
||||
type getCmd struct {
|
||||
out io.Writer
|
||||
errOut io.Writer
|
||||
|
||||
deployOpts options.DeployOptions
|
||||
}
|
||||
|
||||
func newGetCmd(out io.Writer, errOut io.Writer) *cobra.Command {
|
||||
o := &getCmd{out: out, errOut: errOut}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "get",
|
||||
Short: "Get bilibilipro",
|
||||
Long: getDesc,
|
||||
Example: getExample,
|
||||
Args: cobra.MaximumNArgs(0),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
||||
err := o.run(out)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
f := cmd.Flags()
|
||||
f.StringVarP(&o.deployOpts.Namespace, "namespace", "n", "bilipro", "namespace scope for this request")
|
||||
f.StringVarP(&o.deployOpts.Name, "name", "", "bilibilipro", "name of deployment to get")
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (o *getCmd) run(writer io.Writer) error {
|
||||
// do kubectl get
|
||||
cmd := exec.Command("kubectl", "get", "deploy", o.deployOpts.Name, "-n", o.deployOpts.Namespace)
|
||||
|
||||
if err := helper.Run(cmd, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user