Skip to content

Commit 669a994

Browse files
Merge branch 'main' into feat/STACKITCLI-361-iaas-sdk-migration
2 parents 9529dfd + 9331e88 commit 669a994

23 files changed

Lines changed: 144 additions & 156 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.5.8
2929
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.6
3030
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.3.5
31-
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.23.0
31+
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0
3232
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3
3333
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.14.3
3434
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0 h1:/8lmviszgrB+
636636
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.26.0/go.mod h1:hnhvlLX1Y71R8KIQqLBeoSZqkU5ZJOG0J4wz0LeUdaw=
637637
github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6 h1:CXM9cZ9WeTyJd+Aw/hnJnDsKRVAQi4qgtd0RJ3zoPwo=
638638
github.com/stackitcloud/stackit-sdk-go/services/redis v0.25.6/go.mod h1:KJNceOHRefjku1oVBoHG7idCS/SeW42WJ+55bN3AxrQ=
639-
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.23.0 h1:u2C3oHNcc41Ba5cUqSPuqviDrYSRhpaC5+ELbuHHdwM=
640-
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.23.0/go.mod h1:NEz3f+GV5G++BE9/MmZCsXJyCih7jtg0pZuSyG2sLEs=
639+
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 h1:JPP6a0ME1tZXr4iB69d/LtJsCAr58ENBadFaK9f48/c=
640+
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0/go.mod h1:NEz3f+GV5G++BE9/MmZCsXJyCih7jtg0pZuSyG2sLEs=
641641
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 h1:AiGNJmpQ/f9cglaIQQ4SyePbtCI3K1DQLNvqVN9jKSo=
642642
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3/go.mod h1:U/q0V89fvCF2O1ZJfi68/Chie9YY/5s7xBHI1Klq7wA=
643643
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.14.3 h1:3hZSg3z+4AXa5LbR2Vl38VmSA83ABItE63E53LuyWv8=

