From 43772794b1c91a8a3cb503dbc103e36eba1e1e7c Mon Sep 17 00:00:00 2001 From: Anton Averchenkov <84287187+averche@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:38:00 -0500 Subject: [PATCH] [HCP Vault Secrets] Print out Gateway Pool Resource ID for gateway commands (#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 --- .changelog/195.txt | 3 +++ .../vaultsecrets/gatewaypools/create.go | 20 +++++++++++-------- .../vaultsecrets/gatewaypools/list.go | 10 +++++++++- .../vaultsecrets/gatewaypools/read.go | 15 ++++++++++---- 4 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 .changelog/195.txt diff --git a/.changelog/195.txt b/.changelog/195.txt new file mode 100644 index 00000000..36c32df1 --- /dev/null +++ b/.changelog/195.txt @@ -0,0 +1,3 @@ +```release-note:improvement +vault-secrets: adding Gateway Pool Resource ID to the output of gateway commands. +``` diff --git a/internal/commands/vaultsecrets/gatewaypools/create.go b/internal/commands/vaultsecrets/gatewaypools/create.go index 71597b68..56a715f6 100644 --- a/internal/commands/vaultsecrets/gatewaypools/create.go +++ b/internal/commands/vaultsecrets/gatewaypools/create.go @@ -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 }}", }, } @@ -143,6 +147,7 @@ func createFields(showOauth bool) []format.Field { }, }...) } + return fields } @@ -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) } @@ -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"` diff --git a/internal/commands/vaultsecrets/gatewaypools/list.go b/internal/commands/vaultsecrets/gatewaypools/list.go index 65af7f8d..ed541294 100644 --- a/internal/commands/vaultsecrets/gatewaypools/list.go +++ b/internal/commands/vaultsecrets/gatewaypools/list.go @@ -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 }}", diff --git a/internal/commands/vaultsecrets/gatewaypools/read.go b/internal/commands/vaultsecrets/gatewaypools/read.go index 951ea3fd..ef832507 100644 --- a/internal/commands/vaultsecrets/gatewaypools/read.go +++ b/internal/commands/vaultsecrets/gatewaypools/read.go @@ -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 }}", + }, } } @@ -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) }