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

[HCP Vault Secrets] Print out Gateway Pool Resource ID for gateway commands #195

Merged
merged 6 commits into from
Nov 19, 2024
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: 3 additions & 0 deletions .changelog/195.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
vault-secrets: adding Gateway Pool Resource ID to the output of gateway commands.
```
20 changes: 12 additions & 8 deletions internal/commands/vaultsecrets/gatewaypools/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,20 @@ func NewCmdCreate(ctx *cmd.Context, runF func(*CreateOpts) error) *cmd.Command {
func createFields(showOauth bool) []format.Field {
fields := []format.Field{
{
Name: "GatewayPool Name",
Name: "Gateway Pool Name",
ValueFormat: "{{ .GatewayPool.Name }}",
},
{
Name: "Description",
ValueFormat: "{{ .GatewayPool.Description }}",
Name: "Gateway Pool Resource Name",
ValueFormat: "{{ .GatewayPool.ResourceName }}",
},
{
Name: "Resource Name",
ValueFormat: "{{ .GatewayPool.ResourceName }}",
Name: "Gateway Pool Resource ID",
ValueFormat: "{{ .GatewayPool.ResourceID }}",
},
{
Name: "Description",
ValueFormat: "{{ .GatewayPool.Description }}",
},
}

Expand All @@ -143,6 +147,7 @@ func createFields(showOauth bool) []format.Field {
},
}...)
}

return fields
}

Expand All @@ -164,7 +169,6 @@ func createRun(opts *CreateOpts) error {
Description: opts.Description,
},
}, nil)

if err != nil {
return fmt.Errorf("failed to create gateway pool: %w", err)
}
Expand Down Expand Up @@ -205,8 +209,8 @@ func createRun(opts *CreateOpts) error {
}

type gatewayCreds struct {
ProjectID string `json:"project_id,omitempty"`
ResourceName string `json:"resource_name,omitempty"`
ProjectID string `json:"project_id,omitempty"`

// Scheme is the authentication scheme which is service_principal_creds
Scheme string `json:"scheme,omitempty"`

Expand Down
10 changes: 9 additions & 1 deletion internal/commands/vaultsecrets/gatewaypools/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,17 @@ func NewCmdList(ctx *cmd.Context, runF func(*ListOpts) error) *cmd.Command {
func listFields() []format.Field {
return []format.Field{
{
Name: "GatewayPool Name",
Name: "Gateway Pool Name",
ValueFormat: "{{ .Name }}",
},
{
Name: "Gateway Pool Resource Name",
ValueFormat: "{{ .ResourceName }}",
},
{
Name: "Gateway Pool Resource ID",
ValueFormat: "{{ .ResourceID }}",
},
{
Name: "Description",
ValueFormat: "{{ .Description }}",
Expand Down
15 changes: 11 additions & 4 deletions internal/commands/vaultsecrets/gatewaypools/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,25 @@ func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command {
func readFields() []format.Field {
return []format.Field{
{
Name: "GatewayPool Name",
Name: "Gateway Pool Name",
ValueFormat: "{{ .GatewayPool.Name }}",
},
{
Name: "Description",
ValueFormat: "{{ .GatewayPool.Description }}",
Name: "Gateway Pool Resource Name",
ValueFormat: "{{ .GatewayPool.ResourceName }}",
},
{
Name: "Gateway Pool Resource ID",
ValueFormat: "{{ .GatewayPool.ResourceID }}",
},
{
Name: "Integrations",
ValueFormat: "{{ .Integrations }}",
},
{
Name: "Description",
ValueFormat: "{{ .GatewayPool.Description }}",
},
}
}

Expand All @@ -94,7 +102,6 @@ func readRun(opts *ReadOpts) error {
OrganizationID: opts.Profile.OrganizationID,
GatewayPoolName: opts.GatewayPoolName,
}, nil)

if err != nil {
return fmt.Errorf("failed to read gateway pool: %w", err)
}
Expand Down