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 {
|
func defaultConfigCommand() *cobra.Command {
|
||||||
return &cobra.Command{
|
return &cobra.Command{
|
||||||
Use: "default-config",
|
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) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
options.PrintDefaultTomlConfig()
|
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() {
|
func main() {
|
||||||
if reexec.Init() {
|
if reexec.Init() {
|
||||||
return
|
return
|
||||||
@ -70,20 +80,16 @@ func main() {
|
|||||||
|
|
||||||
o.AddFlags(cmd.Flags())
|
o.AddFlags(cmd.Flags())
|
||||||
cmd.AddCommand(defaultConfigCommand())
|
cmd.AddCommand(defaultConfigCommand())
|
||||||
|
cmd.AddCommand(versionCommand())
|
||||||
|
|
||||||
cmd.Run = func(cmd *cobra.Command, args []string) {
|
cmd.Run = func(cmd *cobra.Command, args []string) {
|
||||||
if err := o.InitFlags(cmd.Flags()); err != nil {
|
if err := o.InitFlags(cmd.Flags()); err != nil {
|
||||||
glog.Exitf("Failed to init CRI containerd flags: %v", err)
|
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)
|
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)
|
glog.V(2).Infof("Run cri-containerd grpc server on socket %q", o.SocketPath)
|
||||||
s, err := server.NewCRIContainerdService(o.Config)
|
s, err := server.NewCRIContainerdService(o.Config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -95,8 +95,6 @@ type CRIContainerdOptions struct {
|
|||||||
Config
|
Config
|
||||||
// Path to the TOML config file.
|
// Path to the TOML config file.
|
||||||
ConfigFilePath string `toml:"-"`
|
ConfigFilePath string `toml:"-"`
|
||||||
// PrintVersion indicates to print version information of cri-containerd.
|
|
||||||
PrintVersion bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCRIContainerdOptions returns a reference to CRIContainerdOptions
|
// 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.")
|
defaults.ContainerdConfig.RuntimeEngine, "Runtime engine used by containerd. Defaults to containerd's default if not specified.")
|
||||||
fs.StringVar(&c.ContainerdConfig.RuntimeRoot, "containerd-runtime-root",
|
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.")
|
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",
|
fs.StringVar(&c.NetworkPluginBinDir, "network-bin-dir",
|
||||||
defaults.NetworkPluginBinDir, "The directory for putting network binaries.")
|
defaults.NetworkPluginBinDir, "The directory for putting network binaries.")
|
||||||
fs.StringVar(&c.NetworkPluginConfDir, "network-conf-dir",
|
fs.StringVar(&c.NetworkPluginConfDir, "network-conf-dir",
|
||||||
|
Loading…
Reference in New Issue
Block a user