mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 04:04:45 +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.
|
||||
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
|
||||
var configFilePathOption = fmt.Sprintf("%s-config", projectPrefix)
|
||||
var showConfigPathsOption = fmt.Sprintf("%s-show-default-config-paths", projectPrefix)
|
||||
|
@ -306,8 +306,9 @@ func genericHostIsVMContainerCapable(details vmContainerCapableDetails) error {
|
||||
}
|
||||
|
||||
var kataCheckCLICommand = cli.Command{
|
||||
Name: checkCmd,
|
||||
Usage: "tests if system can run " + project,
|
||||
Name: "check",
|
||||
Aliases: []string{"kata-check"},
|
||||
Usage: "tests if system can run " + project,
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "check-version-only",
|
||||
@ -344,36 +345,36 @@ EXAMPLES:
|
||||
|
||||
- Perform basic checks:
|
||||
|
||||
$ %s %s
|
||||
$ %s check
|
||||
|
||||
- Local basic checks only:
|
||||
|
||||
$ %s %s --no-network-checks
|
||||
$ %s check --no-network-checks
|
||||
|
||||
- Perform further checks:
|
||||
|
||||
$ sudo %s %s
|
||||
$ sudo %s check
|
||||
|
||||
- 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"):
|
||||
|
||||
$ %s %s --only-list-releases
|
||||
$ %s check --only-list-releases
|
||||
|
||||
- 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,
|
||||
noNetworkEnvVar,
|
||||
name, checkCmd,
|
||||
name, checkCmd,
|
||||
name, checkCmd,
|
||||
name, checkCmd,
|
||||
name, checkCmd,
|
||||
name, checkCmd,
|
||||
name,
|
||||
name,
|
||||
name,
|
||||
name,
|
||||
name,
|
||||
name,
|
||||
),
|
||||
|
||||
Action: func(context *cli.Context) error {
|
||||
@ -386,7 +387,7 @@ EXAMPLES:
|
||||
return err
|
||||
}
|
||||
|
||||
span, _ := katautils.Trace(ctx, "kata-check")
|
||||
span, _ := katautils.Trace(ctx, "check")
|
||||
defer span.Finish()
|
||||
|
||||
if context.Bool("no-network-checks") == false && os.Getenv(noNetworkEnvVar) == "" {
|
||||
@ -413,7 +414,7 @@ EXAMPLES:
|
||||
|
||||
runtimeConfig, ok := context.App.Metadata["runtimeConfig"].(oci.RuntimeConfig)
|
||||
if !ok {
|
||||
return errors.New("kata-check: cannot determine runtime config")
|
||||
return errors.New("check: cannot determine runtime config")
|
||||
}
|
||||
|
||||
err = setCPUtype(runtimeConfig.HypervisorType)
|
||||
|
@ -437,8 +437,9 @@ func writeJSONSettings(env EnvInfo, file *os.File) error {
|
||||
}
|
||||
|
||||
var kataEnvCLICommand = cli.Command{
|
||||
Name: envCmd,
|
||||
Usage: "display settings. Default to TOML",
|
||||
Name: "env",
|
||||
Aliases: []string{"kata-env"},
|
||||
Usage: "display settings. Default to TOML",
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "json",
|
||||
|
@ -272,7 +272,7 @@ func beforeSubcommands(c *cli.Context) error {
|
||||
ignoreConfigLogs := false
|
||||
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 {
|
||||
// checkCmd will use the default logrus logger to stderr
|
||||
// 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).
|
||||
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
|
||||
ignoreConfigLogs = true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user