Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/stackit_mongodbflex_instance_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ stackit mongodbflex instance create [flags]
```
--acl strings The access control list (ACL). Must contain at least one valid subnet, for instance '0.0.0.0/0' for open access (discouraged), '1.2.3.0/24 for a public IP range of an organization, '1.2.3.4/32' for a single IP range, etc. (default [])
--backup-schedule string Backup schedule (default "0 0/6 * * *")
--cpu int Number of CPUs
--cpu int32 Number of CPUs
--flavor-id string ID of the flavor
-h, --help Help for "stackit mongodbflex instance create"
-n, --name string Instance name
--ram int Amount of RAM (in GB)
--ram int32 Amount of RAM (in GB)
--storage-class string Storage class (default "premium-perf2-mongodb")
--storage-size int Storage size (in GB) (default 10)
--type string Instance type, (one of: [Replica, Sharded, Single]) (default "Replica")
Expand Down
4 changes: 2 additions & 2 deletions docs/stackit_mongodbflex_instance_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ stackit mongodbflex instance update INSTANCE_ID [flags]
```
--acl strings Lists of IP networks in CIDR notation which are allowed to access this instance (default [])
--backup-schedule string Backup schedule
--cpu int Number of CPUs
--cpu int32 Number of CPUs
--flavor-id string ID of the flavor
-h, --help Help for "stackit mongodbflex instance update"
-n, --name string Instance name
--ram int Amount of RAM (in GB)
--ram int32 Amount of RAM (in GB)
--storage-class string Storage class
--storage-size int Storage size (in GB)
--type string Instance type, (one of: [Replica, Sharded, Single])
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.12.0
github.com/stackitcloud/stackit-sdk-go/services/intake v0.7.1
github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2 h1:vr4atxFRT+EL+DqON
github.com/stackitcloud/stackit-sdk-go/services/logs v0.5.2/go.mod h1:CAPsiTX7osAImfrG5RnIjaJ/Iz3QpoBKuH2fS346wuQ=
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0 h1:LFIH1wAp633ZAJw/7H3F4nq1DZe0Qu3rlDeXhobZEZA=
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.30.0/go.mod h1:joa89Y1dyn0j22FstRcIKfW2ada3FDxNfttxSvq27uY=
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8 h1:S7t4wcT6SN8ZzdoY8d6VbF903zFpGjzqrU0FN27rJPg=
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8/go.mod h1:CdrhFUsBO7/iJleCc2yQjDChIbG6YaxKNBQRNCjgcF4=
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0 h1:SVd3WMmLAE0Jxk2SaRuM85DTOOXHycyMpZGx9vzqNkI=
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.12.0/go.mod h1:0hHEPiOEMAA23EzEl42Rm3FlyKIzkW+LWLvDkuFTZ+Q=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0 h1:UxnbsKm6PQV8Gudw/EhySaEh9q1xSaTG8mzJz1EvhnE=
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.7.0/go.mod h1:RFL4h6JZvpsyFYbdJ3+eINEkletzJQTfrPdd+yPT/fU=
github.com/stackitcloud/stackit-sdk-go/services/observability v0.17.0 h1:LGwCvvST0fwUgZ6bOxYIfu45qqTgv421ZS07UhKjZL8=
Expand Down
16 changes: 10 additions & 6 deletions internal/cmd/mongodbflex/backup/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/types"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"
mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
Expand Down Expand Up @@ -61,7 +61,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
}

instanceLabel, err := mongoUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region)
instanceLabel, err := mongoUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
instanceLabel = model.InstanceId
Expand All @@ -75,13 +75,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return fmt.Errorf("describe backup for MongoDB Flex instance: %w", err)
}

restoreJobs, err := apiClient.ListRestoreJobs(ctx, model.ProjectId, model.InstanceId, model.Region).Execute()
restoreJobs, err := apiClient.DefaultAPI.ListRestoreJobs(ctx, model.ProjectId, model.InstanceId, model.Region).Execute()
if err != nil {
return fmt.Errorf("get restore jobs for MongoDB Flex instance %q: %w", instanceLabel, err)
}

restoreJobState := mongoUtils.GetRestoreStatus(model.BackupId, restoreJobs)
return outputResult(params.Printer, model.OutputFormat, restoreJobState, *resp.Item)
return outputResult(params.Printer, model.OutputFormat, restoreJobState, resp.Item)
},
}
configureFlags(cmd)
Expand Down Expand Up @@ -114,11 +114,15 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiGetBackupRequest {
req := apiClient.GetBackup(ctx, model.ProjectId, model.InstanceId, model.BackupId, model.Region)
req := apiClient.DefaultAPI.GetBackup(ctx, model.ProjectId, model.InstanceId, model.BackupId, model.Region)
return req
}

