From 02ee8b0b8a6eda1d61e5c7f54bbf5f3816fdeccb Mon Sep 17 00:00:00 2001 From: Daniel Knittl-Frank Date: Sat, 24 Oct 2020 12:29:22 +0200 Subject: [PATCH] cli: Add aliases for kata- options Remove `kata-` prefix from options `kata-config` and `kata-show-default-config-paths`. Fixes #1011 Signed-off-by: Daniel Knittl-Frank --- src/runtime/cli/config-generated.go.in | 8 -------- src/runtime/cli/main.go | 12 ++++++------ src/runtime/cli/main_test.go | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/runtime/cli/config-generated.go.in b/src/runtime/cli/config-generated.go.in index 3e0589f498..baa6d9cd0c 100644 --- a/src/runtime/cli/config-generated.go.in +++ b/src/runtime/cli/config-generated.go.in @@ -9,10 +9,6 @@ // by the tests. package main -import ( - "fmt" -) - // name is the name of the runtime const name = "@RUNTIME_NAME@" @@ -36,10 +32,6 @@ var commit = "@COMMIT@" // version is the runtime version. var version = "@VERSION@" -// project-specific option names -var configFilePathOption = fmt.Sprintf("%s-config", projectPrefix) -var showConfigPathsOption = fmt.Sprintf("%s-show-default-config-paths", projectPrefix) - // Default config file used by stateless systems. var defaultRuntimeConfiguration = "@CONFIG_PATH@" diff --git a/src/runtime/cli/main.go b/src/runtime/cli/main.go index 28ff5de369..3b331db288 100644 --- a/src/runtime/cli/main.go +++ b/src/runtime/cli/main.go @@ -84,8 +84,8 @@ var defaultErrorFile = os.Stderr // runtimeFlags is the list of supported global command-line flags var runtimeFlags = []cli.Flag{ cli.StringFlag{ - Name: configFilePathOption, - Usage: project + " config file path", + Name: "config, kata-config", + Usage: project + " config file path", }, cli.StringFlag{ Name: "log", @@ -108,8 +108,8 @@ var runtimeFlags = []cli.Flag{ Usage: "ignore cgroup permission errors ('true', 'false', or 'auto')", }, cli.BoolFlag{ - Name: showConfigPathsOption, - Usage: "show config file paths that will be checked for (in order)", + Name: "show-default-config-paths, kata-show-default-config-paths", + Usage: "show config file paths that will be checked for (in order)", }, cli.BoolFlag{ Name: "systemd-cgroup", @@ -319,7 +319,7 @@ func beforeSubcommands(c *cli.Context) error { } } - configFile, runtimeConfig, err = katautils.LoadConfiguration(c.GlobalString(configFilePathOption), ignoreConfigLogs, false) + configFile, runtimeConfig, err = katautils.LoadConfiguration(c.GlobalString("config"), ignoreConfigLogs, false) if err != nil { fatal(err) } @@ -366,7 +366,7 @@ func beforeSubcommands(c *cli.Context) error { // handleShowConfig determines if the user wishes to see the configuration // paths. If so, it will display them and then exit. func handleShowConfig(context *cli.Context) { - if context.GlobalBool(showConfigPathsOption) { + if context.GlobalBool("show-default-config-paths") { files := katautils.GetDefaultConfigFilePaths() for _, file := range files { diff --git a/src/runtime/cli/main_test.go b/src/runtime/cli/main_test.go index 94140162da..3bd8e64815 100644 --- a/src/runtime/cli/main_test.go +++ b/src/runtime/cli/main_test.go @@ -671,7 +671,7 @@ func TestMainBeforeSubCommandsShowCCConfigPaths(t *testing.T) { defer os.RemoveAll(tmpdir) set := flag.NewFlagSet("", 0) - set.Bool("kata-show-default-config-paths", true, "") + set.Bool("show-default-config-paths", true, "") ctx := createCLIContext(set)