-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.go
43 lines (36 loc) · 1013 Bytes
/
run.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 cmds
import (
"io"
"github.com/appscode/go/log"
v "github.com/appscode/go/version"
"github.com/kube-ci/git-apiserver/pkg/cmds/server"
"github.com/spf13/cobra"
"kmodules.xyz/client-go/tools/cli"
)
func NewCmdRun(out, errOut io.Writer, stopCh <-chan struct{}) *cobra.Command {
o := server.NewGitAPIServerOptions(out, errOut)
cmd := &cobra.Command{
Use: "run",
Short: "Launch git apiserver",
Long: "Launch git apiserver",
DisableAutoGenTag: true,
PreRun: func(c *cobra.Command, args []string) {
cli.SendPeriodicAnalytics(c, v.Version.Version)
},
RunE: func(cmd *cobra.Command, args []string) error {
log.Infof("Starting server version %s+%s ...", v.Version.Version, v.Version.CommitHash)
if err := o.Complete(); err != nil {
return err
}
if err := o.Validate(args); err != nil {
return err
}
if err := o.Run(stopCh); err != nil {
return err
}
return nil
},
}
o.AddFlags(cmd.Flags())
return cmd
}