-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
root.go
43 lines (39 loc) · 1.1 KB
/
root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package cmd
import (
appCmd "github.com/jenkins-zh/jenkins-cli/app/cmd"
cmdApp "github.com/jenkins-zh/jenkins-cli/app/cmd"
"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"github.com/spf13/cobra"
"os"
)
// Check do the health check of casc cmd
func (o *CASCOptions) Check() (err error) {
opt := cmdApp.PluginOptions{
Option: common.Option{RoundTripper: o.RoundTripper},
}
_, err = opt.FindPlugin("configuration-as-code")
return
}
func NewCasCCMD() (cascCmd *cobra.Command) {
opt := CASCOptions{}
rootCmd := appCmd.GetRootCommand()
cascCmd = &cobra.Command{
Use: "casc",
Short: "Configuration as Code",
Long: "Configuration as Code",
ValidArgsFunction: common.NoFileCompletion,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
cmd.SetOut(os.Stdout)
return rootCmd.PersistentPreRunE(cmd, args)
},
PersistentPostRun: rootCmd.PersistentPostRun,
}
cmdApp.GetHealthCheckRegister().Register("jcli.casc.*", &opt)
cascCmd.AddCommand(
NewSchemaCmd(),
NewReloadCmd(),
NewExportCmd(),
NewApplyCmd(),
NewOpenCmd())
return
}