mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-30 04:34:27 +00:00
cli: Remove kata-
prefix from env and check subcommands
Provide the subcommands `kata-env` and `kata-check` as `env` and `check` respectively. Fixes #1011 Signed-off-by: Daniel Knittl-Frank <knittl89+git@googlemail.com> fixup! cli: Add aliases to kata-env and kata-check commands
This commit is contained in:
parent
063e8bd801
commit
c5d355e1ff
@ -36,10 +36,6 @@ var commit = "@COMMIT@"
|
|||||||
// version is the runtime version.
|
// version is the runtime version.
|
||||||
var version = "@VERSION@"
|
var version = "@VERSION@"
|
||||||
|
|
||||||
// project-specific command names
|
|
||||||
var envCmd = fmt.Sprintf("%s-env", projectPrefix)
|
|
||||||
var checkCmd = fmt.Sprintf("%s-check", projectPrefix)
|
|
||||||
|
|
||||||
// project-specific option names
|
// project-specific option names
|
||||||
var configFilePathOption = fmt.Sprintf("%s-config", projectPrefix)
|
var configFilePathOption = fmt.Sprintf("%s-config", projectPrefix)
|
||||||
var showConfigPathsOption = fmt.Sprintf("%s-show-default-config-paths", projectPrefix)
|
var showConfigPathsOption = fmt.Sprintf("%s-show-default-config-paths", projectPrefix)
|
||||||
|
@ -306,7 +306,8 @@ func genericHostIsVMContainerCapable(details vmContainerCapableDetails) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var kataCheckCLICommand = cli.Command{
|
var kataCheckCLICommand = cli.Command{
|
||||||
Name: checkCmd,
|
Name: "check",
|
||||||
|
Aliases: []string{"kata-check"},
|
||||||
Usage: "tests if system can run " + project,
|
Usage: "tests if system can run " + project,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
@ -344,36 +345,36 @@ EXAMPLES:
|
|||||||
|
|
||||||
- Perform basic checks:
|
- Perform basic checks:
|
||||||
|
|
||||||
$ %s %s
|
$ %s check
|
||||||
|
|
||||||
- Local basic checks only:
|
- Local basic checks only:
|
||||||
|
|
||||||
$ %s %s --no-network-checks
|
$ %s check --no-network-checks
|
||||||
|
|
||||||
- Perform further checks:
|
- Perform further checks:
|
||||||
|
|
||||||
$ sudo %s %s
|
$ sudo %s check
|
||||||
|
|
||||||
- Just check if a newer version is available:
|
- Just check if a newer version is available:
|
||||||
|
|
||||||
$ %s %s --check-version-only
|
$ %s check --check-version-only
|
||||||
|
|
||||||
- List available releases (shows output in format "version;release-date;url"):
|
- List available releases (shows output in format "version;release-date;url"):
|
||||||
|
|
||||||
$ %s %s --only-list-releases
|
$ %s check --only-list-releases
|
||||||
|
|
||||||
- List all available releases (includes pre-release versions):
|
- List all available releases (includes pre-release versions):
|
||||||
|
|
||||||
$ %s %s --only-list-releases --include-all-releases
|
$ %s check --only-list-releases --include-all-releases
|
||||||
`,
|
`,
|
||||||
project,
|
project,
|
||||||
noNetworkEnvVar,
|
noNetworkEnvVar,
|
||||||
name, checkCmd,
|
name,
|
||||||
name, checkCmd,
|
name,
|
||||||
name, checkCmd,
|
name,
|
||||||
name, checkCmd,
|
name,
|
||||||
name, checkCmd,
|
name,
|
||||||
name, checkCmd,
|
name,
|
||||||
),
|
),
|
||||||
|
|
||||||
Action: func(context *cli.Context) error {
|
Action: func(context *cli.Context) error {
|
||||||
@ -386,7 +387,7 @@ EXAMPLES:
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
span, _ := katautils.Trace(ctx, "kata-check")
|
span, _ := katautils.Trace(ctx, "check")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
if context.Bool("no-network-checks") == false && os.Getenv(noNetworkEnvVar) == "" {
|
if context.Bool("no-network-checks") == false && os.Getenv(noNetworkEnvVar) == "" {
|
||||||
@ -413,7 +414,7 @@ EXAMPLES:
|
|||||||
|
|
||||||
runtimeConfig, ok := context.App.Metadata["runtimeConfig"].(oci.RuntimeConfig)
|
runtimeConfig, ok := context.App.Metadata["runtimeConfig"].(oci.RuntimeConfig)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("kata-check: cannot determine runtime config")
|
return errors.New("check: cannot determine runtime config")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = setCPUtype(runtimeConfig.HypervisorType)
|
err = setCPUtype(runtimeConfig.HypervisorType)
|
||||||
|
@ -437,7 +437,8 @@ func writeJSONSettings(env EnvInfo, file *os.File) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var kataEnvCLICommand = cli.Command{
|
var kataEnvCLICommand = cli.Command{
|
||||||
Name: envCmd,
|
Name: "env",
|
||||||
|
Aliases: []string{"kata-env"},
|
||||||
Usage: "display settings. Default to TOML",
|
Usage: "display settings. Default to TOML",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
|
@ -272,7 +272,7 @@ func beforeSubcommands(c *cli.Context) error {
|
|||||||
ignoreConfigLogs := false
|
ignoreConfigLogs := false
|
||||||
var traceRootSpan string
|
var traceRootSpan string
|
||||||
|
|
||||||
subCmdIsCheckCmd := (c.NArg() >= 1 && (c.Args()[0] == checkCmd))
|
subCmdIsCheckCmd := (c.NArg() >= 1 && ((c.Args()[0] == "kata-check") || (c.Args()[0] == "check")))
|
||||||
if subCmdIsCheckCmd {
|
if subCmdIsCheckCmd {
|
||||||
// checkCmd will use the default logrus logger to stderr
|
// checkCmd will use the default logrus logger to stderr
|
||||||
// raise the logger default level to warn
|
// raise the logger default level to warn
|
||||||
@ -313,7 +313,7 @@ func beforeSubcommands(c *cli.Context) error {
|
|||||||
// (meaning any spans created at this point will be silently ignored).
|
// (meaning any spans created at this point will be silently ignored).
|
||||||
setExternalLoggers(context.Background(), kataLog)
|
setExternalLoggers(context.Background(), kataLog)
|
||||||
|
|
||||||
if c.NArg() == 1 && c.Args()[0] == envCmd {
|
if c.NArg() == 1 && (c.Args()[0] == "kata-env" || c.Args()[0] == "env") {
|
||||||
// simply report the logging setup
|
// simply report the logging setup
|
||||||
ignoreConfigLogs = true
|
ignoreConfigLogs = true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user