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

CMD: Add json output on endpoint config #3234

Merged
merged 1 commit into from
Mar 21, 2018
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
3 changes: 2 additions & 1 deletion Documentation/cmdref/cilium_endpoint_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ endpoint config 5421 DropNotification=false TraceNotification=false
### Options

```
--list-options List available options
--list-options List available options
-o, --output string json| jsonpath='{}'
```

### Options inherited from parent commands
Expand Down
10 changes: 10 additions & 0 deletions cilium/cmd/endpoint_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ package cmd

import (
"fmt"
"os"

"github.com/cilium/cilium/api/v1/models"
"github.com/cilium/cilium/pkg/command"
"github.com/cilium/cilium/pkg/endpoint"
"github.com/cilium/cilium/pkg/option"

Expand Down Expand Up @@ -45,6 +47,7 @@ var endpointConfigCmd = &cobra.Command{
func init() {
endpointCmd.AddCommand(endpointConfigCmd)
endpointConfigCmd.Flags().BoolVarP(&listOptions, "list-options", "", false, "List available options")
command.AddJSONOutput(endpointConfigCmd)
}

func listEndpointOptions() {
Expand All @@ -62,6 +65,13 @@ func configEndpoint(cmd *cobra.Command, args []string) {

opts := args[1:]
if len(opts) == 0 {
if command.OutputJSON() {
if err := command.PrintOutput(cfg); err != nil {
os.Exit(1)
}
return
}

dumpConfig(cfg.Immutable)
dumpConfig(cfg.Mutable)
return
Expand Down