Add version subcommand.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
eb4d5f3fc7
commit
16f1c54bd6
@ -55,13 +55,23 @@ func init() {
|
||||
func defaultConfigCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "default-config",
|
||||
Short: "Print default toml config of cri-containerd and quit.",
|
||||
Short: "Print default toml config of cri-containerd.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
options.PrintDefaultTomlConfig()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func versionCommand() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print cri-containerd version information.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
version.PrintVersion()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
if reexec.Init() {
|
||||
return
|
||||
@ -70,20 +80,16 @@ func main() {
|
||||
|
||||
o.AddFlags(cmd.Flags())
|
||||
cmd.AddCommand(defaultConfigCommand())
|
||||
cmd.AddCommand(versionCommand())
|
||||
|
||||
cmd.Run = func(cmd *cobra.Command, args []string) {
|
||||
if err := o.InitFlags(cmd.Flags()); err != nil {
|
||||
glog.Exitf("Failed to init CRI containerd flags: %v", err)
|
||||
}
|
||||
|
||||
// TODO(random-liu): Turn to subcommand.
|
||||
glog.V(0).Infof("Run cri-containerd %+v", o)
|
||||
if o.PrintVersion {
|
||||
version.PrintVersion()
|
||||
os.Exit(0)
|
||||
}
|
||||
validateConfig(o)
|
||||
|
||||
glog.V(0).Infof("Run cri-containerd %+v", o)
|
||||
|
||||
glog.V(2).Infof("Run cri-containerd grpc server on socket %q", o.SocketPath)
|
||||
s, err := server.NewCRIContainerdService(o.Config)
|
||||
if err != nil {
|
||||
|
@ -95,8 +95,6 @@ type CRIContainerdOptions struct {
|
||||
Config
|
||||
// Path to the TOML config file.
|
||||
ConfigFilePath string `toml:"-"`
|
||||
// PrintVersion indicates to print version information of cri-containerd.
|
||||
PrintVersion bool
|
||||
}
|
||||
|
||||
// NewCRIContainerdOptions returns a reference to CRIContainerdOptions
|
||||
@ -125,8 +123,6 @@ func (c *CRIContainerdOptions) AddFlags(fs *pflag.FlagSet) {
|
||||
defaults.ContainerdConfig.RuntimeEngine, "Runtime engine used by containerd. Defaults to containerd's default if not specified.")
|
||||
fs.StringVar(&c.ContainerdConfig.RuntimeRoot, "containerd-runtime-root",
|
||||
defaults.ContainerdConfig.RuntimeRoot, "The directory used by containerd for runtime state. Defaults to containerd's default if not specified.")
|
||||
fs.BoolVar(&c.PrintVersion, "version",
|
||||
false, "Print cri-containerd version information and quit.")
|
||||
fs.StringVar(&c.NetworkPluginBinDir, "network-bin-dir",
|
||||
defaults.NetworkPluginBinDir, "The directory for putting network binaries.")
|
||||
fs.StringVar(&c.NetworkPluginConfDir, "network-conf-dir",
|
||||
|
Loading…
Reference in New Issue
Block a user