Skip to content

Commit

Permalink
[HCP Vault Secrets] Print out Gateway Pool Resource ID for gateway co…
Browse files Browse the repository at this point in the history
…mmands (#195)

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

* fixes

* changelog

* remove from creds file

* add back resource name

* swap columns
  • Loading branch information
averche authored Nov 19, 2024
1 parent 038205f commit 4377279
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
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

0 comments on commit 4377279

Please sign in to comment.