internal/cmd/network-area/create/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
103103
var orgLabel string
104104
rmApiClient, err := rmClient.ConfigureClient(params.Printer, params.CliVersion)
105105
if err == nil {
106-
orgLabel, err = rmUtils.GetOrganizationName(ctx, rmApiClient, model.OrganizationId)
106+
orgLabel, err = rmUtils.GetOrganizationName(ctx, rmApiClient.DefaultAPI, model.OrganizationId)
107107
if err != nil {
108108
params.Printer.Debug(print.ErrorLevel, "get organization name: %v", err)
109109
orgLabel = model.OrganizationId

internal/cmd/network-area/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8585
var orgLabel string
8686
rmApiClient, err := rmClient.ConfigureClient(params.Printer, params.CliVersion)
8787
if err == nil {
88-
orgLabel, err = rmUtils.GetOrganizationName(ctx, rmApiClient, model.OrganizationId)
88+
orgLabel, err = rmUtils.GetOrganizationName(ctx, rmApiClient.DefaultAPI, model.OrganizationId)
8989
if err != nil {
9090
params.Printer.Debug(print.ErrorLevel, "get organization name: %v", err)
9191
orgLabel = model.OrganizationId

internal/cmd/network-area/update/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
9292
var orgLabel string
9393
rmApiClient, err := rmClient.ConfigureClient(params.Printer, params.CliVersion)
9494
if err == nil {
95-
orgLabel, err = rmUtils.GetOrganizationName(ctx, rmApiClient, *model.OrganizationId)
95+
orgLabel, err = rmUtils.GetOrganizationName(ctx, rmApiClient.DefaultAPI, *model.OrganizationId)
9696
if err != nil {
9797
params.Printer.Debug(print.ErrorLevel, "get organization name: %v", err)
9898
orgLabel = *model.OrganizationId

internal/cmd/organization/describe/describe.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
88

99
"github.com/spf13/cobra"
10-
"github.com/stackitcloud/stackit-sdk-go/services/resourcemanager"
10+
resourcemanager "github.com/stackitcloud/stackit-sdk-go/services/resourcemanager/v0api"
1111

1212
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1313
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
@@ -84,7 +84,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
8484
}
8585

8686
func buildRequest(ctx context.Context, model *inputModel, apiClient *resourcemanager.APIClient) resourcemanager.ApiGetOrganizationRequest {
87-
req := apiClient.GetOrganization(ctx, model.OrganizationId)
87+
req := apiClient.DefaultAPI.GetOrganization(ctx, model.OrganizationId)
8888
return req
8989
}
9090

@@ -97,17 +97,17 @@ func outputResult(p *print.Printer, outputFormat string, organization *resourcem
9797

9898
table := tables.NewTable()
9999

100-
table.AddRow("ORGANIZATION ID", utils.PtrString(organization.OrganizationId))
100+
table.AddRow("ORGANIZATION ID", organization.OrganizationId)
101101
table.AddSeparator()
102-
table.AddRow("NAME", utils.PtrString(organization.Name))
102+
table.AddRow("NAME", organization.Name)
103103
table.AddSeparator()
104-
table.AddRow("CONTAINER ID", utils.PtrString(organization.ContainerId))
104+
table.AddRow("CONTAINER ID", organization.ContainerId)
105105
table.AddSeparator()
106-
table.AddRow("STATUS", utils.PtrString(organization.LifecycleState))
106+
table.AddRow("STATUS", organization.LifecycleState)
107107
table.AddSeparator()
108-
table.AddRow("CREATION TIME", utils.PtrString(organization.CreationTime))
108+
table.AddRow("CREATION TIME", organization.CreationTime)
109109
table.AddSeparator()
110-
table.AddRow("UPDATE TIME", utils.PtrString(organization.UpdateTime))
110+
table.AddRow("UPDATE TIME", organization.UpdateTime)
111111
table.AddSeparator()
112112
table.AddRow("LABELS", utils.JoinStringMap(utils.PtrValue(organization.Labels), ": ", ", "))
113113

internal/cmd/organization/describe/describe_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import (
1414
"github.com/google/go-cmp/cmp"
1515
"github.com/google/go-cmp/cmp/cmpopts"
1616
"github.com/google/uuid"
17-
"github.com/stackitcloud/stackit-sdk-go/services/resourcemanager"
17+
resourcemanager "github.com/stackitcloud/stackit-sdk-go/services/resourcemanager/v0api"
1818
)
1919

2020
type testCtxKey struct{}
2121

2222
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
23-
var testClient = &resourcemanager.APIClient{}
23+
var testClient = &resourcemanager.APIClient{DefaultAPI: &resourcemanager.DefaultAPIService{}}
2424

2525
var (
2626
testOrganizationId = uuid.NewString()
@@ -50,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5050
}
5151

5252
func fixtureRequest(mods ...func(request *resourcemanager.ApiGetOrganizationRequest)) resourcemanager.ApiGetOrganizationRequest {
53-
request := testClient.GetOrganization(testCtx, testOrganizationId)
53+
request := testClient.DefaultAPI.GetOrganization(testCtx, testOrganizationId)
5454
for _, mod := range mods {
5555
mod(&request)
5656
}
@@ -120,7 +120,7 @@ func TestBuildRequest(t *testing.T) {
120120

121121
diff := cmp.Diff(request, tt.expectedRequest,
122122
cmp.AllowUnexported(tt.expectedRequest),
123-
cmpopts.EquateComparable(testCtx),
123+
cmpopts.EquateComparable(testCtx, resourcemanager.DefaultAPIService{}),
124124
)
125125
if diff != "" {
126126
t.Fatalf("Data does not match: %s", diff)
@@ -162,12 +162,12 @@ func TestOutputResult(t *testing.T) {
162162
name: "full response",
163163
args: args{
164164
organization: utils.Ptr(resourcemanager.OrganizationResponse{
165-
OrganizationId: utils.Ptr(uuid.NewString()),
166-
Name: utils.Ptr("foo bar"),
167-
LifecycleState: utils.Ptr(resourcemanager.LIFECYCLESTATE_ACTIVE),
168-
ContainerId: utils.Ptr("foo-bar-organization"),
169-
CreationTime: utils.Ptr(time.Now()),
170-
UpdateTime: utils.Ptr(time.Now()),
165+
OrganizationId: uuid.NewString(),
166+
Name: "foo bar",
167+
LifecycleState: resourcemanager.LIFECYCLESTATE_ACTIVE,
168+
ContainerId: "foo-bar-organization",
169+
CreationTime: time.Now(),
170+
UpdateTime: time.Now(),
171171
Labels: utils.Ptr(map[string]string{
172172
"foo": "true",
173173
"bar": "false",

internal/cmd/organization/list/list.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
1010

1111
"github.com/spf13/cobra"
12-
"github.com/stackitcloud/stackit-sdk-go/services/resourcemanager"
12+
resourcemanager "github.com/stackitcloud/stackit-sdk-go/services/resourcemanager/v0api"
1313

1414
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1515
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -19,7 +19,6 @@ import (
1919
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
2020
"github.com/stackitcloud/stackit-cli/internal/pkg/services/resourcemanager/client"
2121
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
22-
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
2322
)
2423

2524
const (
@@ -78,7 +77,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7877
return fmt.Errorf("list organizations: empty response")
7978
}
8079

81-
return outputResult(params.Printer, model.OutputFormat, utils.PtrValue(resp.Items))
80+
return outputResult(params.Printer, model.OutputFormat, resp.Items)
8281
},
8382
}
8483
configureFlags(cmd)
@@ -110,7 +109,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
110109
}
111110

112111
func buildRequest(ctx context.Context, model *inputModel, apiClient *resourcemanager.APIClient) resourcemanager.ApiListOrganizationsRequest {
113-
req := apiClient.ListOrganizations(ctx)
112+
req := apiClient.DefaultAPI.ListOrganizations(ctx)
114113
req = req.Member(model.Member)
115114
if model.Limit != nil {
116115
req = req.Limit(float32(*model.Limit))
@@ -130,9 +129,9 @@ func outputResult(p *print.Printer, outputFormat string, organizations []resourc
130129

131130
for _, organization := range organizations {
132131
table.AddRow(
133-
utils.PtrString(organization.OrganizationId),
134-
utils.PtrString(organization.Name),
135-
utils.PtrString(organization.ContainerId),
132+
organization.OrganizationId,
133+
organization.Name,
134+
organization.ContainerId,
136135
)
137136
table.AddSeparator()
138137
}

internal/cmd/organization/list/list_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import (
1212

1313
"github.com/google/go-cmp/cmp"
1414
"github.com/google/go-cmp/cmp/cmpopts"
15-
"github.com/stackitcloud/stackit-sdk-go/services/resourcemanager"
15+
resourcemanager "github.com/stackitcloud/stackit-sdk-go/services/resourcemanager/v0api"
1616
)
1717

1818
type testCtxKey struct{}
1919

2020
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
21-
var testClient = &resourcemanager.APIClient{}
21+
var testClient = &resourcemanager.APIClient{DefaultAPI: &resourcemanager.DefaultAPIService{}}
2222

2323
const (
2424
testEmail = "foo@bar"
@@ -27,7 +27,7 @@ const (
2727

2828
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
2929
flagValues := map[string]string{
30-
limitFlag: strconv.Itoa(int(testLimit)),
30+
limitFlag: strconv.Itoa(testLimit),
3131
}
3232
for _, mod := range mods {
3333
mod(flagValues)
@@ -50,7 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5050
}
5151

5252
func fixtureRequest(mods ...func(request *resourcemanager.ApiListOrganizationsRequest)) resourcemanager.ApiListOrganizationsRequest {
53-
request := testClient.ListOrganizations(testCtx)
53+
request := testClient.DefaultAPI.ListOrganizations(testCtx)
5454
request = request.Limit(testLimit)
5555
request = request.Member(testEmail)
5656
for _, mod := range mods {
@@ -128,7 +128,7 @@ func TestBuildRequest(t *testing.T) {
128128
model.Member = ""
129129
model.Limit = nil
130130
}),
131-
expectedRequest: testClient.ListOrganizations(testCtx).Member(""),
131+
expectedRequest: testClient.DefaultAPI.ListOrganizations(testCtx).Member(""),
132132
},
133133
}
134134

@@ -138,7 +138,7 @@ func TestBuildRequest(t *testing.T) {
138138

139139
diff := cmp.Diff(request, tt.expectedRequest,
140140
cmp.AllowUnexported(tt.expectedRequest),
141-
cmpopts.EquateComparable(testCtx),
141+
cmpopts.EquateComparable(testCtx, resourcemanager.DefaultAPIService{}),
142142
)
143143
if diff != "" {
144144
t.Fatalf("Data does not match: %s", diff)

internal/cmd/project/create/create.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ import (
1515
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1616
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1717
"github.com/stackitcloud/stackit-cli/internal/pkg/services/resourcemanager/client"
18-
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1918

2019
"github.com/spf13/cobra"
21-
"github.com/stackitcloud/stackit-sdk-go/services/resourcemanager"
20+
resourcemanager "github.com/stackitcloud/stackit-sdk-go/services/resourcemanager/v0api"
2221
)
2322

2423
const (
@@ -35,8 +34,8 @@ const (
3534

3635
type inputModel struct {
3736
*globalflags.GlobalFlagModel
38-
ParentId *string
39-
Name *string
37+
ParentId string
38+
Name string
4039
Labels *map[string]string
4140
NetworkAreaId *string
4241
}
@@ -77,7 +76,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
7776
return err
7877
}
7978

80-
prompt := fmt.Sprintf("Are you sure you want to create a project under the parent with ID %q?", *model.ParentId)
79+
prompt := fmt.Sprintf("Are you sure you want to create a project under the parent with ID %q?", model.ParentId)
8180
err = params.Printer.PromptForConfirmation(prompt)
8281
if err != nil {
8382
return err
@@ -136,8 +135,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
136135

137136
model := inputModel{
138137
GlobalFlagModel: globalFlags,
139-
ParentId: flags.FlagToStringPointer(p, cmd, parentIdFlag),
140-
Name: flags.FlagToStringPointer(p, cmd, nameFlag),
138+
ParentId: flags.FlagToStringValue(p, cmd, parentIdFlag),
139+
Name: flags.FlagToStringValue(p, cmd, nameFlag),
141140
Labels: labels,
142141
NetworkAreaId: flags.FlagToStringPointer(p, cmd, networkAreaIdFlag),
143142
}
@@ -147,7 +146,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
147146
}
148147

149148
func buildRequest(ctx context.Context, model *inputModel, apiClient *resourcemanager.APIClient) (resourcemanager.ApiCreateProjectRequest, error) {
150-
req := apiClient.CreateProject(ctx)
149+
req := apiClient.DefaultAPI.CreateProject(ctx)
151150

152151
authFlow, err := auth.GetAuthFlow()
153152
if err != nil {
@@ -191,10 +190,10 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *resourceman
191190
ContainerParentId: model.ParentId,
192191
Name: model.Name,
193192
Labels: labels,
194-
Members: &[]resourcemanager.Member{
193+
Members: []resourcemanager.Member{
195194
{
196-
Role: utils.Ptr(ownerRole),
197-
Subject: utils.Ptr(email),
195+
Role: ownerRole,
196+
Subject: email,
198197
},
199198
},
200199
})
@@ -210,7 +209,7 @@ func outputResult(p *print.Printer, model inputModel, resp *resourcemanager.Proj
210209
return fmt.Errorf("globalflags are empty")
211210
}
212211
return p.OutputResult(model.OutputFormat, resp, func() error {
213-
p.Outputf("Created project under the parent with ID %q. Project ID: %s\n", utils.PtrString(model.ParentId), utils.PtrString(resp.ProjectId))
212+
p.Outputf("Created project under the parent with ID %q. Project ID: %s\n", model.ParentId, resp.ProjectId)
214213
return nil
215214
})
216215
}

0 commit comments

Comments
 (0)