Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crictl config add list flag #1090

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions cmd/crictl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ CRICTL OPTIONS:
Name: "set",
Usage: "set option (can specify multiple or separate values with commas: opt1=val1,opt2=val2)",
},
&cli.BoolFlag{
Name: "list",
Usage: "show all option value",
},
},
Action: func(context *cli.Context) error {
configFile := context.String("config")
Expand All @@ -65,6 +69,7 @@ CRICTL OPTIONS:
if err != nil {
return fmt.Errorf("load config file: %w", err)
}

if context.IsSet("get") {
get := context.String("get")
switch get {
Expand Down Expand Up @@ -101,6 +106,19 @@ CRICTL OPTIONS:
}
}
return common.WriteConfig(config, configFile)
} else if context.Bool("list") {
display := newTableDisplay(20, 1, 3, ' ', 0)
display.AddRow([]string{columnKey, columnValue})
display.AddRow([]string{"runtime-endpoint", config.RuntimeEndpoint})
display.AddRow([]string{"image-endpoint", config.RuntimeEndpoint})
display.AddRow([]string{"timeout", config.RuntimeEndpoint})
display.AddRow([]string{"debug", config.RuntimeEndpoint})
display.AddRow([]string{"pull-image-on-create", config.RuntimeEndpoint})
display.AddRow([]string{"disable-pull-on-run", config.RuntimeEndpoint})
display.ClearScreen()
display.Flush()

return nil
} else { // default for backwards compatibility
key := context.Args().First()
if key == "" {
Expand Down
2 changes: 2 additions & 0 deletions cmd/crictl/display.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ const (
columnDisk = "DISK"
columnCPU = "CPU %"
columnPodname = "POD"
columnKey = "KEY"
columnValue = "VALUE"
)

// display use to output something on screen with table format.
Expand Down