func outputResult(p *print.Printer, outputFormat, restoreStatus string, backup mongodbflex.Backup) error {
func outputResult(p *print.Printer, outputFormat, restoreStatus string, backup *mongodbflex.Backup) error {
// allows passing empty backups but avoids having to pass large backup by value

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't quite get the intention of this change here tbh 😅 Can you explain it please?

Even if we decide to keep it, can this be moved into the callback for the pretty output in the p.OutputResult call?

if backup == nil {
backup = &mongodbflex.Backup{}
}
return p.OutputResult(outputFormat, backup, func() error {
table := tables.NewTable()
table.AddRow("ID", utils.PtrString(backup.Id))
Expand Down
12 changes: 6 additions & 6 deletions internal/cmd/mongodbflex/backup/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"
mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api"
)

const (
Expand All @@ -22,7 +22,7 @@ const (
type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &mongodbflex.APIClient{}
var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}}
var testProjectId = uuid.NewString()
var testInstanceId = uuid.NewString()

Expand Down Expand Up @@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *mongodbflex.ApiGetBackupRequest)) mongodbflex.ApiGetBackupRequest {
request := testClient.GetBackup(testCtx, testProjectId, testInstanceId, testBackupId, testRegion)
request := testClient.DefaultAPI.GetBackup(testCtx, testProjectId, testInstanceId, testBackupId, testRegion)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -187,7 +187,7 @@ func TestBuildRequest(t *testing.T) {

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx),
cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
Expand All @@ -199,7 +199,7 @@ func TestBuildRequest(t *testing.T) {
func TestOutputResult(t *testing.T) {
type args struct {
outputFormat string
backup mongodbflex.Backup
backup *mongodbflex.Backup
restoreStatus string
}
tests := []struct {
Expand All @@ -215,7 +215,7 @@ func TestOutputResult(t *testing.T) {
{
name: "set backup",
args: args{
backup: mongodbflex.Backup{},
backup: &mongodbflex.Backup{},
},
wantErr: false,
},
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/mongodbflex/backup/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"
mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api"
)

const (
Expand Down Expand Up @@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
}

instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, *model.InstanceId, model.Region)
instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, *model.InstanceId, model.Region)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
instanceLabel = *model.InstanceId
Expand All @@ -75,9 +75,9 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
if err != nil {
return fmt.Errorf("get backups for MongoDB Flex instance %q: %w", instanceLabel, err)
}
backups := utils.GetSliceFromPointer(resp.Items)
backups := resp.Items

restoreJobs, err := apiClient.ListRestoreJobs(ctx, model.ProjectId, *model.InstanceId, model.Region).Execute()
restoreJobs, err := apiClient.DefaultAPI.ListRestoreJobs(ctx, model.ProjectId, *model.InstanceId, model.Region).Execute()
if err != nil {
return fmt.Errorf("get restore jobs for MongoDB Flex instance %q: %w", instanceLabel, err)
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiListBackupsRequest {
req := apiClient.ListBackups(ctx, model.ProjectId, *model.InstanceId, model.Region)
req := apiClient.DefaultAPI.ListBackups(ctx, model.ProjectId, *model.InstanceId, model.Region)
return req
}

Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/mongodbflex/backup/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"
mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api"
)

const (
Expand All @@ -22,7 +22,7 @@ const (
type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &mongodbflex.APIClient{}
var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}}
var testProjectId = uuid.NewString()
var testInstanceId = uuid.NewString()

Expand Down Expand Up @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *mongodbflex.ApiListBackupsRequest)) mongodbflex.ApiListBackupsRequest {
request := testClient.ListBackups(testCtx, testProjectId, testInstanceId, testRegion)
request := testClient.DefaultAPI.ListBackups(testCtx, testProjectId, testInstanceId, testRegion)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestBuildRequest(t *testing.T) {

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx),
cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/mongodbflex/backup/restore-jobs/restore_jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/types"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"
mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api"

"github.com/stackitcloud/stackit-cli/internal/pkg/args"
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
Expand Down Expand Up @@ -63,7 +63,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
}

instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient, model.ProjectId, *model.InstanceId, model.Region)
instanceLabel, err := mongodbflexUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, *model.InstanceId, model.Region)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
instanceLabel = *model.InstanceId
Expand All @@ -75,11 +75,11 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
if err != nil {
return fmt.Errorf("get restore jobs for MongoDB Flex instance %q: %w", instanceLabel, err)
}
if resp.Items == nil || len(*resp.Items) == 0 {
if len(resp.Items) == 0 {
cmd.Printf("No restore jobs found for instance %q\n", instanceLabel)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can please quick-fix this here directly with the migration: We have an invalid JSON/YAML output here.

See #893 (and the linked PRs in it) for reference.

return nil
}
restoreJobs := *resp.Items
restoreJobs := resp.Items

// Truncate output
if model.Limit != nil && len(restoreJobs) > int(*model.Limit) {
Expand Down Expand Up @@ -127,7 +127,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiListRestoreJobsRequest {
req := apiClient.ListRestoreJobs(ctx, model.ProjectId, *model.InstanceId, model.Region)
req := apiClient.DefaultAPI.ListRestoreJobs(ctx, model.ProjectId, *model.InstanceId, model.Region)
return req
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/google/uuid"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"
mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api"
)

const (
Expand All @@ -22,7 +22,7 @@ const (
type testCtxKey struct{}

var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &mongodbflex.APIClient{}
var testClient = &mongodbflex.APIClient{DefaultAPI: &mongodbflex.DefaultAPIService{}}
var testProjectId = uuid.NewString()
var testInstanceId = uuid.NewString()

Expand Down Expand Up @@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *mongodbflex.ApiListRestoreJobsRequest)) mongodbflex.ApiListRestoreJobsRequest {
request := testClient.ListRestoreJobs(testCtx, testProjectId, testInstanceId, testRegion)
request := testClient.DefaultAPI.ListRestoreJobs(testCtx, testProjectId, testInstanceId, testRegion)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestBuildRequest(t *testing.T) {

diff := cmp.Diff(request, tt.expectedRequest,
cmp.AllowUnexported(tt.expectedRequest),
cmpopts.EquateComparable(testCtx),
cmpopts.EquateComparable(testCtx, mongodbflex.DefaultAPIService{}),
)
if diff != "" {
t.Fatalf("Data does not match: %s", diff)
Expand Down
20 changes: 10 additions & 10 deletions internal/cmd/mongodbflex/backup/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"

"github.com/spf13/cobra"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex"
"github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/wait"
mongodbflex "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api"
wait "github.com/stackitcloud/stackit-sdk-go/services/mongodbflex/v2api/wait"
)

const (
Expand Down Expand Up @@ -71,7 +71,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
return err
}

instanceLabel, err := mongodbUtils.GetInstanceName(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region)
instanceLabel, err := mongodbUtils.GetInstanceName(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region)
if err != nil {
params.Printer.Debug(print.ErrorLevel, "get instance name: %v", err)
instanceLabel = model.ProjectId
Expand Down Expand Up @@ -100,7 +100,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

if !model.Async {
err := spinner.Run(params.Printer, "Restoring instance", func() error {
_, err = wait.RestoreInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId, model.BackupId, model.Region).WaitWithContext(ctx)
_, err = wait.RestoreInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.BackupId, model.Region).WaitWithContext(ctx)
return err
})
if err != nil {
Expand All @@ -125,7 +125,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {

if !model.Async {
err := spinner.Run(params.Printer, "Cloning instance", func() error {
_, err = wait.CloneInstanceWaitHandler(ctx, apiClient, model.ProjectId, model.InstanceId, model.Region).WaitWithContext(ctx)
_, err = wait.CloneInstanceWaitHandler(ctx, apiClient.DefaultAPI, model.ProjectId, model.InstanceId, model.Region).WaitWithContext(ctx)
return err
})
if err != nil {
Expand Down Expand Up @@ -183,19 +183,19 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
}

func buildRestoreRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiRestoreInstanceRequest {
req := apiClient.RestoreInstance(ctx, model.ProjectId, model.InstanceId, model.Region)
req := apiClient.DefaultAPI.RestoreInstance(ctx, model.ProjectId, model.InstanceId, model.Region)
req = req.RestoreInstancePayload(mongodbflex.RestoreInstancePayload{
BackupId: &model.BackupId,
InstanceId: &model.BackupInstanceId,
BackupId: model.BackupId,
InstanceId: model.BackupInstanceId,
})
return req
}

func buildCloneRequest(ctx context.Context, model *inputModel, apiClient *mongodbflex.APIClient) mongodbflex.ApiCloneInstanceRequest {
req := apiClient.CloneInstance(ctx, model.ProjectId, model.InstanceId, model.Region)
req := apiClient.DefaultAPI.CloneInstance(ctx, model.ProjectId, model.InstanceId, model.Region)
req = req.CloneInstancePayload(mongodbflex.CloneInstancePayload{
Timestamp: &model.Timestamp,
InstanceId: &model.BackupInstanceId,
InstanceId: model.BackupInstanceId,
})
return req
}
Expand Down
Loading
Loading