Skip to content

Commit

Permalink
Merge pull request #1662 from saschagrunert/config-default
Browse files Browse the repository at this point in the history
Clarify that `crictl config` without args refers to `set`
  • Loading branch information
k8s-ci-robot authored Oct 28, 2024
2 parents 47503b3 + baca737 commit f4d03d4
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions cmd/crictl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,34 @@ import (
"strconv"
"strings"

"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"

"sigs.k8s.io/cri-tools/pkg/common"
)

var configCommand = &cli.Command{
Name: "config",
Usage: "Get and set crictl client configuration options",
Usage: "Get, set and list crictl configuration options",
ArgsUsage: `[<crictl options>]
EXAMPLE:
EXAMPLES:
# Set the key "debug" to "true"
crictl config --set debug=true
# Set the key "debug" to "true"
crictl config debug true
# Get the value of "debug"
crictl config --get debug
# Show the full configuration
crictl config --list
CRICTL OPTIONS:
runtime-endpoint: Container runtime endpoint
image-endpoint: Image endpoint
timeout: Timeout of connecting to server (default: 2s)
runtime-endpoint: Container Runtime Interface (CRI) runtime endpoint (default: "")
image-endpoint: Container Runtime Interface (CRI) image endpoint (default: "")
timeout: Timeout of connecting to server (default: 2)
debug: Enable debug output (default: false)
pull-image-on-create: Enable pulling image on create requests (default: false)
disable-pull-on-run: Disable pulling image on run requests (default: false)`,
Expand Down Expand Up @@ -126,8 +137,9 @@ CRICTL OPTIONS:
return cli.ShowSubcommandHelp(c)
}
value := c.Args().Get(1)
logrus.Infof("No --get, --set or --list provided, setting key %q to value %q", key, value)
if err := setValue(key, value, config); err != nil {
return err
return fmt.Errorf("set %q to %q: %w", key, value, err)
}
return common.WriteConfig(config, configFile)
},
Expand Down

0 comments on commit f4d03d4

Please sign in to comment.