From 868356a215c47fa3270423d0fe90b576a54aed3b Mon Sep 17 00:00:00 2001 From: Keefer Bibby Date: Wed, 20 Nov 2024 15:16:48 -0800 Subject: [PATCH] hvs use 2023-11-28 api --- internal/commands/vaultsecrets/apps/create.go | 31 +++---- .../commands/vaultsecrets/apps/create_test.go | 18 ++-- internal/commands/vaultsecrets/apps/delete.go | 29 +++--- .../commands/vaultsecrets/apps/delete_test.go | 12 +-- .../commands/vaultsecrets/apps/displayer.go | 27 +----- .../vaultsecrets/apps/helper/helper.go | 12 +-- internal/commands/vaultsecrets/apps/list.go | 23 ++--- .../commands/vaultsecrets/apps/list_test.go | 38 ++++---- internal/commands/vaultsecrets/apps/read.go | 29 +++--- .../commands/vaultsecrets/apps/read_test.go | 18 ++-- .../commands/vaultsecrets/apps/update_test.go | 20 ++-- .../commands/vaultsecrets/apps/updates.go | 33 ++++--- .../vaultsecrets/gatewaypools/create.go | 16 ++-- .../vaultsecrets/gatewaypools/delete.go | 18 ++-- .../vaultsecrets/gatewaypools/helper.go | 10 +- .../vaultsecrets/gatewaypools/list.go | 18 ++-- .../list_gateway_pools_gateways.go | 18 ++-- .../vaultsecrets/gatewaypools/read.go | 20 ++-- .../vaultsecrets/gatewaypools/update.go | 16 ++-- .../vaultsecrets/integrations/create.go | 39 ++++---- .../vaultsecrets/integrations/create_test.go | 32 +++---- .../vaultsecrets/integrations/delete.go | 25 +++-- .../vaultsecrets/integrations/delete_test.go | 12 +-- .../vaultsecrets/integrations/list.go | 57 ++++++------ .../vaultsecrets/integrations/list_test.go | 40 ++++---- .../vaultsecrets/integrations/read.go | 27 +++--- .../vaultsecrets/integrations/read_test.go | 20 ++-- .../vaultsecrets/integrations/update.go | 39 ++++---- .../vaultsecrets/integrations/update_test.go | 36 ++++---- internal/commands/vaultsecrets/run/run.go | 27 +++--- .../commands/vaultsecrets/run/run_test.go | 68 +++++++------- .../commands/vaultsecrets/secrets/create.go | 65 +++++++------ .../vaultsecrets/secrets/create_test.go | 92 +++++++++---------- .../commands/vaultsecrets/secrets/delete.go | 27 +++--- .../vaultsecrets/secrets/delete_test.go | 14 +-- .../vaultsecrets/secrets/displayer.go | 46 +++------- .../vaultsecrets/secrets/helper/helper.go | 12 +-- .../commands/vaultsecrets/secrets/list.go | 25 +++-- .../vaultsecrets/secrets/list_test.go | 40 ++++---- .../commands/vaultsecrets/secrets/open.go | 21 ++--- .../vaultsecrets/secrets/open_test.go | 32 +++---- .../commands/vaultsecrets/secrets/read.go | 29 +++--- .../vaultsecrets/secrets/read_test.go | 30 +++--- .../commands/vaultsecrets/secrets/rotate.go | 27 +++--- .../vaultsecrets/secrets/rotate_test.go | 24 ++--- .../commands/vaultsecrets/secrets/secrets.go | 4 +- .../commands/vaultsecrets/secrets/update.go | 59 ++++++------ .../vaultsecrets/secrets/update_test.go | 71 +++++++------- .../vaultsecrets/secrets/versions/list.go | 25 +++-- .../secrets/versions/list_test.go | 46 +++++----- 50 files changed, 705 insertions(+), 812 deletions(-) diff --git a/internal/commands/vaultsecrets/apps/create.go b/internal/commands/vaultsecrets/apps/create.go index 29807630..178a4c34 100644 --- a/internal/commands/vaultsecrets/apps/create.go +++ b/internal/commands/vaultsecrets/apps/create.go @@ -7,8 +7,9 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" "github.com/hashicorp/hcp/internal/pkg/format" @@ -23,20 +24,18 @@ type CreateOpts struct { Output *format.Outputter IO iostreams.IOStreams - AppName string - Description string - Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService + AppName string + Description string + Client secret_service.ClientService } func NewCmdCreate(ctx *cmd.Context, runF func(*CreateOpts) error) *cmd.Command { opts := &CreateOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - Client: secret_service.New(ctx.HCP, nil), - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -88,10 +87,10 @@ func NewCmdCreate(ctx *cmd.Context, runF func(*CreateOpts) error) *cmd.Command { func createRun(opts *CreateOpts) error { resp, err := opts.Client.CreateApp(&secret_service.CreateAppParams{ - Context: opts.Ctx, - LocationProjectID: opts.Profile.ProjectID, - LocationOrganizationID: opts.Profile.OrganizationID, - Body: secret_service.CreateAppBody{ + Context: opts.Ctx, + ProjectID: opts.Profile.ProjectID, + OrganizationID: opts.Profile.OrganizationID, + Body: &models.SecretServiceCreateAppBody{ Name: opts.AppName, Description: opts.Description, }, diff --git a/internal/commands/vaultsecrets/apps/create_test.go b/internal/commands/vaultsecrets/apps/create_test.go index 601c678d..101422d6 100644 --- a/internal/commands/vaultsecrets/apps/create_test.go +++ b/internal/commands/vaultsecrets/apps/create_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/models" - mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -151,16 +151,16 @@ func TestCreateRun(t *testing.T) { vs.EXPECT().CreateApp(mock.Anything, mock.Anything).Return(nil, errors.New("missing app name")).Once() } else { vs.EXPECT().CreateApp(&secret_service.CreateAppParams{ - Context: opts.Ctx, - LocationOrganizationID: "123", - LocationProjectID: "abc", - Body: secret_service.CreateAppBody{ + Context: opts.Ctx, + OrganizationID: "123", + ProjectID: "abc", + Body: &models.SecretServiceCreateAppBody{ Name: opts.AppName, Description: opts.Description, }, }, nil).Return(&secret_service.CreateAppOK{ - Payload: &models.Secrets20230613CreateAppResponse{ - App: &models.Secrets20230613App{ + Payload: &models.Secrets20231128CreateAppResponse{ + App: &models.Secrets20231128App{ Name: opts.AppName, Description: opts.Description, }, diff --git a/internal/commands/vaultsecrets/apps/delete.go b/internal/commands/vaultsecrets/apps/delete.go index 3286d457..a72614c8 100644 --- a/internal/commands/vaultsecrets/apps/delete.go +++ b/internal/commands/vaultsecrets/apps/delete.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/apps/helper" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" @@ -23,19 +22,17 @@ type DeleteOpts struct { Output *format.Outputter IO iostreams.IOStreams - AppName string - Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService + AppName string + Client secret_service.ClientService } func NewCmdDelete(ctx *cmd.Context, runF func(*DeleteOpts) error) *cmd.Command { opts := &DeleteOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - Client: secret_service.New(ctx.HCP, nil), - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -69,17 +66,17 @@ func NewCmdDelete(ctx *cmd.Context, runF func(*DeleteOpts) error) *cmd.Command { return deleteRun(opts) }, } - cmd.Args.Autocomplete = helper.PredictAppName(ctx, cmd, preview_secret_service.New(ctx.HCP, nil)) + cmd.Args.Autocomplete = helper.PredictAppName(ctx, cmd, secret_service.New(ctx.HCP, nil)) return cmd } func deleteRun(opts *DeleteOpts) error { _, err := opts.Client.DeleteApp(&secret_service.DeleteAppParams{ - Context: opts.Ctx, - LocationOrganizationID: opts.Profile.OrganizationID, - LocationProjectID: opts.Profile.ProjectID, - Name: opts.AppName, + Context: opts.Ctx, + OrganizationID: opts.Profile.OrganizationID, + ProjectID: opts.Profile.ProjectID, + Name: opts.AppName, }, nil) if err != nil { diff --git a/internal/commands/vaultsecrets/apps/delete_test.go b/internal/commands/vaultsecrets/apps/delete_test.go index d7fe9267..8b565faa 100644 --- a/internal/commands/vaultsecrets/apps/delete_test.go +++ b/internal/commands/vaultsecrets/apps/delete_test.go @@ -13,8 +13,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -135,10 +135,10 @@ func TestDeleteRun(t *testing.T) { vs.EXPECT().DeleteApp(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { vs.EXPECT().DeleteApp(&secret_service.DeleteAppParams{ - LocationOrganizationID: "123", - LocationProjectID: "abc", - Name: opts.AppName, - Context: opts.Ctx, + OrganizationID: "123", + ProjectID: "abc", + Name: opts.AppName, + Context: opts.Ctx, }, nil).Return(&secret_service.DeleteAppOK{}, nil).Once() } diff --git a/internal/commands/vaultsecrets/apps/displayer.go b/internal/commands/vaultsecrets/apps/displayer.go index 798e4bd7..28cc3241 100644 --- a/internal/commands/vaultsecrets/apps/displayer.go +++ b/internal/commands/vaultsecrets/apps/displayer.go @@ -4,49 +4,28 @@ package apps import ( - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/models" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/format" ) type displayer struct { - apps []*models.Secrets20230613App - previewApps []*preview_models.Secrets20231128App + apps []*models.Secrets20231128App single bool } -func newDisplayer(single bool, apps ...*models.Secrets20230613App) *displayer { +func newDisplayer(single bool, apps ...*models.Secrets20231128App) *displayer { return &displayer{ apps: apps, single: single, } } -func newDisplayerPreview(single bool, apps ...*preview_models.Secrets20231128App) *displayer { - return &displayer{ - previewApps: apps, - single: single, - } -} - func (d *displayer) DefaultFormat() format.Format { return format.Table } func (d *displayer) Payload() any { - if d.previewApps != nil { - if d.single { - if len(d.previewApps) != 1 { - return nil - } - - return d.previewApps[0] - } - - return d.previewApps - } - if d.single { if len(d.apps) != 1 { return nil diff --git a/internal/commands/vaultsecrets/apps/helper/helper.go b/internal/commands/vaultsecrets/apps/helper/helper.go index 4db5a62c..ecf32076 100644 --- a/internal/commands/vaultsecrets/apps/helper/helper.go +++ b/internal/commands/vaultsecrets/apps/helper/helper.go @@ -7,14 +7,14 @@ import ( "context" "fmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/posener/complete" ) // PredictAppName returns a predict function for application names. -func PredictAppName(ctx *cmd.Context, c *cmd.Command, client preview_secret_service.ClientService) complete.PredictFunc { +func PredictAppName(ctx *cmd.Context, c *cmd.Command, client secret_service.ClientService) complete.PredictFunc { return func(args complete.Args) []string { // Parse the args remainingArgs, err := ctx.ParseFlags(c, args.All) @@ -40,11 +40,11 @@ func PredictAppName(ctx *cmd.Context, c *cmd.Command, client preview_secret_serv } } -func getApps(ctx context.Context, orgID, projectID string, client preview_secret_service.ClientService) ([]*preview_models.Secrets20231128App, error) { - req := preview_secret_service.NewListAppsParamsWithContext(ctx) +func getApps(ctx context.Context, orgID, projectID string, client secret_service.ClientService) ([]*models.Secrets20231128App, error) { + req := secret_service.NewListAppsParamsWithContext(ctx) req.OrganizationID = orgID req.ProjectID = projectID - var apps []*preview_models.Secrets20231128App + var apps []*models.Secrets20231128App for { resp, err := client.ListApps(req, nil) diff --git a/internal/commands/vaultsecrets/apps/list.go b/internal/commands/vaultsecrets/apps/list.go index 09ca2698..f99d5fa6 100644 --- a/internal/commands/vaultsecrets/apps/list.go +++ b/internal/commands/vaultsecrets/apps/list.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" @@ -23,18 +22,16 @@ type ListOpts struct { Output *format.Outputter IO iostreams.IOStreams - Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService + Client secret_service.ClientService } func NewCmdList(ctx *cmd.Context, runF func(*ListOpts) error) *cmd.Command { opts := &ListOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -62,7 +59,7 @@ func NewCmdList(ctx *cmd.Context, runF func(*ListOpts) error) *cmd.Command { } func listRun(opts *ListOpts) error { - params := &preview_secret_service.ListAppsParams{ + params := &secret_service.ListAppsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -70,7 +67,7 @@ func listRun(opts *ListOpts) error { var apps []*models.Secrets20231128App for { - resp, err := opts.PreviewClient.ListApps(params, nil) + resp, err := opts.Client.ListApps(params, nil) if err != nil { return fmt.Errorf("failed to list apps: %w", err) @@ -84,5 +81,5 @@ func listRun(opts *ListOpts) error { next := resp.Payload.Pagination.NextPageToken params.PaginationNextPageToken = &next } - return opts.Output.Display(newDisplayerPreview(false, apps...)) + return opts.Output.Display(newDisplayer(false, apps...)) } diff --git a/internal/commands/vaultsecrets/apps/list_test.go b/internal/commands/vaultsecrets/apps/list_test.go index b2a57a4a..37435b9f 100644 --- a/internal/commands/vaultsecrets/apps/list_test.go +++ b/internal/commands/vaultsecrets/apps/list_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -95,40 +95,40 @@ func TestListRun(t *testing.T) { io := iostreams.Test() io.ErrorTTY = true - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &ListOpts{ - Ctx: context.Background(), - IO: io, - Profile: profile.TestProfile(t).SetOrgID("123").SetProjectID("abc"), - Output: format.New(io), - PreviewClient: vs, + Ctx: context.Background(), + IO: io, + Profile: profile.TestProfile(t).SetOrgID("123").SetProjectID("abc"), + Output: format.New(io), + Client: vs, } if c.ErrMsg != "" { vs.EXPECT().ListApps(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { paginationNextPageToken := "token" - vs.EXPECT().ListApps(&preview_secret_service.ListAppsParams{ + vs.EXPECT().ListApps(&secret_service.ListAppsParams{ OrganizationID: "123", ProjectID: "abc", Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.ListAppsOK{ - Payload: &preview_models.Secrets20231128ListAppsResponse{ + }, mock.Anything).Return(&secret_service.ListAppsOK{ + Payload: &models.Secrets20231128ListAppsResponse{ Apps: getMockApps(0, 10), - Pagination: &preview_models.CommonPaginationResponse{ + Pagination: &models.CommonPaginationResponse{ NextPageToken: paginationNextPageToken, }, }, }, nil).Once() - vs.EXPECT().ListApps(&preview_secret_service.ListAppsParams{ + vs.EXPECT().ListApps(&secret_service.ListAppsParams{ OrganizationID: "123", ProjectID: "abc", Context: opts.Ctx, PaginationNextPageToken: &paginationNextPageToken, - }, mock.Anything).Return(&preview_secret_service.ListAppsOK{ - Payload: &preview_models.Secrets20231128ListAppsResponse{ + }, mock.Anything).Return(&secret_service.ListAppsOK{ + Payload: &models.Secrets20231128ListAppsResponse{ Apps: getMockApps(10, 5), }, }, nil).Once() @@ -147,10 +147,10 @@ func TestListRun(t *testing.T) { } } -func getMockApps(start, limit int) []*preview_models.Secrets20231128App { - var secrets []*preview_models.Secrets20231128App +func getMockApps(start, limit int) []*models.Secrets20231128App { + var secrets []*models.Secrets20231128App for i := start; i < (start + limit); i++ { - secrets = append(secrets, &preview_models.Secrets20231128App{ + secrets = append(secrets, &models.Secrets20231128App{ Name: fmt.Sprint("test_app_", i), Description: fmt.Sprint("test_description_", i), }) diff --git a/internal/commands/vaultsecrets/apps/read.go b/internal/commands/vaultsecrets/apps/read.go index aa102cfd..70f2043f 100644 --- a/internal/commands/vaultsecrets/apps/read.go +++ b/internal/commands/vaultsecrets/apps/read.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/apps/helper" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" @@ -23,19 +22,17 @@ type ReadOpts struct { Output *format.Outputter IO iostreams.IOStreams - AppName string - Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService + AppName string + Client secret_service.ClientService } func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command { opts := &ReadOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - Client: secret_service.New(ctx.HCP, nil), - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -69,17 +66,17 @@ func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command { return readRun(opts) }, } - cmd.Args.Autocomplete = helper.PredictAppName(ctx, cmd, preview_secret_service.New(ctx.HCP, nil)) + cmd.Args.Autocomplete = helper.PredictAppName(ctx, cmd, secret_service.New(ctx.HCP, nil)) return cmd } func readRun(opts *ReadOpts) error { resp, err := opts.Client.GetApp(&secret_service.GetAppParams{ - Context: opts.Ctx, - LocationProjectID: opts.Profile.ProjectID, - LocationOrganizationID: opts.Profile.OrganizationID, - Name: opts.AppName, + Context: opts.Ctx, + ProjectID: opts.Profile.ProjectID, + OrganizationID: opts.Profile.OrganizationID, + Name: opts.AppName, }, nil) if err != nil { diff --git a/internal/commands/vaultsecrets/apps/read_test.go b/internal/commands/vaultsecrets/apps/read_test.go index 8ec74aba..2eaec548 100644 --- a/internal/commands/vaultsecrets/apps/read_test.go +++ b/internal/commands/vaultsecrets/apps/read_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/models" - mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -136,13 +136,13 @@ func TestReadRun(t *testing.T) { vs.EXPECT().GetApp(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { vs.EXPECT().GetApp(&secret_service.GetAppParams{ - LocationOrganizationID: "123", - LocationProjectID: "abc", - Name: opts.AppName, - Context: opts.Ctx, + OrganizationID: "123", + ProjectID: "abc", + Name: opts.AppName, + Context: opts.Ctx, }, nil).Return(&secret_service.GetAppOK{ - Payload: &models.Secrets20230613GetAppResponse{ - App: &models.Secrets20230613App{ + Payload: &models.Secrets20231128GetAppResponse{ + App: &models.Secrets20231128App{ Name: opts.AppName, }, }, diff --git a/internal/commands/vaultsecrets/apps/update_test.go b/internal/commands/vaultsecrets/apps/update_test.go index 897f1884..6a4c77ef 100644 --- a/internal/commands/vaultsecrets/apps/update_test.go +++ b/internal/commands/vaultsecrets/apps/update_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/models" - mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -155,16 +155,16 @@ func TestUpdateRun(t *testing.T) { vs.EXPECT().UpdateApp(mock.Anything, mock.Anything).Return(nil, errors.New(c.Error)).Once() } else { vs.EXPECT().UpdateApp(&secret_service.UpdateAppParams{ - Context: opts.Ctx, - LocationOrganizationID: "123", - LocationProjectID: "abc", - Name: opts.AppName, - Body: secret_service.UpdateAppBody{ + Context: opts.Ctx, + OrganizationID: "123", + ProjectID: "abc", + Name: opts.AppName, + Body: &models.SecretServiceUpdateAppBody{ Description: opts.Description, }, }, nil).Return(&secret_service.UpdateAppOK{ - Payload: &models.Secrets20230613UpdateAppResponse{ - App: &models.Secrets20230613App{ + Payload: &models.Secrets20231128UpdateAppResponse{ + App: &models.Secrets20231128App{ Name: opts.AppName, Description: opts.Description, }, diff --git a/internal/commands/vaultsecrets/apps/updates.go b/internal/commands/vaultsecrets/apps/updates.go index 25248b81..75c7be3c 100644 --- a/internal/commands/vaultsecrets/apps/updates.go +++ b/internal/commands/vaultsecrets/apps/updates.go @@ -7,8 +7,9 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" "github.com/hashicorp/hcp/internal/pkg/format" @@ -23,20 +24,18 @@ type UpdateOpts struct { Output *format.Outputter IO iostreams.IOStreams - AppName string - Description string - Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService + AppName string + Description string + Client secret_service.ClientService } func NewCmdUpdate(ctx *cmd.Context, runF func(*UpdateOpts) error) *cmd.Command { opts := &UpdateOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - Client: secret_service.New(ctx.HCP, nil), - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -87,11 +86,11 @@ func NewCmdUpdate(ctx *cmd.Context, runF func(*UpdateOpts) error) *cmd.Command { func updateRun(opts *UpdateOpts) error { _, err := opts.Client.UpdateApp(&secret_service.UpdateAppParams{ - Context: opts.Ctx, - LocationProjectID: opts.Profile.ProjectID, - Name: opts.AppName, - LocationOrganizationID: opts.Profile.OrganizationID, - Body: secret_service.UpdateAppBody{ + Context: opts.Ctx, + ProjectID: opts.Profile.ProjectID, + Name: opts.AppName, + OrganizationID: opts.Profile.OrganizationID, + Body: &models.SecretServiceUpdateAppBody{ Description: opts.Description, }, }, nil) diff --git a/internal/commands/vaultsecrets/gatewaypools/create.go b/internal/commands/vaultsecrets/gatewaypools/create.go index d0e4a8dc..b4e6e41f 100644 --- a/internal/commands/vaultsecrets/gatewaypools/create.go +++ b/internal/commands/vaultsecrets/gatewaypools/create.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/hcl/v2/gohcl" "github.com/hashicorp/hcl/v2/hclwrite" "github.com/hashicorp/hcp-sdk-go/auth" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp-sdk-go/config/files" "github.com/hashicorp/hcp/internal/pkg/cmd" @@ -39,16 +39,16 @@ type CreateOpts struct { Description string OutDirPath string ShowClientSecret bool - PreviewClient preview_secret_service.ClientService + Client secret_service.ClientService } func NewCmdCreate(ctx *cmd.Context, runF func(*CreateOpts) error) *cmd.Command { opts := &CreateOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -160,7 +160,7 @@ func createRun(opts *CreateOpts) error { return fmt.Errorf("failed to create the output directory: %w", err) } } - resp, err := opts.PreviewClient.CreateGatewayPool(&preview_secret_service.CreateGatewayPoolParams{ + resp, err := opts.Client.CreateGatewayPool(&secret_service.CreateGatewayPoolParams{ Context: opts.Ctx, OrganizationID: opts.Profile.OrganizationID, ProjectID: opts.Profile.ProjectID, diff --git a/internal/commands/vaultsecrets/gatewaypools/delete.go b/internal/commands/vaultsecrets/gatewaypools/delete.go index 3b4a8093..c64b365a 100644 --- a/internal/commands/vaultsecrets/gatewaypools/delete.go +++ b/internal/commands/vaultsecrets/gatewaypools/delete.go @@ -7,7 +7,7 @@ import ( "context" "fmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/heredoc" @@ -22,16 +22,16 @@ type DeleteOpts struct { IO iostreams.IOStreams GatewayPoolName string - PreviewClient preview_secret_service.ClientService + Client secret_service.ClientService } func NewCmdDelete(ctx *cmd.Context, runF func(*DeleteOpts) error) *cmd.Command { opts := &DeleteOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -65,13 +65,13 @@ func NewCmdDelete(ctx *cmd.Context, runF func(*DeleteOpts) error) *cmd.Command { return deleteRun(opts) }, } - cmd.Args.Autocomplete = PredictGatewayPoolName(ctx, cmd, preview_secret_service.New(ctx.HCP, nil)) + cmd.Args.Autocomplete = PredictGatewayPoolName(ctx, cmd, secret_service.New(ctx.HCP, nil)) return cmd } func deleteRun(opts *DeleteOpts) error { - _, err := opts.PreviewClient.DeleteGatewayPool(&preview_secret_service.DeleteGatewayPoolParams{ + _, err := opts.Client.DeleteGatewayPool(&secret_service.DeleteGatewayPoolParams{ Context: opts.Ctx, OrganizationID: opts.Profile.OrganizationID, ProjectID: opts.Profile.ProjectID, diff --git a/internal/commands/vaultsecrets/gatewaypools/helper.go b/internal/commands/vaultsecrets/gatewaypools/helper.go index cbb479fc..654181dd 100644 --- a/internal/commands/vaultsecrets/gatewaypools/helper.go +++ b/internal/commands/vaultsecrets/gatewaypools/helper.go @@ -7,14 +7,14 @@ import ( "context" "fmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/posener/complete" ) // PredictGatewayPoolName returns a predict function for gateway pools names. -func PredictGatewayPoolName(ctx *cmd.Context, c *cmd.Command, client preview_secret_service.ClientService) complete.PredictFunc { +func PredictGatewayPoolName(ctx *cmd.Context, c *cmd.Command, client secret_service.ClientService) complete.PredictFunc { return func(args complete.Args) []string { // Parse the args remainingArgs, err := ctx.ParseFlags(c, args.All) @@ -40,8 +40,8 @@ func PredictGatewayPoolName(ctx *cmd.Context, c *cmd.Command, client preview_sec } } -func listGatewayPools(ctx context.Context, orgID, projectID string, client preview_secret_service.ClientService) ([]*preview_models.Secrets20231128GatewayPool, error) { - req := preview_secret_service.NewListGatewayPoolsParamsWithContext(ctx) +func listGatewayPools(ctx context.Context, orgID, projectID string, client secret_service.ClientService) ([]*models.Secrets20231128GatewayPool, error) { + req := secret_service.NewListGatewayPoolsParamsWithContext(ctx) req.OrganizationID = orgID req.ProjectID = projectID diff --git a/internal/commands/vaultsecrets/gatewaypools/list.go b/internal/commands/vaultsecrets/gatewaypools/list.go index ef644bfd..eeaf6cb9 100644 --- a/internal/commands/vaultsecrets/gatewaypools/list.go +++ b/internal/commands/vaultsecrets/gatewaypools/list.go @@ -7,7 +7,7 @@ import ( "context" "fmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/heredoc" @@ -21,16 +21,16 @@ type ListOpts struct { Output *format.Outputter IO iostreams.IOStreams - PreviewClient preview_secret_service.ClientService + Client secret_service.ClientService } func NewCmdList(ctx *cmd.Context, runF func(*ListOpts) error) *cmd.Command { opts := &ListOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -79,13 +79,13 @@ func listFields() []format.Field { } func listRun(opts *ListOpts) error { - params := &preview_secret_service.ListGatewayPoolsParams{ + params := &secret_service.ListGatewayPoolsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, } - resp, err := opts.PreviewClient.ListGatewayPools(params, nil) + resp, err := opts.Client.ListGatewayPools(params, nil) if err != nil { return fmt.Errorf("failed to list gateway pools: %w", err) } diff --git a/internal/commands/vaultsecrets/gatewaypools/list_gateway_pools_gateways.go b/internal/commands/vaultsecrets/gatewaypools/list_gateway_pools_gateways.go index 7233ca36..d6b4c628 100644 --- a/internal/commands/vaultsecrets/gatewaypools/list_gateway_pools_gateways.go +++ b/internal/commands/vaultsecrets/gatewaypools/list_gateway_pools_gateways.go @@ -7,7 +7,7 @@ import ( "context" "fmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" "github.com/hashicorp/hcp/internal/pkg/format" @@ -22,18 +22,18 @@ type ListGatewaysOpts struct { Output *format.Outputter IO iostreams.IOStreams - PreviewClient preview_secret_service.ClientService + Client secret_service.ClientService GatewayPoolName string ShowAll bool } func NewCmdListGatewayPoolsGateway(ctx *cmd.Context, runF func(*ListGatewaysOpts) error) *cmd.Command { opts := &ListGatewaysOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -83,14 +83,14 @@ func NewCmdListGatewayPoolsGateway(ctx *cmd.Context, runF func(*ListGatewaysOpts } func listGatewaysRun(opts *ListGatewaysOpts) error { - params := &preview_secret_service.ListGatewayPoolGatewaysParams{ + params := &secret_service.ListGatewayPoolGatewaysParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, GatewayPoolName: opts.GatewayPoolName, } - resp, err := opts.PreviewClient.ListGatewayPoolGateways(params, nil) + resp, err := opts.Client.ListGatewayPoolGateways(params, nil) if err != nil { return fmt.Errorf("failed to list gateway pools: %w", err) } diff --git a/internal/commands/vaultsecrets/gatewaypools/read.go b/internal/commands/vaultsecrets/gatewaypools/read.go index 746476e5..c9c86733 100644 --- a/internal/commands/vaultsecrets/gatewaypools/read.go +++ b/internal/commands/vaultsecrets/gatewaypools/read.go @@ -7,7 +7,7 @@ import ( "context" "fmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/heredoc" @@ -22,16 +22,16 @@ type ReadOpts struct { IO iostreams.IOStreams GatewayPoolName string - PreviewClient preview_secret_service.ClientService + Client secret_service.ClientService } func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command { opts := &ReadOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -65,7 +65,7 @@ func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command { return readRun(opts) }, } - cmd.Args.Autocomplete = PredictGatewayPoolName(ctx, cmd, preview_secret_service.New(ctx.HCP, nil)) + cmd.Args.Autocomplete = PredictGatewayPoolName(ctx, cmd, secret_service.New(ctx.HCP, nil)) return cmd } @@ -96,7 +96,7 @@ func readFields() []format.Field { } func readRun(opts *ReadOpts) error { - resp, err := opts.PreviewClient.GetGatewayPool(&preview_secret_service.GetGatewayPoolParams{ + resp, err := opts.Client.GetGatewayPool(&secret_service.GetGatewayPoolParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -110,7 +110,7 @@ func readRun(opts *ReadOpts) error { return fmt.Errorf("gateway pool not found") } - integList, err := opts.PreviewClient.ListGatewayPoolIntegrations(&preview_secret_service.ListGatewayPoolIntegrationsParams{ + integList, err := opts.Client.ListGatewayPoolIntegrations(&secret_service.ListGatewayPoolIntegrationsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, diff --git a/internal/commands/vaultsecrets/gatewaypools/update.go b/internal/commands/vaultsecrets/gatewaypools/update.go index 49a7cc12..8d955b8b 100644 --- a/internal/commands/vaultsecrets/gatewaypools/update.go +++ b/internal/commands/vaultsecrets/gatewaypools/update.go @@ -7,7 +7,7 @@ import ( "context" "fmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" @@ -25,16 +25,16 @@ type UpdateOpts struct { GatewayPoolName string Description string - PreviewClient preview_secret_service.ClientService + Client secret_service.ClientService } func NewCmdUpdate(ctx *cmd.Context, runF func(*UpdateOpts) error) *cmd.Command { opts := &UpdateOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -87,7 +87,7 @@ func NewCmdUpdate(ctx *cmd.Context, runF func(*UpdateOpts) error) *cmd.Command { } func updateRun(opts *UpdateOpts) error { - _, err := opts.PreviewClient.UpdateGatewayPool(&preview_secret_service.UpdateGatewayPoolParams{ + _, err := opts.Client.UpdateGatewayPool(&secret_service.UpdateGatewayPoolParams{ Context: opts.Ctx, OrganizationID: opts.Profile.OrganizationID, ProjectID: opts.Profile.ProjectID, diff --git a/internal/commands/vaultsecrets/integrations/create.go b/internal/commands/vaultsecrets/integrations/create.go index 759dd5bf..b89e6f31 100644 --- a/internal/commands/vaultsecrets/integrations/create.go +++ b/internal/commands/vaultsecrets/integrations/create.go @@ -14,9 +14,8 @@ import ( "golang.org/x/exp/maps" "github.com/hashicorp/hcl/v2/hclsimple" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" "github.com/hashicorp/hcp/internal/pkg/format" @@ -33,7 +32,6 @@ type CreateOpts struct { IntegrationName string ConfigFilePath string - PreviewClient preview_secret_service.ClientService Client secret_service.ClientService } @@ -46,8 +44,7 @@ func NewCmdCreate(ctx *cmd.Context, runF func(*CreateOpts) error) *cmd.Command { IO: ctx.IO, Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -162,11 +159,11 @@ func createRun(opts *CreateOpts) error { switch config.Type { case Twilio: - req := preview_secret_service.NewCreateTwilioIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewCreateTwilioIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID - var twilioBody preview_models.SecretServiceCreateTwilioIntegrationBody + var twilioBody models.SecretServiceCreateTwilioIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -179,17 +176,17 @@ func createRun(opts *CreateOpts) error { req.Body = &twilioBody req.Body.Name = opts.IntegrationName - _, err = opts.PreviewClient.CreateTwilioIntegration(req, nil) + _, err = opts.Client.CreateTwilioIntegration(req, nil) if err != nil { return fmt.Errorf("failed to create Twilio integration: %w", err) } case MongoDBAtlas: - req := preview_secret_service.NewCreateMongoDBAtlasIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewCreateMongoDBAtlasIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID - var mongoDBBody preview_models.SecretServiceCreateMongoDBAtlasIntegrationBody + var mongoDBBody models.SecretServiceCreateMongoDBAtlasIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -202,17 +199,17 @@ func createRun(opts *CreateOpts) error { req.Body = &mongoDBBody req.Body.Name = opts.IntegrationName - _, err = opts.PreviewClient.CreateMongoDBAtlasIntegration(req, nil) + _, err = opts.Client.CreateMongoDBAtlasIntegration(req, nil) if err != nil { return fmt.Errorf("failed to create MongoDB Atlas integration: %w", err) } case AWS: - req := preview_secret_service.NewCreateAwsIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewCreateAwsIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID - var awsBody preview_models.SecretServiceCreateAwsIntegrationBody + var awsBody models.SecretServiceCreateAwsIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -225,17 +222,17 @@ func createRun(opts *CreateOpts) error { req.Body = &awsBody req.Body.Name = opts.IntegrationName - _, err = opts.PreviewClient.CreateAwsIntegration(req, nil) + _, err = opts.Client.CreateAwsIntegration(req, nil) if err != nil { return fmt.Errorf("failed to create AWS integration: %w", err) } case GCP: - req := preview_secret_service.NewCreateGcpIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewCreateGcpIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID - var gcpBody preview_models.SecretServiceCreateGcpIntegrationBody + var gcpBody models.SecretServiceCreateGcpIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -248,13 +245,13 @@ func createRun(opts *CreateOpts) error { req.Body = &gcpBody req.Body.Name = opts.IntegrationName - _, err = opts.PreviewClient.CreateGcpIntegration(req, nil) + _, err = opts.Client.CreateGcpIntegration(req, nil) if err != nil { return fmt.Errorf("failed to create GCP integration: %w", err) } case Postgres: - req := preview_secret_service.NewCreatePostgresIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewCreatePostgresIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID @@ -263,7 +260,7 @@ func createRun(opts *CreateOpts) error { return fmt.Errorf("error marshaling details config: %w", err) } - var body preview_models.SecretServiceCreatePostgresIntegrationBody + var body models.SecretServiceCreatePostgresIntegrationBody err = body.UnmarshalBinary(detailBytes) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -272,7 +269,7 @@ func createRun(opts *CreateOpts) error { req.Body = &body req.Body.Name = opts.IntegrationName - _, err = opts.PreviewClient.CreatePostgresIntegration(req, nil) + _, err = opts.Client.CreatePostgresIntegration(req, nil) if err != nil { return fmt.Errorf("failed to create MongoDB Atlas integration: %w", err) } diff --git a/internal/commands/vaultsecrets/integrations/create_test.go b/internal/commands/vaultsecrets/integrations/create_test.go index cbe146c1..90601de0 100644 --- a/internal/commands/vaultsecrets/integrations/create_test.go +++ b/internal/commands/vaultsecrets/integrations/create_test.go @@ -13,9 +13,9 @@ import ( "github.com/go-openapi/runtime/client" "github.com/stretchr/testify/require" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -132,43 +132,43 @@ details = { r.NoError(err) io := iostreams.Test() - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &CreateOpts{ Ctx: context.Background(), Profile: profile.TestProfile(t).SetOrgID("123").SetProjectID("abc"), IO: io, - PreviewClient: vs, + Client: vs, Output: format.New(io), IntegrationName: c.IntegrationName, ConfigFilePath: f.Name(), } if c.Error == "" { - vs.EXPECT().CreateAwsIntegration(&preview_secret_service.CreateAwsIntegrationParams{ + vs.EXPECT().CreateAwsIntegration(&secret_service.CreateAwsIntegrationParams{ Context: opts.Ctx, OrganizationID: "123", ProjectID: "abc", - Body: &preview_models.SecretServiceCreateAwsIntegrationBody{ + Body: &models.SecretServiceCreateAwsIntegrationBody{ Name: opts.IntegrationName, - FederatedWorkloadIdentity: &preview_models.Secrets20231128AwsFederatedWorkloadIdentityRequest{ + FederatedWorkloadIdentity: &models.Secrets20231128AwsFederatedWorkloadIdentityRequest{ Audience: "abc", RoleArn: "def", }, - Capabilities: []*preview_models.Secrets20231128Capability{ - preview_models.Secrets20231128CapabilityDYNAMIC.Pointer(), + Capabilities: []*models.Secrets20231128Capability{ + models.Secrets20231128CapabilityDYNAMIC.Pointer(), }, }, - }, nil).Return(&preview_secret_service.CreateAwsIntegrationOK{ - Payload: &preview_models.Secrets20231128CreateAwsIntegrationResponse{ - Integration: &preview_models.Secrets20231128AwsIntegration{ + }, nil).Return(&secret_service.CreateAwsIntegrationOK{ + Payload: &models.Secrets20231128CreateAwsIntegrationResponse{ + Integration: &models.Secrets20231128AwsIntegration{ Name: opts.IntegrationName, - FederatedWorkloadIdentity: &preview_models.Secrets20231128AwsFederatedWorkloadIdentityResponse{ + FederatedWorkloadIdentity: &models.Secrets20231128AwsFederatedWorkloadIdentityResponse{ Audience: "abc", RoleArn: "def", }, - Capabilities: []*preview_models.Secrets20231128Capability{ - preview_models.Secrets20231128CapabilityDYNAMIC.Pointer(), + Capabilities: []*models.Secrets20231128Capability{ + models.Secrets20231128CapabilityDYNAMIC.Pointer(), }, }, }, diff --git a/internal/commands/vaultsecrets/integrations/delete.go b/internal/commands/vaultsecrets/integrations/delete.go index aa1a2baa..de8616a3 100644 --- a/internal/commands/vaultsecrets/integrations/delete.go +++ b/internal/commands/vaultsecrets/integrations/delete.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" "github.com/hashicorp/hcp/internal/pkg/format" @@ -26,17 +25,15 @@ type DeleteOpts struct { IntegrationName string Type IntegrationType Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService } func NewCmdDelete(ctx *cmd.Context, runF func(*DeleteOpts) error) *cmd.Command { opts := &DeleteOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - Client: secret_service.New(ctx.HCP, nil), - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -89,7 +86,7 @@ func NewCmdDelete(ctx *cmd.Context, runF func(*DeleteOpts) error) *cmd.Command { func deleteRun(opts *DeleteOpts) error { switch opts.Type { case Twilio: - _, err := opts.PreviewClient.DeleteTwilioIntegration(&preview_secret_service.DeleteTwilioIntegrationParams{ + _, err := opts.Client.DeleteTwilioIntegration(&secret_service.DeleteTwilioIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -100,7 +97,7 @@ func deleteRun(opts *DeleteOpts) error { } case MongoDBAtlas: - _, err := opts.PreviewClient.DeleteMongoDBAtlasIntegration(&preview_secret_service.DeleteMongoDBAtlasIntegrationParams{ + _, err := opts.Client.DeleteMongoDBAtlasIntegration(&secret_service.DeleteMongoDBAtlasIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -111,7 +108,7 @@ func deleteRun(opts *DeleteOpts) error { } case AWS: - _, err := opts.PreviewClient.DeleteAwsIntegration(&preview_secret_service.DeleteAwsIntegrationParams{ + _, err := opts.Client.DeleteAwsIntegration(&secret_service.DeleteAwsIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -122,7 +119,7 @@ func deleteRun(opts *DeleteOpts) error { } case GCP: - _, err := opts.PreviewClient.DeleteGcpIntegration(&preview_secret_service.DeleteGcpIntegrationParams{ + _, err := opts.Client.DeleteGcpIntegration(&secret_service.DeleteGcpIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -133,7 +130,7 @@ func deleteRun(opts *DeleteOpts) error { } case Postgres: - _, err := opts.PreviewClient.DeletePostgresIntegration(&preview_secret_service.DeletePostgresIntegrationParams{ + _, err := opts.Client.DeletePostgresIntegration(&secret_service.DeletePostgresIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, diff --git a/internal/commands/vaultsecrets/integrations/delete_test.go b/internal/commands/vaultsecrets/integrations/delete_test.go index 815f68f2..e25a3b1b 100644 --- a/internal/commands/vaultsecrets/integrations/delete_test.go +++ b/internal/commands/vaultsecrets/integrations/delete_test.go @@ -12,8 +12,8 @@ import ( "github.com/go-openapi/runtime/client" "github.com/stretchr/testify/require" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -117,13 +117,13 @@ func TestDeleteRun(t *testing.T) { r := require.New(t) io := iostreams.Test() - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &DeleteOpts{ Ctx: context.Background(), Profile: profile.TestProfile(t).SetOrgID("123").SetProjectID("abc"), IO: io, - PreviewClient: vs, + Client: vs, Output: format.New(io), IntegrationName: c.IntegrationName, Type: c.Type, @@ -132,12 +132,12 @@ func TestDeleteRun(t *testing.T) { if c.ErrMsg != "" { vs.EXPECT().DeleteTwilioIntegration(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - vs.EXPECT().DeleteTwilioIntegration(&preview_secret_service.DeleteTwilioIntegrationParams{ + vs.EXPECT().DeleteTwilioIntegration(&secret_service.DeleteTwilioIntegrationParams{ OrganizationID: "123", ProjectID: "abc", Name: opts.IntegrationName, Context: opts.Ctx, - }, nil).Return(&preview_secret_service.DeleteTwilioIntegrationOK{}, nil).Once() + }, nil).Return(&secret_service.DeleteTwilioIntegrationOK{}, nil).Once() } // Run the command diff --git a/internal/commands/vaultsecrets/integrations/list.go b/internal/commands/vaultsecrets/integrations/list.go index fb09d619..5913d75b 100644 --- a/internal/commands/vaultsecrets/integrations/list.go +++ b/internal/commands/vaultsecrets/integrations/list.go @@ -7,9 +7,8 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" "github.com/hashicorp/hcp/internal/pkg/format" @@ -24,19 +23,17 @@ type ListOpts struct { Output *format.Outputter IO iostreams.IOStreams - Type IntegrationType - Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService + Type IntegrationType + Client secret_service.ClientService } func NewCmdList(ctx *cmd.Context, runF func(*ListOpts) error) *cmd.Command { opts := &ListOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -82,15 +79,15 @@ func NewCmdList(ctx *cmd.Context, runF func(*ListOpts) error) *cmd.Command { func listRun(opts *ListOpts) error { if opts.Type == "" { - var integrations []*preview_models.Secrets20231128Integration - params := &preview_secret_service.ListIntegrationsParams{ + var integrations []*models.Secrets20231128Integration + params := &secret_service.ListIntegrationsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, Capabilities: []string{"ROTATION", "DYNAMIC"}, } for { - resp, err := opts.PreviewClient.ListIntegrations(params, nil) + resp, err := opts.Client.ListIntegrations(params, nil) if err != nil { return fmt.Errorf("failed to list integrations: %w", err) } @@ -109,16 +106,16 @@ func listRun(opts *ListOpts) error { switch opts.Type { case Twilio: - var integrations []*preview_models.Secrets20231128TwilioIntegration + var integrations []*models.Secrets20231128TwilioIntegration - params := &preview_secret_service.ListTwilioIntegrationsParams{ + params := &secret_service.ListTwilioIntegrationsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, } for { - resp, err := opts.PreviewClient.ListTwilioIntegrations(params, nil) + resp, err := opts.Client.ListTwilioIntegrations(params, nil) if err != nil { return fmt.Errorf("failed to list Twilio integrations: %w", err) } @@ -135,16 +132,16 @@ func listRun(opts *ListOpts) error { return opts.Output.Display(newTwilioDisplayer(false, integrations...)) case MongoDBAtlas: - var integrations []*preview_models.Secrets20231128MongoDBAtlasIntegration + var integrations []*models.Secrets20231128MongoDBAtlasIntegration - params := &preview_secret_service.ListMongoDBAtlasIntegrationsParams{ + params := &secret_service.ListMongoDBAtlasIntegrationsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, } for { - resp, err := opts.PreviewClient.ListMongoDBAtlasIntegrations(params, nil) + resp, err := opts.Client.ListMongoDBAtlasIntegrations(params, nil) if err != nil { return fmt.Errorf("failed to list MongoDB Atlas integrations: %w", err) } @@ -161,16 +158,16 @@ func listRun(opts *ListOpts) error { return opts.Output.Display(newMongoDBDisplayer(false, integrations...)) case AWS: - var integrations []*preview_models.Secrets20231128AwsIntegration + var integrations []*models.Secrets20231128AwsIntegration - params := &preview_secret_service.ListAwsIntegrationsParams{ + params := &secret_service.ListAwsIntegrationsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, } for { - resp, err := opts.PreviewClient.ListAwsIntegrations(params, nil) + resp, err := opts.Client.ListAwsIntegrations(params, nil) if err != nil { return fmt.Errorf("failed to list AWS integrations: %w", err) } @@ -187,16 +184,16 @@ func listRun(opts *ListOpts) error { return opts.Output.Display(newAwsDisplayer(false, false, integrations...)) case GCP: - var integrations []*preview_models.Secrets20231128GcpIntegration + var integrations []*models.Secrets20231128GcpIntegration - params := &preview_secret_service.ListGcpIntegrationsParams{ + params := &secret_service.ListGcpIntegrationsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, } for { - resp, err := opts.PreviewClient.ListGcpIntegrations(params, nil) + resp, err := opts.Client.ListGcpIntegrations(params, nil) if err != nil { return fmt.Errorf("failed to list GCP integrations: %w", err) } @@ -213,16 +210,16 @@ func listRun(opts *ListOpts) error { return opts.Output.Display(newGcpDisplayer(false, false, integrations...)) case Postgres: - var integrations []*preview_models.Secrets20231128PostgresIntegration + var integrations []*models.Secrets20231128PostgresIntegration - params := &preview_secret_service.ListPostgresIntegrationsParams{ + params := &secret_service.ListPostgresIntegrationsParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, } for { - resp, err := opts.PreviewClient.ListPostgresIntegrations(params, nil) + resp, err := opts.Client.ListPostgresIntegrations(params, nil) if err != nil { return fmt.Errorf("failed to list Postgres integrations: %w", err) } diff --git a/internal/commands/vaultsecrets/integrations/list_test.go b/internal/commands/vaultsecrets/integrations/list_test.go index 83508a3f..6e33a37c 100644 --- a/internal/commands/vaultsecrets/integrations/list_test.go +++ b/internal/commands/vaultsecrets/integrations/list_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -106,41 +106,41 @@ func TestListRun(t *testing.T) { io := iostreams.Test() io.ErrorTTY = true - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &ListOpts{ - Ctx: context.Background(), - IO: io, - Profile: profile.TestProfile(t).SetOrgID("123").SetProjectID("abc"), - Output: format.New(io), - PreviewClient: vs, - Type: "twilio", + Ctx: context.Background(), + IO: io, + Profile: profile.TestProfile(t).SetOrgID("123").SetProjectID("abc"), + Output: format.New(io), + Client: vs, + Type: "twilio", } if c.RespErr { vs.EXPECT().ListTwilioIntegrations(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { paginationNextPageToken := "token" - vs.EXPECT().ListTwilioIntegrations(&preview_secret_service.ListTwilioIntegrationsParams{ + vs.EXPECT().ListTwilioIntegrations(&secret_service.ListTwilioIntegrationsParams{ OrganizationID: "123", ProjectID: "abc", Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.ListTwilioIntegrationsOK{ - Payload: &preview_models.Secrets20231128ListTwilioIntegrationsResponse{ + }, mock.Anything).Return(&secret_service.ListTwilioIntegrationsOK{ + Payload: &models.Secrets20231128ListTwilioIntegrationsResponse{ Integrations: getIntegrations(0, 10), - Pagination: &preview_models.CommonPaginationResponse{ + Pagination: &models.CommonPaginationResponse{ NextPageToken: paginationNextPageToken, }, }, }, nil).Once() - vs.EXPECT().ListTwilioIntegrations(&preview_secret_service.ListTwilioIntegrationsParams{ + vs.EXPECT().ListTwilioIntegrations(&secret_service.ListTwilioIntegrationsParams{ OrganizationID: "123", ProjectID: "abc", Context: opts.Ctx, PaginationNextPageToken: &paginationNextPageToken, - }, mock.Anything).Return(&preview_secret_service.ListTwilioIntegrationsOK{ - Payload: &preview_models.Secrets20231128ListTwilioIntegrationsResponse{ + }, mock.Anything).Return(&secret_service.ListTwilioIntegrationsOK{ + Payload: &models.Secrets20231128ListTwilioIntegrationsResponse{ Integrations: getIntegrations(10, 5), }, }, nil).Once() @@ -159,10 +159,10 @@ func TestListRun(t *testing.T) { } } -func getIntegrations(start, limit int) []*preview_models.Secrets20231128TwilioIntegration { - var secrets []*preview_models.Secrets20231128TwilioIntegration +func getIntegrations(start, limit int) []*models.Secrets20231128TwilioIntegration { + var secrets []*models.Secrets20231128TwilioIntegration for i := start; i < (start + limit); i++ { - secrets = append(secrets, &preview_models.Secrets20231128TwilioIntegration{ + secrets = append(secrets, &models.Secrets20231128TwilioIntegration{ Name: fmt.Sprint("test_app_", i), }) } diff --git a/internal/commands/vaultsecrets/integrations/read.go b/internal/commands/vaultsecrets/integrations/read.go index 031105ff..07e9c1ad 100644 --- a/internal/commands/vaultsecrets/integrations/read.go +++ b/internal/commands/vaultsecrets/integrations/read.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" "github.com/hashicorp/hcp/internal/pkg/format" @@ -26,17 +25,15 @@ type ReadOpts struct { IntegrationName string Type IntegrationType Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService } func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command { opts := &ReadOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - Output: ctx.Output, - IO: ctx.IO, - Client: secret_service.New(ctx.HCP, nil), - PreviewClient: preview_secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + Output: ctx.Output, + IO: ctx.IO, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -87,7 +84,7 @@ func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command { func readRun(opts *ReadOpts) error { switch opts.Type { case "": - resp, err := opts.PreviewClient.GetIntegration(&preview_secret_service.GetIntegrationParams{ + resp, err := opts.Client.GetIntegration(&secret_service.GetIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -100,7 +97,7 @@ func readRun(opts *ReadOpts) error { return opts.Output.Display(newGenericDisplayer(true, resp.Payload.Integration)) case Twilio: - resp, err := opts.PreviewClient.GetTwilioIntegration(&preview_secret_service.GetTwilioIntegrationParams{ + resp, err := opts.Client.GetTwilioIntegration(&secret_service.GetTwilioIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -113,7 +110,7 @@ func readRun(opts *ReadOpts) error { return opts.Output.Display(newTwilioDisplayer(true, resp.Payload.Integration)) case MongoDBAtlas: - resp, err := opts.PreviewClient.GetMongoDBAtlasIntegration(&preview_secret_service.GetMongoDBAtlasIntegrationParams{ + resp, err := opts.Client.GetMongoDBAtlasIntegration(&secret_service.GetMongoDBAtlasIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -126,7 +123,7 @@ func readRun(opts *ReadOpts) error { return opts.Output.Display(newMongoDBDisplayer(true, resp.Payload.Integration)) case AWS: - resp, err := opts.PreviewClient.GetAwsIntegration(&preview_secret_service.GetAwsIntegrationParams{ + resp, err := opts.Client.GetAwsIntegration(&secret_service.GetAwsIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -139,7 +136,7 @@ func readRun(opts *ReadOpts) error { return opts.Output.Display(newAwsDisplayer(true, resp.Payload.Integration.FederatedWorkloadIdentity != nil, resp.Payload.Integration)) case GCP: - resp, err := opts.PreviewClient.GetGcpIntegration(&preview_secret_service.GetGcpIntegrationParams{ + resp, err := opts.Client.GetGcpIntegration(&secret_service.GetGcpIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, @@ -152,7 +149,7 @@ func readRun(opts *ReadOpts) error { return opts.Output.Display(newGcpDisplayer(true, resp.Payload.Integration.FederatedWorkloadIdentity != nil, resp.Payload.Integration)) case Postgres: - resp, err := opts.PreviewClient.GetPostgresIntegration(&preview_secret_service.GetPostgresIntegrationParams{ + resp, err := opts.Client.GetPostgresIntegration(&secret_service.GetPostgresIntegrationParams{ Context: opts.Ctx, ProjectID: opts.Profile.ProjectID, OrganizationID: opts.Profile.OrganizationID, diff --git a/internal/commands/vaultsecrets/integrations/read_test.go b/internal/commands/vaultsecrets/integrations/read_test.go index b0ce5100..c116090f 100644 --- a/internal/commands/vaultsecrets/integrations/read_test.go +++ b/internal/commands/vaultsecrets/integrations/read_test.go @@ -12,9 +12,9 @@ import ( "github.com/go-openapi/runtime/client" "github.com/stretchr/testify/require" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -111,13 +111,13 @@ func TestReadRun(t *testing.T) { r := require.New(t) io := iostreams.Test() - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &ReadOpts{ Ctx: context.Background(), Profile: profile.TestProfile(t).SetOrgID("123").SetProjectID("abc"), IO: io, - PreviewClient: vs, + Client: vs, Output: format.New(io), IntegrationName: c.IntegrationName, Type: c.Type, @@ -126,16 +126,16 @@ func TestReadRun(t *testing.T) { if c.ErrMsg != "" { vs.EXPECT().GetTwilioIntegration(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - vs.EXPECT().GetTwilioIntegration(&preview_secret_service.GetTwilioIntegrationParams{ + vs.EXPECT().GetTwilioIntegration(&secret_service.GetTwilioIntegrationParams{ OrganizationID: "123", ProjectID: "abc", Name: opts.IntegrationName, Context: opts.Ctx, - }, nil).Return(&preview_secret_service.GetTwilioIntegrationOK{ - Payload: &preview_models.Secrets20231128GetTwilioIntegrationResponse{ - Integration: &preview_models.Secrets20231128TwilioIntegration{ + }, nil).Return(&secret_service.GetTwilioIntegrationOK{ + Payload: &models.Secrets20231128GetTwilioIntegrationResponse{ + Integration: &models.Secrets20231128TwilioIntegration{ Name: opts.IntegrationName, - StaticCredentialDetails: &preview_models.Secrets20231128TwilioStaticCredentialsResponse{ + StaticCredentialDetails: &models.Secrets20231128TwilioStaticCredentialsResponse{ AccountSid: "account_sid", APIKeySid: "api_key_sid", }, diff --git a/internal/commands/vaultsecrets/integrations/update.go b/internal/commands/vaultsecrets/integrations/update.go index a0482a4a..fa43de4e 100644 --- a/internal/commands/vaultsecrets/integrations/update.go +++ b/internal/commands/vaultsecrets/integrations/update.go @@ -9,13 +9,12 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hclsimple" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/flagvalue" "github.com/hashicorp/hcp/internal/pkg/heredoc" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" "github.com/hashicorp/hcp/internal/pkg/profile" @@ -29,7 +28,6 @@ type UpdateOpts struct { IntegrationName string ConfigFilePath string - PreviewClient preview_secret_service.ClientService Client secret_service.ClientService } @@ -40,8 +38,7 @@ func NewCmdUpdate(ctx *cmd.Context, runF func(*UpdateOpts) error) *cmd.Command { IO: ctx.IO, Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -111,12 +108,12 @@ func updateRun(opts *UpdateOpts) error { switch config.Type { case Twilio: - req := preview_secret_service.NewUpdateTwilioIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateTwilioIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.Name = opts.IntegrationName - var twilioBody preview_models.SecretServiceUpdateTwilioIntegrationBody + var twilioBody models.SecretServiceUpdateTwilioIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -128,18 +125,18 @@ func updateRun(opts *UpdateOpts) error { } req.Body = &twilioBody - _, err = opts.PreviewClient.UpdateTwilioIntegration(req, nil) + _, err = opts.Client.UpdateTwilioIntegration(req, nil) if err != nil { return fmt.Errorf("failed to update Twilio integration: %w", err) } case MongoDBAtlas: - req := preview_secret_service.NewUpdateMongoDBAtlasIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateMongoDBAtlasIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.Name = opts.IntegrationName - var mongoDBBody preview_models.SecretServiceUpdateMongoDBAtlasIntegrationBody + var mongoDBBody models.SecretServiceUpdateMongoDBAtlasIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -151,18 +148,18 @@ func updateRun(opts *UpdateOpts) error { } req.Body = &mongoDBBody - _, err = opts.PreviewClient.UpdateMongoDBAtlasIntegration(req, nil) + _, err = opts.Client.UpdateMongoDBAtlasIntegration(req, nil) if err != nil { return fmt.Errorf("failed to update MongoDB Atlas integration: %w", err) } case AWS: - req := preview_secret_service.NewUpdateAwsIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateAwsIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.Name = opts.IntegrationName - var awsBody preview_models.SecretServiceUpdateAwsIntegrationBody + var awsBody models.SecretServiceUpdateAwsIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -174,18 +171,18 @@ func updateRun(opts *UpdateOpts) error { } req.Body = &awsBody - _, err = opts.PreviewClient.UpdateAwsIntegration(req, nil) + _, err = opts.Client.UpdateAwsIntegration(req, nil) if err != nil { return fmt.Errorf("failed to update AWS integration: %w", err) } case GCP: - req := preview_secret_service.NewUpdateGcpIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateGcpIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.Name = opts.IntegrationName - var gcpBody preview_models.SecretServiceUpdateGcpIntegrationBody + var gcpBody models.SecretServiceUpdateGcpIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -197,18 +194,18 @@ func updateRun(opts *UpdateOpts) error { } req.Body = &gcpBody - _, err = opts.PreviewClient.UpdateGcpIntegration(req, nil) + _, err = opts.Client.UpdateGcpIntegration(req, nil) if err != nil { return fmt.Errorf("failed to update GCP integration: %w", err) } case Postgres: - req := preview_secret_service.NewUpdatePostgresIntegrationParamsWithContext(opts.Ctx) + req := secret_service.NewUpdatePostgresIntegrationParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.Name = opts.IntegrationName - var body preview_models.SecretServiceUpdatePostgresIntegrationBody + var body models.SecretServiceUpdatePostgresIntegrationBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -220,7 +217,7 @@ func updateRun(opts *UpdateOpts) error { } req.Body = &body - _, err = opts.PreviewClient.UpdatePostgresIntegration(req, nil) + _, err = opts.Client.UpdatePostgresIntegration(req, nil) if err != nil { return fmt.Errorf("failed to update MongoDB Atlas integration: %w", err) } diff --git a/internal/commands/vaultsecrets/integrations/update_test.go b/internal/commands/vaultsecrets/integrations/update_test.go index 454c9fb5..40a4f532 100644 --- a/internal/commands/vaultsecrets/integrations/update_test.go +++ b/internal/commands/vaultsecrets/integrations/update_test.go @@ -13,9 +13,9 @@ import ( "github.com/go-openapi/runtime/client" "github.com/stretchr/testify/require" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -138,45 +138,45 @@ details = { r.NoError(err) io := iostreams.Test() - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &UpdateOpts{ Ctx: context.Background(), Profile: profile.TestProfile(t).SetOrgID("123").SetProjectID("abc"), IO: io, - PreviewClient: vs, + Client: vs, Output: format.New(io), IntegrationName: c.IntegrationName, ConfigFilePath: f.Name(), } if c.Error == "" { - vs.EXPECT().UpdateAwsIntegration(&preview_secret_service.UpdateAwsIntegrationParams{ + vs.EXPECT().UpdateAwsIntegration(&secret_service.UpdateAwsIntegrationParams{ Context: opts.Ctx, OrganizationID: "123", ProjectID: "abc", Name: opts.IntegrationName, - Body: &preview_models.SecretServiceUpdateAwsIntegrationBody{ - FederatedWorkloadIdentity: &preview_models.Secrets20231128AwsFederatedWorkloadIdentityRequest{ + Body: &models.SecretServiceUpdateAwsIntegrationBody{ + FederatedWorkloadIdentity: &models.Secrets20231128AwsFederatedWorkloadIdentityRequest{ Audience: "abc", RoleArn: "def", }, - Capabilities: []*preview_models.Secrets20231128Capability{ - preview_models.Secrets20231128CapabilityROTATION.Pointer(), - preview_models.Secrets20231128CapabilityDYNAMIC.Pointer(), + Capabilities: []*models.Secrets20231128Capability{ + models.Secrets20231128CapabilityROTATION.Pointer(), + models.Secrets20231128CapabilityDYNAMIC.Pointer(), }, }, - }, nil).Return(&preview_secret_service.UpdateAwsIntegrationOK{ - Payload: &preview_models.Secrets20231128UpdateAwsIntegrationResponse{ - Integration: &preview_models.Secrets20231128AwsIntegration{ + }, nil).Return(&secret_service.UpdateAwsIntegrationOK{ + Payload: &models.Secrets20231128UpdateAwsIntegrationResponse{ + Integration: &models.Secrets20231128AwsIntegration{ Name: opts.IntegrationName, - FederatedWorkloadIdentity: &preview_models.Secrets20231128AwsFederatedWorkloadIdentityResponse{ + FederatedWorkloadIdentity: &models.Secrets20231128AwsFederatedWorkloadIdentityResponse{ Audience: "abc", RoleArn: "def", }, - Capabilities: []*preview_models.Secrets20231128Capability{ - preview_models.Secrets20231128CapabilityROTATION.Pointer(), - preview_models.Secrets20231128CapabilityDYNAMIC.Pointer(), + Capabilities: []*models.Secrets20231128Capability{ + models.Secrets20231128CapabilityROTATION.Pointer(), + models.Secrets20231128CapabilityDYNAMIC.Pointer(), }, }, }, diff --git a/internal/commands/vaultsecrets/run/run.go b/internal/commands/vaultsecrets/run/run.go index 939bfa80..c862c702 100644 --- a/internal/commands/vaultsecrets/run/run.go +++ b/internal/commands/vaultsecrets/run/run.go @@ -12,8 +12,7 @@ import ( "strings" "github.com/hashicorp/go-hclog" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/apps/helper" @@ -32,20 +31,18 @@ type RunOpts struct { Output *format.Outputter Logger hclog.Logger - AppName string - Command []string - PreviewClient preview_secret_service.ClientService - Client secret_service.ClientService + AppName string + Command []string + Client secret_service.ClientService } func NewCmdRun(ctx *cmd.Context, runF func(*RunOpts) error) *cmd.Command { opts := &RunOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -105,7 +102,7 @@ func NewCmdRun(ctx *cmd.Context, runF func(*RunOpts) error) *cmd.Command { } for _, f := range cmd.Flags.Local { if f.Name == "app" { - f.Autocomplete = helper.PredictAppName(ctx, cmd, opts.PreviewClient) + f.Autocomplete = helper.PredictAppName(ctx, cmd, opts.Client) } } @@ -221,14 +218,14 @@ func setupChildProcess(ctx context.Context, command []string, envVars []string) } func fetchPaginatedSecrets(opts *RunOpts) ([]*models.Secrets20231128OpenSecret, error) { - params := preview_secret_service.NewOpenAppSecretsParamsWithContext(opts.Ctx) + params := secret_service.NewOpenAppSecretsParamsWithContext(opts.Ctx) params.OrganizationID = opts.Profile.OrganizationID params.ProjectID = opts.Profile.ProjectID params.AppName = opts.AppName var secrets []*models.Secrets20231128OpenSecret for { - resp, err := opts.PreviewClient.OpenAppSecrets(params, nil) + resp, err := opts.Client.OpenAppSecrets(params, nil) if err != nil { return nil, fmt.Errorf("failed to open app secrets: %w", err) } diff --git a/internal/commands/vaultsecrets/run/run_test.go b/internal/commands/vaultsecrets/run/run_test.go index 1f0c9003..dd8ad01d 100644 --- a/internal/commands/vaultsecrets/run/run_test.go +++ b/internal/commands/vaultsecrets/run/run_test.go @@ -15,10 +15,10 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -100,7 +100,7 @@ func TestRunRun(t *testing.T) { cases := []struct { Name string - Secrets []*preview_models.Secrets20231128OpenSecret + Secrets []*models.Secrets20231128OpenSecret RespErr bool ErrMsg string IOErrorContains string @@ -115,20 +115,20 @@ func TestRunRun(t *testing.T) { { Name: "Success", RespErr: false, - Secrets: []*preview_models.Secrets20231128OpenSecret{ + Secrets: []*models.Secrets20231128OpenSecret{ { Name: "static", - StaticVersion: &preview_models.Secrets20231128OpenSecretStaticVersion{}, + StaticVersion: &models.Secrets20231128OpenSecretStaticVersion{}, }, { Name: "rotating", - RotatingVersion: &preview_models.Secrets20231128OpenSecretRotatingVersion{ + RotatingVersion: &models.Secrets20231128OpenSecretRotatingVersion{ Values: map[string]string{"sub_key": "value"}, }, }, { Name: "dynamic", - DynamicInstance: &preview_models.Secrets20231128OpenSecretDynamicInstance{ + DynamicInstance: &models.Secrets20231128OpenSecretDynamicInstance{ Values: map[string]string{"sub_key": "value"}, }, }, @@ -139,20 +139,20 @@ func TestRunRun(t *testing.T) { RespErr: false, ErrMsg: "multiple secrets map to the same environment variable", IOErrorContains: "ERROR: \"static_collision\" [static], \"static\" [rotating] map to the same environment variable \"STATIC_COLLISION\"", - Secrets: []*preview_models.Secrets20231128OpenSecret{ + Secrets: []*models.Secrets20231128OpenSecret{ { Name: "static_collision", Type: "static", LatestVersion: 1, CreatedAt: strfmt.DateTime(time.Now()), - StaticVersion: &preview_models.Secrets20231128OpenSecretStaticVersion{}, + StaticVersion: &models.Secrets20231128OpenSecretStaticVersion{}, }, { Name: "static", Type: "rotating", LatestVersion: 1, CreatedAt: strfmt.DateTime(time.Now()), - RotatingVersion: &preview_models.Secrets20231128OpenSecretRotatingVersion{ + RotatingVersion: &models.Secrets20231128OpenSecretRotatingVersion{ Values: map[string]string{"collision": ""}, }, }, @@ -162,22 +162,22 @@ func TestRunRun(t *testing.T) { Name: "Paginated", PaginatedResp: true, RespErr: false, - Secrets: []*preview_models.Secrets20231128OpenSecret{ + Secrets: []*models.Secrets20231128OpenSecret{ { Name: "static_1", - StaticVersion: &preview_models.Secrets20231128OpenSecretStaticVersion{}, + StaticVersion: &models.Secrets20231128OpenSecretStaticVersion{}, }, { Name: "static_2", - StaticVersion: &preview_models.Secrets20231128OpenSecretStaticVersion{}, + StaticVersion: &models.Secrets20231128OpenSecretStaticVersion{}, }, { Name: "static_3", - StaticVersion: &preview_models.Secrets20231128OpenSecretStaticVersion{}, + StaticVersion: &models.Secrets20231128OpenSecretStaticVersion{}, }, { Name: "static_4", - StaticVersion: &preview_models.Secrets20231128OpenSecretStaticVersion{}, + StaticVersion: &models.Secrets20231128OpenSecretStaticVersion{}, }, }, }, @@ -191,15 +191,15 @@ func TestRunRun(t *testing.T) { io := iostreams.Test() io.ErrorTTY = true - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &RunOpts{ - Ctx: context.Background(), - IO: io, - Profile: testProfile(t), - Output: format.New(io), - PreviewClient: vs, - AppName: testProfile(t).VaultSecrets.AppName, - Command: []string{"echo \"Testing\""}, + Ctx: context.Background(), + IO: io, + Profile: testProfile(t), + Output: format.New(io), + Client: vs, + AppName: testProfile(t).VaultSecrets.AppName, + Command: []string{"echo \"Testing\""}, } if c.RespErr { @@ -209,15 +209,15 @@ func TestRunRun(t *testing.T) { // expect first request to be missing the page token // provide half the secrets and a NextPageToken - vs.EXPECT().OpenAppSecrets(&preview_secret_service.OpenAppSecretsParams{ + vs.EXPECT().OpenAppSecrets(&secret_service.OpenAppSecretsParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.OpenAppSecretsOK{ - Payload: &preview_models.Secrets20231128OpenAppSecretsResponse{ + }, mock.Anything).Return(&secret_service.OpenAppSecretsOK{ + Payload: &models.Secrets20231128OpenAppSecretsResponse{ Secrets: c.Secrets[:len(c.Secrets)/2], - Pagination: &preview_models.CommonPaginationResponse{ + Pagination: &models.CommonPaginationResponse{ NextPageToken: paginationNextPageToken, }, }, @@ -225,25 +225,25 @@ func TestRunRun(t *testing.T) { // expect second request to have a page token // provide later half of the secrets - vs.EXPECT().OpenAppSecrets(&preview_secret_service.OpenAppSecretsParams{ + vs.EXPECT().OpenAppSecrets(&secret_service.OpenAppSecretsParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Context: opts.Ctx, PaginationNextPageToken: &paginationNextPageToken, - }, mock.Anything).Return(&preview_secret_service.OpenAppSecretsOK{ - Payload: &preview_models.Secrets20231128OpenAppSecretsResponse{ + }, mock.Anything).Return(&secret_service.OpenAppSecretsOK{ + Payload: &models.Secrets20231128OpenAppSecretsResponse{ Secrets: c.Secrets[len(c.Secrets)/2:], }, }, nil).Once() } else { - vs.EXPECT().OpenAppSecrets(&preview_secret_service.OpenAppSecretsParams{ + vs.EXPECT().OpenAppSecrets(&secret_service.OpenAppSecretsParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Context: opts.Ctx, - }, nil).Return(&preview_secret_service.OpenAppSecretsOK{ - Payload: &preview_models.Secrets20231128OpenAppSecretsResponse{ + }, nil).Return(&secret_service.OpenAppSecretsOK{ + Payload: &models.Secrets20231128OpenAppSecretsResponse{ Secrets: c.Secrets, }, }, nil).Once() diff --git a/internal/commands/vaultsecrets/secrets/create.go b/internal/commands/vaultsecrets/secrets/create.go index a6ceedf7..7a8175fe 100644 --- a/internal/commands/vaultsecrets/secrets/create.go +++ b/internal/commands/vaultsecrets/secrets/create.go @@ -19,9 +19,8 @@ import ( "golang.org/x/exp/maps" "github.com/hashicorp/hcl/v2/hclsimple" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/integrations" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/pkg/cmd" @@ -34,12 +33,11 @@ import ( func NewCmdCreate(ctx *cmd.Context, runF func(*CreateOpts) error) *cmd.Command { opts := &CreateOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -130,7 +128,6 @@ type CreateOpts struct { SecretValuePlaintext string SecretFilePath string Type string - PreviewClient preview_secret_service.ClientService Client secret_service.ClientService } @@ -221,11 +218,11 @@ func createRun(opts *CreateOpts) error { } req := secret_service.NewCreateAppKVSecretParamsWithContext(opts.Ctx) - req.LocationOrganizationID = opts.Profile.OrganizationID - req.LocationProjectID = opts.Profile.ProjectID + req.OrganizationID = opts.Profile.OrganizationID + req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName - req.Body = secret_service.CreateAppKVSecretBody{ + req.Body = &models.SecretServiceCreateAppKVSecretBody{ Name: opts.SecretName, Value: opts.SecretValuePlaintext, } @@ -265,12 +262,12 @@ func createRun(opts *CreateOpts) error { switch config.Type { case integrations.Twilio: - req := preview_secret_service.NewCreateTwilioRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewCreateTwilioRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName - var twilioBody preview_models.SecretServiceCreateTwilioRotatingSecretBody + var twilioBody models.SecretServiceCreateTwilioRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -284,7 +281,7 @@ func createRun(opts *CreateOpts) error { twilioBody.Name = opts.SecretName req.Body = &twilioBody - resp, err := opts.PreviewClient.CreateTwilioRotatingSecret(req, nil) + resp, err := opts.Client.CreateTwilioRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to create secret with name %q: %w", opts.SecretName, err) } @@ -295,12 +292,12 @@ func createRun(opts *CreateOpts) error { case integrations.MongoDBAtlas: - req := preview_secret_service.NewCreateMongoDBAtlasRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewCreateMongoDBAtlasRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName - var mongoDBBody preview_models.SecretServiceCreateMongoDBAtlasRotatingSecretBody + var mongoDBBody models.SecretServiceCreateMongoDBAtlasRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -314,7 +311,7 @@ func createRun(opts *CreateOpts) error { mongoDBBody.Name = opts.SecretName req.Body = &mongoDBBody - resp, err := opts.PreviewClient.CreateMongoDBAtlasRotatingSecret(req, nil) + resp, err := opts.Client.CreateMongoDBAtlasRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to create secret with name %q: %w", opts.SecretName, err) } @@ -324,12 +321,12 @@ func createRun(opts *CreateOpts) error { } case integrations.AWS: - req := preview_secret_service.NewCreateAwsIAMUserAccessKeyRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewCreateAwsIAMUserAccessKeyRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName - var awsBody preview_models.SecretServiceCreateAwsIAMUserAccessKeyRotatingSecretBody + var awsBody models.SecretServiceCreateAwsIAMUserAccessKeyRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -343,18 +340,18 @@ func createRun(opts *CreateOpts) error { awsBody.Name = opts.SecretName req.Body = &awsBody - _, err = opts.PreviewClient.CreateAwsIAMUserAccessKeyRotatingSecret(req, nil) + _, err = opts.Client.CreateAwsIAMUserAccessKeyRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to create secret with name %q: %w", opts.SecretName, err) } case integrations.GCP: - req := preview_secret_service.NewCreateGcpServiceAccountKeyRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewCreateGcpServiceAccountKeyRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName - var gcpBody preview_models.SecretServiceCreateGcpServiceAccountKeyRotatingSecretBody + var gcpBody models.SecretServiceCreateGcpServiceAccountKeyRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -368,18 +365,18 @@ func createRun(opts *CreateOpts) error { gcpBody.Name = opts.SecretName req.Body = &gcpBody - _, err = opts.PreviewClient.CreateGcpServiceAccountKeyRotatingSecret(req, nil) + _, err = opts.Client.CreateGcpServiceAccountKeyRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to create secret with name %q: %w", opts.SecretName, err) } case integrations.Postgres: - req := preview_secret_service.NewCreatePostgresRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewCreatePostgresRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName - var postgresBody preview_models.SecretServiceCreatePostgresRotatingSecretBody + var postgresBody models.SecretServiceCreatePostgresRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -393,7 +390,7 @@ func createRun(opts *CreateOpts) error { postgresBody.Name = opts.SecretName req.Body = &postgresBody - _, err = opts.PreviewClient.CreatePostgresRotatingSecret(req, nil) + _, err = opts.Client.CreatePostgresRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to create secret with name %q: %w", opts.SecretName, err) } @@ -429,12 +426,12 @@ func createRun(opts *CreateOpts) error { switch config.Type { case integrations.AWS: - req := preview_secret_service.NewCreateAwsDynamicSecretParamsWithContext(opts.Ctx) + req := secret_service.NewCreateAwsDynamicSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName - var awsBody preview_models.SecretServiceCreateAwsDynamicSecretBody + var awsBody models.SecretServiceCreateAwsDynamicSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -448,18 +445,18 @@ func createRun(opts *CreateOpts) error { awsBody.Name = opts.SecretName req.Body = &awsBody - _, err = opts.PreviewClient.CreateAwsDynamicSecret(req, nil) + _, err = opts.Client.CreateAwsDynamicSecret(req, nil) if err != nil { return fmt.Errorf("failed to create secret with name %q: %w", opts.SecretName, err) } case integrations.GCP: - req := preview_secret_service.NewCreateGcpDynamicSecretParamsWithContext(opts.Ctx) + req := secret_service.NewCreateGcpDynamicSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName - var gcpBody preview_models.SecretServiceCreateGcpDynamicSecretBody + var gcpBody models.SecretServiceCreateGcpDynamicSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -473,7 +470,7 @@ func createRun(opts *CreateOpts) error { gcpBody.Name = opts.SecretName req.Body = &gcpBody - _, err = opts.PreviewClient.CreateGcpDynamicSecret(req, nil) + _, err = opts.Client.CreateGcpDynamicSecret(req, nil) if err != nil { return fmt.Errorf("failed to create secret with name %q: %w", opts.SecretName, err) } diff --git a/internal/commands/vaultsecrets/secrets/create_test.go b/internal/commands/vaultsecrets/secrets/create_test.go index 770dd0d0..ebd614e1 100644 --- a/internal/commands/vaultsecrets/secrets/create_test.go +++ b/internal/commands/vaultsecrets/secrets/create_test.go @@ -18,12 +18,9 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/models" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -272,17 +269,15 @@ details = { } } vs := mock_secret_service.NewMockClientService(t) - pvs := mock_preview_secret_service.NewMockClientService(t) opts := &CreateOpts{ - Ctx: context.Background(), - IO: io, - Profile: testProfile(t), - Output: format.New(io), - Client: vs, - PreviewClient: pvs, - AppName: testProfile(t).VaultSecrets.AppName, - SecretName: "test_secret", + Ctx: context.Background(), + IO: io, + Profile: testProfile(t), + Output: format.New(io), + Client: vs, + AppName: testProfile(t).VaultSecrets.AppName, + SecretName: "test_secret", } if c.AugmentOpts != nil { @@ -305,25 +300,24 @@ details = { vs.EXPECT().CreateAppKVSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { vs.EXPECT().CreateAppKVSecret(&secret_service.CreateAppKVSecretParams{ - LocationOrganizationID: testProfile(t).OrganizationID, - LocationProjectID: testProfile(t).ProjectID, - AppName: testProfile(t).VaultSecrets.AppName, - Body: secret_service.CreateAppKVSecretBody{ + OrganizationID: testProfile(t).OrganizationID, + ProjectID: testProfile(t).ProjectID, + AppName: testProfile(t).VaultSecrets.AppName, + Body: &models.SecretServiceCreateAppKVSecretBody{ Name: opts.SecretName, Value: testSecretValue, }, Context: opts.Ctx, }, mock.Anything).Return(&secret_service.CreateAppKVSecretOK{ - Payload: &models.Secrets20230613CreateAppKVSecretResponse{ - Secret: &models.Secrets20230613Secret{ + Payload: &models.Secrets20231128CreateAppKVSecretResponse{ + Secret: &models.Secrets20231128Secret{ Name: opts.SecretName, CreatedAt: dt, - Version: &models.Secrets20230613SecretVersion{ - Version: "2", + StaticVersion: &models.Secrets20231128SecretStaticVersion{ + Version: 2, CreatedAt: dt, - Type: "kv", }, - LatestVersion: "2", + LatestVersion: 2, }, }, }, nil).Once() @@ -334,19 +328,19 @@ details = { switch c.Provider { case integrations.MongoDBAtlas: if c.RespErr { - pvs.EXPECT().CreateMongoDBAtlasRotatingSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() + vs.EXPECT().CreateMongoDBAtlasRotatingSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - pvs.EXPECT().CreateMongoDBAtlasRotatingSecret(&preview_secret_service.CreateMongoDBAtlasRotatingSecretParams{ + vs.EXPECT().CreateMongoDBAtlasRotatingSecret(&secret_service.CreateMongoDBAtlasRotatingSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, - Body: &preview_models.SecretServiceCreateMongoDBAtlasRotatingSecretBody{ + Body: &models.SecretServiceCreateMongoDBAtlasRotatingSecretBody{ Name: opts.SecretName, IntegrationName: "mongo-db-integration", RotationPolicyName: "built-in:60-days-2-active", - SecretDetails: &preview_models.Secrets20231128MongoDBAtlasSecretDetails{ + SecretDetails: &models.Secrets20231128MongoDBAtlasSecretDetails{ MongodbGroupID: "mbdgi", - MongodbRoles: []*preview_models.Secrets20231128MongoDBRole{ + MongodbRoles: []*models.Secrets20231128MongoDBRole{ { RoleName: "rn1", DatabaseName: "dn1", @@ -361,9 +355,9 @@ details = { }, }, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.CreateMongoDBAtlasRotatingSecretOK{ - Payload: &preview_models.Secrets20231128CreateMongoDBAtlasRotatingSecretResponse{ - Config: &preview_models.Secrets20231128RotatingSecretConfig{ + }, mock.Anything).Return(&secret_service.CreateMongoDBAtlasRotatingSecretOK{ + Payload: &models.Secrets20231128CreateMongoDBAtlasRotatingSecretResponse{ + Config: &models.Secrets20231128RotatingSecretConfig{ AppName: opts.AppName, CreatedAt: dt, IntegrationName: "mongo-db-integration", @@ -375,29 +369,29 @@ details = { } case integrations.Postgres: if c.RespErr { - pvs.EXPECT().CreatePostgresRotatingSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() + vs.EXPECT().CreatePostgresRotatingSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { println(testProfile(t).ProjectID) - pvs.EXPECT().CreatePostgresRotatingSecret(&preview_secret_service.CreatePostgresRotatingSecretParams{ + vs.EXPECT().CreatePostgresRotatingSecret(&secret_service.CreatePostgresRotatingSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, - Body: &preview_models.SecretServiceCreatePostgresRotatingSecretBody{ + Body: &models.SecretServiceCreatePostgresRotatingSecretBody{ Name: opts.SecretName, IntegrationName: "postgres-integration", RotationPolicyName: "built-in:60-days-2-active", - PostgresParams: &preview_models.Secrets20231128PostgresParams{Usernames: []string{"postgres_user_1", "postgres_user_2"}}, + PostgresParams: &models.Secrets20231128PostgresParams{Usernames: []string{"postgres_user_1", "postgres_user_2"}}, }, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.CreatePostgresRotatingSecretOK{ - Payload: &preview_models.Secrets20231128CreatePostgresRotatingSecretResponse{ - Config: &preview_models.Secrets20231128PostgresRotatingSecretConfig{ + }, mock.Anything).Return(&secret_service.CreatePostgresRotatingSecretOK{ + Payload: &models.Secrets20231128CreatePostgresRotatingSecretResponse{ + Config: &models.Secrets20231128PostgresRotatingSecretConfig{ AppName: opts.AppName, CreatedAt: dt, IntegrationName: "postgres-integration", RotationPolicyName: "built-in:60-days-2-active", Name: opts.SecretName, - PostgresParams: &preview_models.Secrets20231128PostgresParams{Usernames: []string{"postgres_user_1", "postgres_user_2"}}, + PostgresParams: &models.Secrets20231128PostgresParams{Usernames: []string{"postgres_user_1", "postgres_user_2"}}, }, }, }, nil).Once() @@ -407,25 +401,25 @@ details = { } else if opts.Type == secretTypeDynamic { if c.MockCalled { if c.RespErr { - pvs.EXPECT().CreateAwsDynamicSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() + vs.EXPECT().CreateAwsDynamicSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - pvs.EXPECT().CreateAwsDynamicSecret(&preview_secret_service.CreateAwsDynamicSecretParams{ + vs.EXPECT().CreateAwsDynamicSecret(&secret_service.CreateAwsDynamicSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, - Body: &preview_models.SecretServiceCreateAwsDynamicSecretBody{ + Body: &models.SecretServiceCreateAwsDynamicSecretBody{ IntegrationName: "Aws-Int-12", Name: opts.SecretName, DefaultTTL: "3600s", - AssumeRole: &preview_models.Secrets20231128AssumeRoleRequest{ + AssumeRole: &models.Secrets20231128AssumeRoleRequest{ RoleArn: "ra", }, }, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.CreateAwsDynamicSecretOK{ - Payload: &preview_models.Secrets20231128CreateAwsDynamicSecretResponse{ - Secret: &preview_models.Secrets20231128AwsDynamicSecret{ - AssumeRole: &preview_models.Secrets20231128AssumeRoleResponse{ + }, mock.Anything).Return(&secret_service.CreateAwsDynamicSecretOK{ + Payload: &models.Secrets20231128CreateAwsDynamicSecretResponse{ + Secret: &models.Secrets20231128AwsDynamicSecret{ + AssumeRole: &models.Secrets20231128AssumeRoleResponse{ RoleArn: "ra", }, DefaultTTL: "3600s", diff --git a/internal/commands/vaultsecrets/secrets/delete.go b/internal/commands/vaultsecrets/secrets/delete.go index 8a116235..493df775 100644 --- a/internal/commands/vaultsecrets/secrets/delete.go +++ b/internal/commands/vaultsecrets/secrets/delete.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/helper" "github.com/hashicorp/hcp/internal/pkg/cmd" @@ -20,12 +19,11 @@ import ( func NewCmdDelete(ctx *cmd.Context, runF func(*DeleteOpts) error) *cmd.Command { opts := &DeleteOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -65,7 +63,7 @@ func NewCmdDelete(ctx *cmd.Context, runF func(*DeleteOpts) error) *cmd.Command { return deleteRun(opts) }, } - cmd.Args.Autocomplete = helper.PredictSecretName(ctx, cmd, opts.PreviewClient) + cmd.Args.Autocomplete = helper.PredictSecretName(ctx, cmd, opts.Client) return cmd } @@ -76,16 +74,15 @@ type DeleteOpts struct { IO iostreams.IOStreams Output *format.Outputter - AppName string - SecretName string - PreviewClient preview_secret_service.ClientService - Client secret_service.ClientService + AppName string + SecretName string + Client secret_service.ClientService } func deleteRun(opts *DeleteOpts) error { req := secret_service.NewDeleteAppSecretParamsWithContext(opts.Ctx) - req.LocationOrganizationID = opts.Profile.OrganizationID - req.LocationProjectID = opts.Profile.ProjectID + req.OrganizationID = opts.Profile.OrganizationID + req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.SecretName = opts.SecretName diff --git a/internal/commands/vaultsecrets/secrets/delete_test.go b/internal/commands/vaultsecrets/secrets/delete_test.go index 7a65bcf8..cd7d63a8 100644 --- a/internal/commands/vaultsecrets/secrets/delete_test.go +++ b/internal/commands/vaultsecrets/secrets/delete_test.go @@ -11,8 +11,8 @@ import ( "github.com/go-openapi/runtime/client" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -145,11 +145,11 @@ func TestDeleteRun(t *testing.T) { vs.EXPECT().DeleteAppSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { vs.EXPECT().DeleteAppSecret(&secret_service.DeleteAppSecretParams{ - LocationOrganizationID: testProfile(t).OrganizationID, - LocationProjectID: testProfile(t).ProjectID, - AppName: testProfile(t).VaultSecrets.AppName, - SecretName: opts.SecretName, - Context: opts.Ctx, + OrganizationID: testProfile(t).OrganizationID, + ProjectID: testProfile(t).ProjectID, + AppName: testProfile(t).VaultSecrets.AppName, + SecretName: opts.SecretName, + Context: opts.Ctx, }, mock.Anything).Return(&secret_service.DeleteAppSecretOK{}, nil).Once() } diff --git a/internal/commands/vaultsecrets/secrets/displayer.go b/internal/commands/vaultsecrets/secrets/displayer.go index ed0ea47b..110c967e 100644 --- a/internal/commands/vaultsecrets/secrets/displayer.go +++ b/internal/commands/vaultsecrets/secrets/displayer.go @@ -6,17 +6,15 @@ package secrets import ( "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/models" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/pkg/format" ) const multiValueSecretFmt = "{{ range $key, $value := %s }}{{printf \"%%s: %%s\\n\" $key $value}}{{ end }}" type displayer struct { - secrets []*models.Secrets20230613Secret - previewSecrets []*preview_models.Secrets20231128Secret - openAppSecrets []*preview_models.Secrets20231128OpenSecret + secrets []*models.Secrets20231128Secret + openAppSecrets []*models.Secrets20231128OpenSecret secretType string secretTypeFormatters map[string]secretTypeFormatter fields []format.Field @@ -103,7 +101,7 @@ func newDisplayer() *displayer { } } -func (d *displayer) Secrets(secrets ...*models.Secrets20230613Secret) *displayer { +func (d *displayer) Secrets(secrets ...*models.Secrets20231128Secret) *displayer { d.secrets = secrets if len(secrets) == 1 { d.secretType = secretTypeKV @@ -111,15 +109,7 @@ func (d *displayer) Secrets(secrets ...*models.Secrets20230613Secret) *displayer return d } -func (d *displayer) PreviewSecrets(secrets ...*preview_models.Secrets20231128Secret) *displayer { - d.previewSecrets = secrets - if len(secrets) == 1 { - d.secretType = secrets[0].Type - } - return d -} - -func (d *displayer) OpenAppSecrets(secrets ...*preview_models.Secrets20231128OpenSecret) *displayer { +func (d *displayer) OpenAppSecrets(secrets ...*models.Secrets20231128OpenSecret) *displayer { d.openAppSecrets = secrets if len(secrets) == 1 { d.secretType = secrets[0].Type @@ -147,10 +137,6 @@ func (d *displayer) DefaultFormat() format.Format { } func (d *displayer) Payload() any { - if d.previewSecrets != nil { - return d.previewSecretsPayload() - } - if d.openAppSecrets != nil { return d.openAppSecretsPayload() } @@ -175,13 +161,6 @@ func (d *displayer) secretsFieldTemplate() []format.Field { }, } - if len(d.previewSecrets) > 0 { - fields = append(fields, format.Field{ - Name: "Type", - ValueFormat: "{{ .Type }}", - }) - } - fields = append(fields, []format.Field{ { Name: "Created At", @@ -191,6 +170,10 @@ func (d *displayer) secretsFieldTemplate() []format.Field { Name: "Latest Version", ValueFormat: "{{ if eq (printf \"%v\" .LatestVersion) \"0\" }}-{{ else }}{{ .LatestVersion }}{{ end }}", }, + { + Name: "Type", + ValueFormat: "{{ .Type }}", + }, }...) return fields @@ -219,13 +202,6 @@ func (d *displayer) secretsPayload() any { return d.secrets } -func (d *displayer) previewSecretsPayload() any { - if len(d.previewSecrets) == 1 { - return d.previewSecrets[0] - } - return d.previewSecrets -} - func (d *displayer) openAppSecretsPayload() any { if len(d.openAppSecrets) == 1 { return d.openAppSecrets[0] @@ -234,7 +210,7 @@ func (d *displayer) openAppSecretsPayload() any { } type rotatingSecretsDisplayer struct { - previewRotatingSecrets []*preview_models.Secrets20231128RotatingSecretConfig + previewRotatingSecrets []*models.Secrets20231128RotatingSecretConfig single bool format format.Format @@ -247,7 +223,7 @@ func newRotatingSecretsDisplayer(single bool) *rotatingSecretsDisplayer { } } -func (r *rotatingSecretsDisplayer) PreviewRotatingSecrets(secrets ...*preview_models.Secrets20231128RotatingSecretConfig) *rotatingSecretsDisplayer { +func (r *rotatingSecretsDisplayer) PreviewRotatingSecrets(secrets ...*models.Secrets20231128RotatingSecretConfig) *rotatingSecretsDisplayer { r.previewRotatingSecrets = secrets return r } diff --git a/internal/commands/vaultsecrets/secrets/helper/helper.go b/internal/commands/vaultsecrets/secrets/helper/helper.go index 6dc447c6..2fedead7 100644 --- a/internal/commands/vaultsecrets/secrets/helper/helper.go +++ b/internal/commands/vaultsecrets/secrets/helper/helper.go @@ -7,15 +7,15 @@ import ( "context" "fmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/posener/complete" ) // PredictSecretName returns a predict function for secret names. -func PredictSecretName(ctx *cmd.Context, c *cmd.Command, client preview_secret_service.ClientService) complete.PredictFunc { +func PredictSecretName(ctx *cmd.Context, c *cmd.Command, client secret_service.ClientService) complete.PredictFunc { return func(args complete.Args) []string { // Parse the args remainingArgs, err := ctx.ParseFlags(c, args.All) @@ -46,13 +46,13 @@ func PredictSecretName(ctx *cmd.Context, c *cmd.Command, client preview_secret_s } } -func getSecrets(ctx context.Context, orgID, projectID, appName string, client preview_secret_service.ClientService) ([]*preview_models.Secrets20231128Secret, error) { - req := preview_secret_service.NewListAppSecretsParamsWithContext(ctx) +func getSecrets(ctx context.Context, orgID, projectID, appName string, client secret_service.ClientService) ([]*models.Secrets20231128Secret, error) { + req := secret_service.NewListAppSecretsParamsWithContext(ctx) req.OrganizationID = orgID req.ProjectID = projectID req.AppName = appName - var secrets []*preview_models.Secrets20231128Secret + var secrets []*models.Secrets20231128Secret for { resp, err := client.ListAppSecrets(req, nil) diff --git a/internal/commands/vaultsecrets/secrets/list.go b/internal/commands/vaultsecrets/secrets/list.go index 26ce08f2..982962bb 100644 --- a/internal/commands/vaultsecrets/secrets/list.go +++ b/internal/commands/vaultsecrets/secrets/list.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" @@ -21,12 +20,11 @@ import ( func NewCmdList(ctx *cmd.Context, runF func(*ListOpts) error) *cmd.Command { opts := &ListOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -70,20 +68,19 @@ type ListOpts struct { IO iostreams.IOStreams Output *format.Outputter - AppName string - PreviewClient preview_secret_service.ClientService - Client secret_service.ClientService + AppName string + Client secret_service.ClientService } func listRun(opts *ListOpts) error { - req := preview_secret_service.NewListAppSecretsParamsWithContext(opts.Ctx) + req := secret_service.NewListAppSecretsParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName var secrets []*models.Secrets20231128Secret for { - resp, err := opts.PreviewClient.ListAppSecrets(req, nil) + resp, err := opts.Client.ListAppSecrets(req, nil) if err != nil { return fmt.Errorf("failed to list secrets: %w", err) } @@ -96,5 +93,5 @@ func listRun(opts *ListOpts) error { next := resp.Payload.Pagination.NextPageToken req.PaginationNextPageToken = &next } - return opts.Output.Display(newDisplayer().PreviewSecrets(secrets...)) + return opts.Output.Display(newDisplayer().Secrets(secrets...)) } diff --git a/internal/commands/vaultsecrets/secrets/list_test.go b/internal/commands/vaultsecrets/secrets/list_test.go index 30582d94..f91b3b1b 100644 --- a/internal/commands/vaultsecrets/secrets/list_test.go +++ b/internal/commands/vaultsecrets/secrets/list_test.go @@ -14,9 +14,9 @@ import ( "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -124,42 +124,42 @@ func TestListRun(t *testing.T) { io := iostreams.Test() io.ErrorTTY = true - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &ListOpts{ - Ctx: context.Background(), - IO: io, - Profile: testProfile(t), - Output: format.New(io), - PreviewClient: vs, - AppName: testProfile(t).VaultSecrets.AppName, + Ctx: context.Background(), + IO: io, + Profile: testProfile(t), + Output: format.New(io), + Client: vs, + AppName: testProfile(t).VaultSecrets.AppName, } if c.RespErr { vs.EXPECT().ListAppSecrets(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { paginationNextPageToken := "next_page_token" - vs.EXPECT().ListAppSecrets(&preview_secret_service.ListAppSecretsParams{ + vs.EXPECT().ListAppSecrets(&secret_service.ListAppSecretsParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.ListAppSecretsOK{ - Payload: &preview_models.Secrets20231128ListAppSecretsResponse{ + }, mock.Anything).Return(&secret_service.ListAppSecretsOK{ + Payload: &models.Secrets20231128ListAppSecretsResponse{ Secrets: getMockSecrets(0, 10), - Pagination: &preview_models.CommonPaginationResponse{ + Pagination: &models.CommonPaginationResponse{ NextPageToken: paginationNextPageToken, }, }, }, nil).Once() - vs.EXPECT().ListAppSecrets(&preview_secret_service.ListAppSecretsParams{ + vs.EXPECT().ListAppSecrets(&secret_service.ListAppSecretsParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Context: opts.Ctx, PaginationNextPageToken: &paginationNextPageToken, - }, mock.Anything).Return(&preview_secret_service.ListAppSecretsOK{ - Payload: &preview_models.Secrets20231128ListAppSecretsResponse{ + }, mock.Anything).Return(&secret_service.ListAppSecretsOK{ + Payload: &models.Secrets20231128ListAppSecretsResponse{ Secrets: getMockSecrets(10, 5), }, }, nil).Once() @@ -178,10 +178,10 @@ func TestListRun(t *testing.T) { } } -func getMockSecrets(start, limit int) []*preview_models.Secrets20231128Secret { - var secrets []*preview_models.Secrets20231128Secret +func getMockSecrets(start, limit int) []*models.Secrets20231128Secret { + var secrets []*models.Secrets20231128Secret for i := start; i < (start + limit); i++ { - secrets = append(secrets, &preview_models.Secrets20231128Secret{ + secrets = append(secrets, &models.Secrets20231128Secret{ Name: fmt.Sprint("test_secret_", i), LatestVersion: int64(rand.Intn(5)), CreatedAt: strfmt.DateTime(time.Now()), diff --git a/internal/commands/vaultsecrets/secrets/open.go b/internal/commands/vaultsecrets/secrets/open.go index 3acc8400..8902e560 100644 --- a/internal/commands/vaultsecrets/secrets/open.go +++ b/internal/commands/vaultsecrets/secrets/open.go @@ -11,8 +11,7 @@ import ( "os" "strings" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/helper" "github.com/hashicorp/hcp/internal/pkg/cmd" @@ -25,12 +24,11 @@ import ( func NewCmdOpen(ctx *cmd.Context, runF func(*OpenOpts) error) *cmd.Command { opts := &OpenOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -76,7 +74,7 @@ func NewCmdOpen(ctx *cmd.Context, runF func(*OpenOpts) error) *cmd.Command { return openRun(opts) }, } - cmd.Args.Autocomplete = helper.PredictSecretName(ctx, cmd, opts.PreviewClient) + cmd.Args.Autocomplete = helper.PredictSecretName(ctx, cmd, opts.Client) return cmd } @@ -90,7 +88,6 @@ type OpenOpts struct { AppName string SecretName string OutputFilePath string - PreviewClient preview_secret_service.ClientService Client secret_service.ClientService } @@ -108,13 +105,13 @@ func openRun(opts *OpenOpts) (err error) { } }() - req := preview_secret_service.NewOpenAppSecretParamsWithContext(opts.Ctx) + req := secret_service.NewOpenAppSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.SecretName = opts.SecretName - resp, err := opts.PreviewClient.OpenAppSecret(req, nil) + resp, err := opts.Client.OpenAppSecret(req, nil) if err != nil { return fmt.Errorf("failed to read the secret %q: %w", opts.SecretName, err) } diff --git a/internal/commands/vaultsecrets/secrets/open_test.go b/internal/commands/vaultsecrets/secrets/open_test.go index 98553b2d..92a36a4d 100644 --- a/internal/commands/vaultsecrets/secrets/open_test.go +++ b/internal/commands/vaultsecrets/secrets/open_test.go @@ -14,9 +14,9 @@ import ( "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -154,15 +154,15 @@ func TestOpenRun(t *testing.T) { io := iostreams.Test() io.ErrorTTY = true - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &OpenOpts{ - Ctx: context.Background(), - IO: io, - Profile: testProfile(t), - Output: format.New(io), - PreviewClient: vs, - AppName: testProfile(t).VaultSecrets.AppName, - SecretName: testSecretName, + Ctx: context.Background(), + IO: io, + Profile: testProfile(t), + Output: format.New(io), + Client: vs, + AppName: testProfile(t).VaultSecrets.AppName, + SecretName: testSecretName, } if c.WriteToFile { @@ -180,18 +180,18 @@ func TestOpenRun(t *testing.T) { if c.RespErr { vs.EXPECT().OpenAppSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - vs.EXPECT().OpenAppSecret(&preview_secret_service.OpenAppSecretParams{ + vs.EXPECT().OpenAppSecret(&secret_service.OpenAppSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, SecretName: opts.SecretName, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.OpenAppSecretOK{ - Payload: &preview_models.Secrets20231128OpenAppSecretResponse{ - Secret: &preview_models.Secrets20231128OpenSecret{ + }, mock.Anything).Return(&secret_service.OpenAppSecretOK{ + Payload: &models.Secrets20231128OpenAppSecretResponse{ + Secret: &models.Secrets20231128OpenSecret{ Name: opts.SecretName, LatestVersion: 3, - StaticVersion: &preview_models.Secrets20231128OpenSecretStaticVersion{ + StaticVersion: &models.Secrets20231128OpenSecretStaticVersion{ Version: 3, Value: "my super secret value", }, diff --git a/internal/commands/vaultsecrets/secrets/read.go b/internal/commands/vaultsecrets/secrets/read.go index 5dc2c752..f5f76c88 100644 --- a/internal/commands/vaultsecrets/secrets/read.go +++ b/internal/commands/vaultsecrets/secrets/read.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/helper" "github.com/hashicorp/hcp/internal/pkg/cmd" @@ -20,12 +19,11 @@ import ( func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command { opts := &ReadOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -66,7 +64,7 @@ func NewCmdRead(ctx *cmd.Context, runF func(*ReadOpts) error) *cmd.Command { return readRun(opts) }, } - cmd.Args.Autocomplete = helper.PredictSecretName(ctx, cmd, opts.PreviewClient) + cmd.Args.Autocomplete = helper.PredictSecretName(ctx, cmd, opts.Client) return cmd } @@ -77,24 +75,23 @@ type ReadOpts struct { IO iostreams.IOStreams Output *format.Outputter - AppName string - SecretName string - PreviewClient preview_secret_service.ClientService - Client secret_service.ClientService + AppName string + SecretName string + Client secret_service.ClientService } func readRun(opts *ReadOpts) error { - req := preview_secret_service.NewGetAppSecretParamsWithContext(opts.Ctx) + req := secret_service.NewGetAppSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.SecretName = opts.SecretName - resp, err := opts.PreviewClient.GetAppSecret(req, nil) + resp, err := opts.Client.GetAppSecret(req, nil) if err != nil { return fmt.Errorf("failed to read the secret %q: %w", opts.SecretName, err) } - displayer := newDisplayer().PreviewSecrets(resp.Payload.Secret).SetDefaultFormat(format.Pretty) + displayer := newDisplayer().Secrets(resp.Payload.Secret).SetDefaultFormat(format.Pretty) return opts.Output.Display(displayer) } diff --git a/internal/commands/vaultsecrets/secrets/read_test.go b/internal/commands/vaultsecrets/secrets/read_test.go index 8d6cf1d4..c7ce44ee 100644 --- a/internal/commands/vaultsecrets/secrets/read_test.go +++ b/internal/commands/vaultsecrets/secrets/read_test.go @@ -12,9 +12,9 @@ import ( "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -144,30 +144,30 @@ func TestReadRun(t *testing.T) { io := iostreams.Test() io.ErrorTTY = true - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &ReadOpts{ - Ctx: context.Background(), - IO: io, - Profile: testProfile(t), - Output: format.New(io), - PreviewClient: vs, - AppName: testProfile(t).VaultSecrets.AppName, - SecretName: testSecretName, + Ctx: context.Background(), + IO: io, + Profile: testProfile(t), + Output: format.New(io), + Client: vs, + AppName: testProfile(t).VaultSecrets.AppName, + SecretName: testSecretName, } if c.MockCalled { if c.RespErr { vs.EXPECT().GetAppSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - vs.EXPECT().GetAppSecret(&preview_secret_service.GetAppSecretParams{ + vs.EXPECT().GetAppSecret(&secret_service.GetAppSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, SecretName: opts.SecretName, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.GetAppSecretOK{ - Payload: &preview_models.Secrets20231128GetAppSecretResponse{ - Secret: &preview_models.Secrets20231128Secret{ + }, mock.Anything).Return(&secret_service.GetAppSecretOK{ + Payload: &models.Secrets20231128GetAppSecretResponse{ + Secret: &models.Secrets20231128Secret{ Name: opts.SecretName, LatestVersion: 2, CreatedAt: strfmt.DateTime(time.Now()), diff --git a/internal/commands/vaultsecrets/secrets/rotate.go b/internal/commands/vaultsecrets/secrets/rotate.go index 2222631f..fa12102a 100644 --- a/internal/commands/vaultsecrets/secrets/rotate.go +++ b/internal/commands/vaultsecrets/secrets/rotate.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/helper" "github.com/hashicorp/hcp/internal/pkg/cmd" @@ -24,20 +23,18 @@ type RotateOpts struct { Output *format.Outputter IO iostreams.IOStreams - AppName string - SecretName string - Client secret_service.ClientService - PreviewClient preview_secret_service.ClientService + AppName string + SecretName string + Client secret_service.ClientService } func NewCmdRotate(ctx *cmd.Context, runF func(*RotateOpts) error) *cmd.Command { opts := &RotateOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -78,13 +75,13 @@ func NewCmdRotate(ctx *cmd.Context, runF func(*RotateOpts) error) *cmd.Command { return rotateRun(opts) }, } - cmd.Args.Autocomplete = helper.PredictSecretName(ctx, cmd, opts.PreviewClient) + cmd.Args.Autocomplete = helper.PredictSecretName(ctx, cmd, opts.Client) return cmd } func rotateRun(opts *RotateOpts) error { - params := &preview_secret_service.RotateSecretParams{ + params := &secret_service.RotateSecretParams{ Context: opts.Ctx, OrganizationID: opts.Profile.OrganizationID, ProjectID: opts.Profile.ProjectID, @@ -92,7 +89,7 @@ func rotateRun(opts *RotateOpts) error { Name: opts.SecretName, } - _, err := opts.PreviewClient.RotateSecret(params, nil) + _, err := opts.Client.RotateSecret(params, nil) if err != nil { return fmt.Errorf("failed to rotate the secret %q: %w", opts.SecretName, err) } diff --git a/internal/commands/vaultsecrets/secrets/rotate_test.go b/internal/commands/vaultsecrets/secrets/rotate_test.go index 672caff8..a2f8a9cb 100644 --- a/internal/commands/vaultsecrets/secrets/rotate_test.go +++ b/internal/commands/vaultsecrets/secrets/rotate_test.go @@ -13,8 +13,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -142,28 +142,28 @@ func TestRotateRun(t *testing.T) { io := iostreams.Test() io.ErrorTTY = true - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &RotateOpts{ - Ctx: context.Background(), - IO: io, - Profile: testProfile(t), - Output: format.New(io), - PreviewClient: vs, - AppName: testProfile(t).VaultSecrets.AppName, - SecretName: testSecretName, + Ctx: context.Background(), + IO: io, + Profile: testProfile(t), + Output: format.New(io), + Client: vs, + AppName: testProfile(t).VaultSecrets.AppName, + SecretName: testSecretName, } if c.MockCalled { if c.RespErr { vs.EXPECT().RotateSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - vs.EXPECT().RotateSecret(&preview_secret_service.RotateSecretParams{ + vs.EXPECT().RotateSecret(&secret_service.RotateSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Name: opts.SecretName, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.RotateSecretOK{}, nil).Once() + }, mock.Anything).Return(&secret_service.RotateSecretOK{}, nil).Once() } } diff --git a/internal/commands/vaultsecrets/secrets/secrets.go b/internal/commands/vaultsecrets/secrets/secrets.go index a93327e1..e2d390e5 100644 --- a/internal/commands/vaultsecrets/secrets/secrets.go +++ b/internal/commands/vaultsecrets/secrets/secrets.go @@ -4,7 +4,7 @@ package secrets import ( - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/apps/helper" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/versions" @@ -39,7 +39,7 @@ func NewCmdSecrets(ctx *cmd.Context) *cmd.Command { // Autocomplete the persistent flag. for _, f := range cmd.Flags.Persistent { if f.Name == "app" { - f.Autocomplete = helper.PredictAppName(ctx, cmd, preview_secret_service.New(ctx.HCP, nil)) + f.Autocomplete = helper.PredictAppName(ctx, cmd, secret_service.New(ctx.HCP, nil)) } } diff --git a/internal/commands/vaultsecrets/secrets/update.go b/internal/commands/vaultsecrets/secrets/update.go index 4e44829d..872fbb63 100644 --- a/internal/commands/vaultsecrets/secrets/update.go +++ b/internal/commands/vaultsecrets/secrets/update.go @@ -12,9 +12,8 @@ import ( "github.com/zclconf/go-cty/cty" "github.com/hashicorp/hcl/v2/hclsimple" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/integrations" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/pkg/cmd" @@ -36,18 +35,16 @@ type UpdateOpts struct { SecretValuePlaintext string SecretFilePath string Type string - PreviewClient preview_secret_service.ClientService Client secret_service.ClientService } func NewCmdUpdate(ctx *cmd.Context, runF func(*UpdateOpts) error) *cmd.Command { opts := &UpdateOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -131,13 +128,13 @@ func updateRun(opts *UpdateOpts) error { switch secretConfig.Type { case integrations.Twilio: - req := preview_secret_service.NewUpdateTwilioRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateTwilioRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.Name = opts.SecretName - var twilioBody preview_models.SecretServiceUpdateTwilioRotatingSecretBody + var twilioBody models.SecretServiceUpdateTwilioRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -149,7 +146,7 @@ func updateRun(opts *UpdateOpts) error { } req.Body = &twilioBody - resp, err := opts.PreviewClient.UpdateTwilioRotatingSecret(req, nil) + resp, err := opts.Client.UpdateTwilioRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to update secret with name %q: %w", opts.SecretName, err) } @@ -159,13 +156,13 @@ func updateRun(opts *UpdateOpts) error { } case integrations.MongoDBAtlas: - req := preview_secret_service.NewUpdateMongoDBAtlasRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateMongoDBAtlasRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.Name = opts.SecretName - var mongoDBBody preview_models.SecretServiceUpdateMongoDBAtlasRotatingSecretBody + var mongoDBBody models.SecretServiceUpdateMongoDBAtlasRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -177,7 +174,7 @@ func updateRun(opts *UpdateOpts) error { } req.Body = &mongoDBBody - resp, err := opts.PreviewClient.UpdateMongoDBAtlasRotatingSecret(req, nil) + resp, err := opts.Client.UpdateMongoDBAtlasRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to update secret with name %q: %w", opts.SecretName, err) } @@ -187,13 +184,13 @@ func updateRun(opts *UpdateOpts) error { } case integrations.AWS: - req := preview_secret_service.NewUpdateAwsIAMUserAccessKeyRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateAwsIAMUserAccessKeyRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.Name = opts.SecretName - var awsBody preview_models.SecretServiceUpdateAwsIAMUserAccessKeyRotatingSecretBody + var awsBody models.SecretServiceUpdateAwsIAMUserAccessKeyRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -206,19 +203,19 @@ func updateRun(opts *UpdateOpts) error { req.Body = &awsBody - _, err = opts.PreviewClient.UpdateAwsIAMUserAccessKeyRotatingSecret(req, nil) + _, err = opts.Client.UpdateAwsIAMUserAccessKeyRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to update secret with name %q: %w", opts.SecretName, err) } case integrations.GCP: - req := preview_secret_service.NewUpdateGcpServiceAccountKeyRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateGcpServiceAccountKeyRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.Name = opts.SecretName - var gcpBody preview_models.SecretServiceUpdateGcpServiceAccountKeyRotatingSecretBody + var gcpBody models.SecretServiceUpdateGcpServiceAccountKeyRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -231,19 +228,19 @@ func updateRun(opts *UpdateOpts) error { req.Body = &gcpBody - _, err = opts.PreviewClient.UpdateGcpServiceAccountKeyRotatingSecret(req, nil) + _, err = opts.Client.UpdateGcpServiceAccountKeyRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to update secret with name %q: %w", opts.SecretName, err) } case integrations.Postgres: - req := preview_secret_service.NewUpdatePostgresRotatingSecretParamsWithContext(opts.Ctx) + req := secret_service.NewUpdatePostgresRotatingSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.Name = opts.SecretName - var postgresBody preview_models.SecretServiceUpdatePostgresRotatingSecretBody + var postgresBody models.SecretServiceUpdatePostgresRotatingSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -256,7 +253,7 @@ func updateRun(opts *UpdateOpts) error { req.Body = &postgresBody - _, err = opts.PreviewClient.UpdatePostgresRotatingSecret(req, nil) + _, err = opts.Client.UpdatePostgresRotatingSecret(req, nil) if err != nil { return fmt.Errorf("failed to update secret with name %q: %w", opts.SecretName, err) } @@ -276,13 +273,13 @@ func updateRun(opts *UpdateOpts) error { switch secretConfig.Type { case integrations.AWS: - req := preview_secret_service.NewUpdateAwsDynamicSecretParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateAwsDynamicSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.Name = opts.SecretName - var awsBody preview_models.SecretServiceUpdateAwsDynamicSecretBody + var awsBody models.SecretServiceUpdateAwsDynamicSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -295,19 +292,19 @@ func updateRun(opts *UpdateOpts) error { req.Body = &awsBody - _, err = opts.PreviewClient.UpdateAwsDynamicSecret(req, nil) + _, err = opts.Client.UpdateAwsDynamicSecret(req, nil) if err != nil { return fmt.Errorf("failed to update secret with name %q: %w", opts.SecretName, err) } case integrations.GCP: - req := preview_secret_service.NewUpdateGcpDynamicSecretParamsWithContext(opts.Ctx) + req := secret_service.NewUpdateGcpDynamicSecretParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName req.Name = opts.SecretName - var gcpBody preview_models.SecretServiceUpdateGcpDynamicSecretBody + var gcpBody models.SecretServiceUpdateGcpDynamicSecretBody detailBytes, err := json.Marshal(internalConfig.Details) if err != nil { return fmt.Errorf("error marshaling details config: %w", err) @@ -320,7 +317,7 @@ func updateRun(opts *UpdateOpts) error { req.Body = &gcpBody - _, err = opts.PreviewClient.UpdateGcpDynamicSecret(req, nil) + _, err = opts.Client.UpdateGcpDynamicSecret(req, nil) if err != nil { return fmt.Errorf("failed to update secret with name %q: %w", opts.SecretName, err) } diff --git a/internal/commands/vaultsecrets/secrets/update_test.go b/internal/commands/vaultsecrets/secrets/update_test.go index bef7e357..74d9684c 100644 --- a/internal/commands/vaultsecrets/secrets/update_test.go +++ b/internal/commands/vaultsecrets/secrets/update_test.go @@ -14,10 +14,9 @@ import ( "github.com/hashicorp/hcp/internal/commands/vaultsecrets/integrations" "github.com/go-openapi/strfmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/stretchr/testify/mock" "github.com/go-openapi/runtime/client" @@ -252,17 +251,15 @@ details = { io := iostreams.Test() vs := mock_secret_service.NewMockClientService(t) - pvs := mock_preview_secret_service.NewMockClientService(t) opts := &UpdateOpts{ - Ctx: context.Background(), - IO: io, - Profile: testProfile(t), - Output: format.New(io), - Client: vs, - PreviewClient: pvs, - AppName: testProfile(t).VaultSecrets.AppName, - SecretName: "test_secret", + Ctx: context.Background(), + IO: io, + Profile: testProfile(t), + Output: format.New(io), + Client: vs, + AppName: testProfile(t).VaultSecrets.AppName, + SecretName: "test_secret", } if c.AugmentOpts != nil { @@ -282,19 +279,19 @@ details = { switch c.Provider { case integrations.MongoDBAtlas: if c.RespErr { - pvs.EXPECT().UpdateMongoDBAtlasRotatingSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() + vs.EXPECT().UpdateMongoDBAtlasRotatingSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - pvs.EXPECT().UpdateMongoDBAtlasRotatingSecret(&preview_secret_service.UpdateMongoDBAtlasRotatingSecretParams{ + vs.EXPECT().UpdateMongoDBAtlasRotatingSecret(&secret_service.UpdateMongoDBAtlasRotatingSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Name: "test_secret", - Body: &preview_models.SecretServiceUpdateMongoDBAtlasRotatingSecretBody{ + Body: &models.SecretServiceUpdateMongoDBAtlasRotatingSecretBody{ RotateOnUpdate: true, RotationPolicyName: "built-in:60-days-2-active", - SecretDetails: &preview_models.Secrets20231128MongoDBAtlasSecretDetails{ + SecretDetails: &models.Secrets20231128MongoDBAtlasSecretDetails{ MongodbGroupID: "mbdgi", - MongodbRoles: []*preview_models.Secrets20231128MongoDBRole{ + MongodbRoles: []*models.Secrets20231128MongoDBRole{ { RoleName: "rn1", DatabaseName: "dn1", @@ -309,9 +306,9 @@ details = { }, }, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.UpdateMongoDBAtlasRotatingSecretOK{ - Payload: &preview_models.Secrets20231128UpdateMongoDBAtlasRotatingSecretResponse{ - Config: &preview_models.Secrets20231128RotatingSecretConfig{ + }, mock.Anything).Return(&secret_service.UpdateMongoDBAtlasRotatingSecretOK{ + Payload: &models.Secrets20231128UpdateMongoDBAtlasRotatingSecretResponse{ + Config: &models.Secrets20231128RotatingSecretConfig{ AppName: opts.AppName, CreatedAt: dt, IntegrationName: "mongo-db-integration", @@ -323,30 +320,30 @@ details = { } case integrations.Postgres: if c.RespErr { - pvs.EXPECT().UpdatePostgresRotatingSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() + vs.EXPECT().UpdatePostgresRotatingSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - pvs.EXPECT().UpdatePostgresRotatingSecret(&preview_secret_service.UpdatePostgresRotatingSecretParams{ + vs.EXPECT().UpdatePostgresRotatingSecret(&secret_service.UpdatePostgresRotatingSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Name: "test_secret", - Body: &preview_models.SecretServiceUpdatePostgresRotatingSecretBody{ + Body: &models.SecretServiceUpdatePostgresRotatingSecretBody{ RotateOnUpdate: true, RotationPolicyName: "built-in:60-days-2-active", - PostgresParams: &preview_models.Secrets20231128PostgresParams{ + PostgresParams: &models.Secrets20231128PostgresParams{ Usernames: []string{"postgres_user_1", "postgres_user_2"}, }, }, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.UpdatePostgresRotatingSecretOK{ - Payload: &preview_models.Secrets20231128UpdatePostgresRotatingSecretResponse{ - Config: &preview_models.Secrets20231128PostgresRotatingSecretConfig{ + }, mock.Anything).Return(&secret_service.UpdatePostgresRotatingSecretOK{ + Payload: &models.Secrets20231128UpdatePostgresRotatingSecretResponse{ + Config: &models.Secrets20231128PostgresRotatingSecretConfig{ AppName: opts.AppName, CreatedAt: dt, IntegrationName: "postgres-integration", RotationPolicyName: "built-in:60-days-2-active", Name: opts.SecretName, - PostgresParams: &preview_models.Secrets20231128PostgresParams{ + PostgresParams: &models.Secrets20231128PostgresParams{ Usernames: []string{"postgres_user_1", "postgres_user_2"}, }, }, @@ -359,24 +356,24 @@ details = { } else if opts.Type == secretTypeDynamic { if c.MockCalled { if c.RespErr { - pvs.EXPECT().UpdateAwsDynamicSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() + vs.EXPECT().UpdateAwsDynamicSecret(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { - pvs.EXPECT().UpdateAwsDynamicSecret(&preview_secret_service.UpdateAwsDynamicSecretParams{ + vs.EXPECT().UpdateAwsDynamicSecret(&secret_service.UpdateAwsDynamicSecretParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, Name: opts.SecretName, - Body: &preview_models.SecretServiceUpdateAwsDynamicSecretBody{ + Body: &models.SecretServiceUpdateAwsDynamicSecretBody{ DefaultTTL: "3600s", - AssumeRole: &preview_models.Secrets20231128AssumeRoleRequest{ + AssumeRole: &models.Secrets20231128AssumeRoleRequest{ RoleArn: "ra2", }, }, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.UpdateAwsDynamicSecretOK{ - Payload: &preview_models.Secrets20231128UpdateAwsDynamicSecretResponse{ - Secret: &preview_models.Secrets20231128AwsDynamicSecret{ - AssumeRole: &preview_models.Secrets20231128AssumeRoleResponse{ + }, mock.Anything).Return(&secret_service.UpdateAwsDynamicSecretOK{ + Payload: &models.Secrets20231128UpdateAwsDynamicSecretResponse{ + Secret: &models.Secrets20231128AwsDynamicSecret{ + AssumeRole: &models.Secrets20231128AssumeRoleResponse{ RoleArn: "ra2", }, DefaultTTL: "3600s", diff --git a/internal/commands/vaultsecrets/secrets/versions/list.go b/internal/commands/vaultsecrets/secrets/versions/list.go index 1f98baac..f7a30027 100644 --- a/internal/commands/vaultsecrets/secrets/versions/list.go +++ b/internal/commands/vaultsecrets/secrets/versions/list.go @@ -7,8 +7,7 @@ import ( "context" "fmt" - "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-06-13/client/secret_service" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" "github.com/hashicorp/hcp/internal/commands/vaultsecrets/secrets/appname" "github.com/hashicorp/hcp/internal/pkg/cmd" @@ -20,12 +19,11 @@ import ( func NewCmdList(ctx *cmd.Context, runF func(*ListOpts) error) *cmd.Command { opts := &ListOpts{ - Ctx: ctx.ShutdownCtx, - Profile: ctx.Profile, - IO: ctx.IO, - Output: ctx.Output, - PreviewClient: preview_secret_service.New(ctx.HCP, nil), - Client: secret_service.New(ctx.HCP, nil), + Ctx: ctx.ShutdownCtx, + Profile: ctx.Profile, + IO: ctx.IO, + Output: ctx.Output, + Client: secret_service.New(ctx.HCP, nil), } cmd := &cmd.Command{ @@ -75,14 +73,13 @@ type ListOpts struct { IO iostreams.IOStreams Output *format.Outputter - AppName string - SecretName string - PreviewClient preview_secret_service.ClientService - Client secret_service.ClientService + AppName string + SecretName string + Client secret_service.ClientService } func versionsRun(opts *ListOpts) error { - req := preview_secret_service.NewListAppSecretVersionsParamsWithContext(opts.Ctx) + req := secret_service.NewListAppSecretVersionsParamsWithContext(opts.Ctx) req.OrganizationID = opts.Profile.OrganizationID req.ProjectID = opts.Profile.ProjectID req.AppName = opts.AppName @@ -90,7 +87,7 @@ func versionsRun(opts *ListOpts) error { var secrets []*models.Secrets20231128SecretStaticVersion for { - resp, err := opts.PreviewClient.ListAppSecretVersions(req, nil) + resp, err := opts.Client.ListAppSecretVersions(req, nil) if err != nil { return fmt.Errorf("failed to versions secrets: %w", err) } diff --git a/internal/commands/vaultsecrets/secrets/versions/list_test.go b/internal/commands/vaultsecrets/secrets/versions/list_test.go index 8339aa73..81bd1fff 100644 --- a/internal/commands/vaultsecrets/secrets/versions/list_test.go +++ b/internal/commands/vaultsecrets/secrets/versions/list_test.go @@ -14,9 +14,9 @@ import ( "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - preview_secret_service "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" - preview_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" - mock_preview_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" + "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models" + mock_secret_service "github.com/hashicorp/hcp/internal/pkg/api/mocks/github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service" "github.com/hashicorp/hcp/internal/pkg/cmd" "github.com/hashicorp/hcp/internal/pkg/format" "github.com/hashicorp/hcp/internal/pkg/iostreams" @@ -141,45 +141,45 @@ func TestListRun(t *testing.T) { io := iostreams.Test() io.ErrorTTY = true - vs := mock_preview_secret_service.NewMockClientService(t) + vs := mock_secret_service.NewMockClientService(t) opts := &ListOpts{ - Ctx: context.Background(), - IO: io, - Profile: testProfile(t), - Output: format.New(io), - PreviewClient: vs, - AppName: testProfile(t).VaultSecrets.AppName, - SecretName: testSecretName, + Ctx: context.Background(), + IO: io, + Profile: testProfile(t), + Output: format.New(io), + Client: vs, + AppName: testProfile(t).VaultSecrets.AppName, + SecretName: testSecretName, } if c.RespErr { vs.EXPECT().ListAppSecretVersions(mock.Anything, mock.Anything).Return(nil, errors.New(c.ErrMsg)).Once() } else { paginationNextPageToken := "next_page_token" - vs.EXPECT().ListAppSecretVersions(&preview_secret_service.ListAppSecretVersionsParams{ + vs.EXPECT().ListAppSecretVersions(&secret_service.ListAppSecretVersionsParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, SecretName: testSecretName, Context: opts.Ctx, - }, mock.Anything).Return(&preview_secret_service.ListAppSecretVersionsOK{ - Payload: &preview_models.Secrets20231128ListAppSecretVersionsResponse{ + }, mock.Anything).Return(&secret_service.ListAppSecretVersionsOK{ + Payload: &models.Secrets20231128ListAppSecretVersionsResponse{ StaticVersions: getMockSecretList(0, 10), - Pagination: &preview_models.CommonPaginationResponse{ + Pagination: &models.CommonPaginationResponse{ NextPageToken: paginationNextPageToken, }, }, }, nil).Once() - vs.EXPECT().ListAppSecretVersions(&preview_secret_service.ListAppSecretVersionsParams{ + vs.EXPECT().ListAppSecretVersions(&secret_service.ListAppSecretVersionsParams{ OrganizationID: testProfile(t).OrganizationID, ProjectID: testProfile(t).ProjectID, AppName: testProfile(t).VaultSecrets.AppName, SecretName: testSecretName, Context: opts.Ctx, PaginationNextPageToken: &paginationNextPageToken, - }, mock.Anything).Return(&preview_secret_service.ListAppSecretVersionsOK{ - Payload: &preview_models.Secrets20231128ListAppSecretVersionsResponse{ + }, mock.Anything).Return(&secret_service.ListAppSecretVersionsOK{ + Payload: &models.Secrets20231128ListAppSecretVersionsResponse{ StaticVersions: getMockSecretList(10, 5), }, }, nil).Once() @@ -198,20 +198,20 @@ func TestListRun(t *testing.T) { } } -func getMockSecretList(start, limit int) *preview_models.Secrets20231128SecretStaticVersionList { - var secrets []*preview_models.Secrets20231128SecretStaticVersion +func getMockSecretList(start, limit int) *models.Secrets20231128SecretStaticVersionList { + var secrets []*models.Secrets20231128SecretStaticVersion for i := start; i < (start + limit); i++ { - secrets = append(secrets, &preview_models.Secrets20231128SecretStaticVersion{ + secrets = append(secrets, &models.Secrets20231128SecretStaticVersion{ Version: int64(rand.Intn(5)), CreatedAt: strfmt.DateTime(time.Now()), - CreatedBy: &preview_models.Secrets20231128Principal{ + CreatedBy: &models.Secrets20231128Principal{ Email: fmt.Sprintf("test-user-%d@example.com", i), Name: fmt.Sprintf("test-user-%d", i), Type: "kv", }, }) } - return &preview_models.Secrets20231128SecretStaticVersionList{ + return &models.Secrets20231128SecretStaticVersionList{ Versions: secrets, } }