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 <knittl89+git@googlemail.com>
This commit is contained in:
Daniel Knittl-Frank 2020-10-24 12:29:22 +02:00
parent c6bc43b697
commit 02ee8b0b8a
3 changed files with 7 additions and 15 deletions

View File

@ -9,10 +9,6 @@
// by the tests. // by the tests.
package main package main
import (
"fmt"
)
// name is the name of the runtime // name is the name of the runtime
const name = "@RUNTIME_NAME@" const name = "@RUNTIME_NAME@"
@ -36,10 +32,6 @@ var commit = "@COMMIT@"
// version is the runtime version. // version is the runtime version.
var version = "@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. // Default config file used by stateless systems.
var defaultRuntimeConfiguration = "@CONFIG_PATH@" var defaultRuntimeConfiguration = "@CONFIG_PATH@"

View File

@ -84,7 +84,7 @@ var defaultErrorFile = os.Stderr
// runtimeFlags is the list of supported global command-line flags // runtimeFlags is the list of supported global command-line flags
var runtimeFlags = []cli.Flag{ var runtimeFlags = []cli.Flag{
cli.StringFlag{ cli.StringFlag{
Name: configFilePathOption, Name: "config, kata-config",
Usage: project + " config file path", Usage: project + " config file path",
}, },
cli.StringFlag{ cli.StringFlag{
@ -108,7 +108,7 @@ var runtimeFlags = []cli.Flag{
Usage: "ignore cgroup permission errors ('true', 'false', or 'auto')", Usage: "ignore cgroup permission errors ('true', 'false', or 'auto')",
}, },
cli.BoolFlag{ cli.BoolFlag{
Name: showConfigPathsOption, Name: "show-default-config-paths, kata-show-default-config-paths",
Usage: "show config file paths that will be checked for (in order)", Usage: "show config file paths that will be checked for (in order)",
}, },
cli.BoolFlag{ cli.BoolFlag{
@ -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 { if err != nil {
fatal(err) fatal(err)
} }
@ -366,7 +366,7 @@ func beforeSubcommands(c *cli.Context) error {
// handleShowConfig determines if the user wishes to see the configuration // handleShowConfig determines if the user wishes to see the configuration
// paths. If so, it will display them and then exit. // paths. If so, it will display them and then exit.
func handleShowConfig(context *cli.Context) { func handleShowConfig(context *cli.Context) {
if context.GlobalBool(showConfigPathsOption) { if context.GlobalBool("show-default-config-paths") {
files := katautils.GetDefaultConfigFilePaths() files := katautils.GetDefaultConfigFilePaths()
for _, file := range files { for _, file := range files {

View File

@ -671,7 +671,7 @@ func TestMainBeforeSubCommandsShowCCConfigPaths(t *testing.T) {
defer os.RemoveAll(tmpdir) defer os.RemoveAll(tmpdir)
set := flag.NewFlagSet("", 0) set := flag.NewFlagSet("", 0)
set.Bool("kata-show-default-config-paths", true, "") set.Bool("show-default-config-paths", true, "")
ctx := createCLIContext(set) ctx := createCLIContext(set)