Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3044 from hashicorp/context-create-set-default
Browse files Browse the repository at this point in the history
Fix the -set-default flag for `context create`.
  • Loading branch information
izaaklauer authored Feb 28, 2022
2 parents 7d04fc1 + e096631 commit 9ab9501
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/3044.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cli: Fix the -set-default flag on `waypoint context create`
```
14 changes: 11 additions & 3 deletions internal/cli/context_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ func (c *ContextCreateCommand) Run(args []string) int {
return 1
}

if c.flagSetDefault {
if err := c.contextStorage.SetDefault(name); err != nil {
c.ui.Output(clierrors.Humanize(err), terminal.WithErrorStyle())
return 1
}
}

c.ui.Output("Context %q created.", name, terminal.WithSuccessStyle())
return 0
}
Expand All @@ -51,9 +58,10 @@ func (c *ContextCreateCommand) Flags() *flag.Sets {
return c.flagSet(0, func(set *flag.Sets) {
f := set.NewSet("Command Options")
f.BoolVar(&flag.BoolVar{
Name: "set-default",
Target: &c.flagSetDefault,
Usage: "Set this context as the new default for the CLI.",
Name: "set-default",
Target: &c.flagSetDefault,
Default: true,
Usage: "Set this context as the new default for the CLI. Defaults to true.",
})
f.StringVar(&flag.StringVar{
Name: "server-addr",
Expand Down
2 changes: 1 addition & 1 deletion website/content/commands/context-create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Creates a new context.

#### Command Options

- `-set-default` - Set this context as the new default for the CLI.
- `-set-default` - Set this context as the new default for the CLI. Defaults to true.
- `-server-addr=<string>` - Address for the server.
- `-server-auth-token=<string>` - Authentication token to use to connect to the server.
- `-server-tls` - If true, will connect to the server over TLS.
Expand Down

0 comments on commit 9ab9501

Please sign in to comment.