Skip to content

Commit 93c956c

Browse files
committed
chore(runcommand): switch to new sdk structure
relates to STACKITCLI-354
1 parent eb09bc8 commit 93c956c

13 files changed

Lines changed: 43 additions & 47 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
github.com/stackitcloud/stackit-sdk-go/services/opensearch v1.1.0
3030
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.11.0
3131
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0
32-
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3
32+
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0
3333
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1
3434
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8
3535
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0 h1:ckYMRXAGE2/vaxPe
634634
github.com/stackitcloud/stackit-sdk-go/services/redis v1.1.0/go.mod h1:yjej6QfYoYdRIyKXlmbVz8fZYxbuUdl+QBkvLDPgA4k=
635635
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0 h1:JPP6a0ME1tZXr4iB69d/LtJsCAr58ENBadFaK9f48/c=
636636
github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.24.0/go.mod h1:NEz3f+GV5G++BE9/MmZCsXJyCih7jtg0pZuSyG2sLEs=
637-
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3 h1:AiGNJmpQ/f9cglaIQQ4SyePbtCI3K1DQLNvqVN9jKSo=
638-
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.4.3/go.mod h1:U/q0V89fvCF2O1ZJfi68/Chie9YY/5s7xBHI1Klq7wA=
637+
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0 h1:T5gy5i+NxrpJPYDEJNjGjljhfD7PWTFia7us8A4mL/c=
638+
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.8.0/go.mod h1:iB27HtF0UcAugURc9w+nlNrtbAj7Mukw/ptAz+7p2WE=
639639
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1 h1:U5rstX5e6Am2t+Ukv5K1Sbftzxt5aFALMa9YS4jCJoo=
640640
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.18.1/go.mod h1:2XA8PE05Qg6BL2YXO4XgfGI9qskJ3cicLE5Qq0aqDdY=
641641
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.8 h1:LLyANBzE8sQa0/49tQBqq4sVLhNgwdqCeQm76srJHWw=

internal/cmd/server/command/create/create.go

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

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

1414
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1515
cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -135,9 +135,9 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
135135
}
136136

137137
func buildRequest(ctx context.Context, model *inputModel, apiClient *runcommand.APIClient) (runcommand.ApiCreateCommandRequest, error) {
138-
req := apiClient.CreateCommand(ctx, model.ProjectId, model.ServerId, model.Region)
138+
req := apiClient.DefaultAPI.CreateCommand(ctx, model.ProjectId, model.ServerId, model.Region)
139139
req = req.CreateCommandPayload(runcommand.CreateCommandPayload{
140-
CommandTemplateName: &model.CommandTemplateName,
140+
CommandTemplateName: model.CommandTemplateName,
141141
Parameters: model.Params,
142142
})
143143
return req, nil

internal/cmd/server/command/create/create_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,19 @@ import (
44
"context"
55
"testing"
66

7-
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
8-
"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
9-
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
10-
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
11-
127
"github.com/google/go-cmp/cmp"
138
"github.com/google/go-cmp/cmp/cmpopts"
149
"github.com/google/uuid"
15-
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"
10+
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
11+
"github.com/stackitcloud/stackit-cli/internal/pkg/testparams"
12+
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
13+
runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api"
1614
)
1715

1816
type testCtxKey struct{}
1917

2018
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
21-
var testClient = &runcommand.APIClient{}
19+
var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}}
2220

2321
var testProjectId = uuid.NewString()
2422
var testServerId = uuid.NewString()
@@ -59,7 +57,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5957
}
6058

6159
func fixtureRequest(mods ...func(request *runcommand.ApiCreateCommandRequest)) runcommand.ApiCreateCommandRequest {
62-
request := testClient.CreateCommand(testCtx, testProjectId, testServerId, testRegion)
60+
request := testClient.DefaultAPI.CreateCommand(testCtx, testProjectId, testServerId, testRegion)
6361
request = request.CreateCommandPayload(fixturePayload())
6462
for _, mod := range mods {
6563
mod(&request)
@@ -69,7 +67,7 @@ func fixtureRequest(mods ...func(request *runcommand.ApiCreateCommandRequest)) r
6967

7068
func fixturePayload(mods ...func(payload *runcommand.CreateCommandPayload)) runcommand.CreateCommandPayload {
7169
payload := runcommand.CreateCommandPayload{
72-
CommandTemplateName: utils.Ptr("RunShellScript"),
70+
CommandTemplateName: "RunShellScript",
7371
Parameters: &map[string]string{"script": "'echo hello'"},
7472
}
7573
for _, mod := range mods {
@@ -170,7 +168,7 @@ func TestBuildRequest(t *testing.T) {
170168

171169
diff := cmp.Diff(request, tt.expectedRequest,
172170
cmp.AllowUnexported(tt.expectedRequest),
173-
cmpopts.EquateComparable(testCtx),
171+
cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}),
174172
)
175173
if diff != "" {
176174
t.Fatalf("Data does not match: %s", diff)

internal/cmd/server/command/describe/describe.go

Lines changed: 2 additions & 2 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/runcommand"
10+
runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api"
1111

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

9999
func buildRequest(ctx context.Context, model *inputModel, apiClient *runcommand.APIClient) runcommand.ApiGetCommandRequest {
100-
req := apiClient.GetCommand(ctx, model.ProjectId, model.Region, model.ServerId, model.CommandId)
100+
req := apiClient.DefaultAPI.GetCommand(ctx, model.ProjectId, model.Region, model.ServerId, model.CommandId)
101101
return req
102102
}
103103

internal/cmd/server/command/describe/describe_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
"github.com/google/go-cmp/cmp"
1212
"github.com/google/go-cmp/cmp/cmpopts"
1313
"github.com/google/uuid"
14-
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"
14+
runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api"
1515
)
1616

1717
type testCtxKey struct{}
1818

1919
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
20-
var testClient = &runcommand.APIClient{}
20+
var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}}
2121
var testProjectId = uuid.NewString()
2222
var testServerId = uuid.NewString()
2323

@@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6565
}
6666

6767
func fixtureRequest(mods ...func(request *runcommand.ApiGetCommandRequest)) runcommand.ApiGetCommandRequest {
68-
request := testClient.GetCommand(testCtx, testProjectId, testRegion, testServerId, testCommandId)
68+
request := testClient.DefaultAPI.GetCommand(testCtx, testProjectId, testRegion, testServerId, testCommandId)
6969
for _, mod := range mods {
7070
mod(&request)
7171
}
@@ -189,7 +189,7 @@ func TestBuildRequest(t *testing.T) {
189189

190190
diff := cmp.Diff(request, tt.expectedRequest,
191191
cmp.AllowUnexported(tt.expectedRequest),
192-
cmpopts.EquateComparable(testCtx),
192+
cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}),
193193
)
194194
if diff != "" {
195195
t.Fatalf("Data does not match: %s", diff)

internal/cmd/server/command/list/list.go

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

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

1414
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1515
"github.com/stackitcloud/stackit-cli/internal/pkg/errors"
@@ -125,7 +125,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
125125
}
126126

127127
func buildRequest(ctx context.Context, model *inputModel, apiClient *runcommand.APIClient) runcommand.ApiListCommandsRequest {
128-
req := apiClient.ListCommands(ctx, model.ProjectId, model.ServerId, model.Region)
128+
req := apiClient.DefaultAPI.ListCommands(ctx, model.ProjectId, model.ServerId, model.Region)
129129
return req
130130
}
131131

internal/cmd/server/command/list/list_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import (
1212
"github.com/google/go-cmp/cmp"
1313
"github.com/google/go-cmp/cmp/cmpopts"
1414
"github.com/google/uuid"
15-
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"
15+
runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api"
1616
)
1717

1818
type testCtxKey struct{}
1919

2020
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
21-
var testClient = &runcommand.APIClient{}
21+
var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}}
2222
var testProjectId = uuid.NewString()
2323
var testServerId = uuid.NewString()
2424

@@ -56,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5656
}
5757

5858
func fixtureRequest(mods ...func(request *runcommand.ApiListCommandsRequest)) runcommand.ApiListCommandsRequest {
59-
request := testClient.ListCommands(testCtx, testProjectId, testServerId, testRegion)
59+
request := testClient.DefaultAPI.ListCommands(testCtx, testProjectId, testServerId, testRegion)
6060
for _, mod := range mods {
6161
mod(&request)
6262
}
@@ -145,7 +145,7 @@ func TestBuildRequest(t *testing.T) {
145145

146146
diff := cmp.Diff(request, tt.expectedRequest,
147147
cmp.AllowUnexported(tt.expectedRequest),
148-
cmpopts.EquateComparable(testCtx),
148+
cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}),
149149
)
150150
if diff != "" {
151151
t.Fatalf("Data does not match: %s", diff)

internal/cmd/server/command/template/describe/describe.go

Lines changed: 3 additions & 3 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/runcommand"
10+
runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api"
1111

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

9999
func buildRequest(ctx context.Context, model *inputModel, apiClient *runcommand.APIClient) runcommand.ApiGetCommandTemplateRequest {
100-
req := apiClient.GetCommandTemplate(ctx, model.ProjectId, model.ServerId, model.CommandTemplateName, model.Region)
100+
req := apiClient.DefaultAPI.GetCommandTemplate(ctx, model.ProjectId, model.ServerId, model.CommandTemplateName, model.Region)
101101
return req
102102
}
103103

@@ -111,7 +111,7 @@ func outputResult(p *print.Printer, outputFormat string, commandTemplate runcomm
111111
table.AddRow("DESCRIPTION", utils.PtrString(commandTemplate.Description))
112112
table.AddSeparator()
113113
if commandTemplate.OsType != nil {
114-
table.AddRow("OS TYPE", utils.JoinStringPtr(commandTemplate.OsType, "\n"))
114+
table.AddRow("OS TYPE", utils.JoinStringPtr(&commandTemplate.OsType, "\n"))
115115
table.AddSeparator()
116116
}
117117
if commandTemplate.ParametersSchema != nil {

internal/cmd/server/command/template/describe/describe_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111
"github.com/google/go-cmp/cmp"
1212
"github.com/google/go-cmp/cmp/cmpopts"
1313
"github.com/google/uuid"
14-
"github.com/stackitcloud/stackit-sdk-go/services/runcommand"
14+
runcommand "github.com/stackitcloud/stackit-sdk-go/services/runcommand/v2api"
1515
)
1616

1717
type testCtxKey struct{}
1818

1919
var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
20-
var testClient = &runcommand.APIClient{}
20+
var testClient = &runcommand.APIClient{DefaultAPI: &runcommand.DefaultAPIService{}}
2121
var testProjectId = uuid.NewString()
2222
var testServerId = uuid.NewString()
2323

@@ -65,7 +65,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6565
}
6666

6767
func fixtureRequest(mods ...func(request *runcommand.ApiGetCommandTemplateRequest)) runcommand.ApiGetCommandTemplateRequest {
68-
request := testClient.GetCommandTemplate(testCtx, testProjectId, testServerId, testCommandTemplateName, testRegion)
68+
request := testClient.DefaultAPI.GetCommandTemplate(testCtx, testProjectId, testServerId, testCommandTemplateName, testRegion)
6969
for _, mod := range mods {
7070
mod(&request)
7171
}
@@ -189,7 +189,7 @@ func TestBuildRequest(t *testing.T) {
189189

190190
diff := cmp.Diff(request, tt.expectedRequest,
191191
cmp.AllowUnexported(tt.expectedRequest),
192-
cmpopts.EquateComparable(testCtx),
192+
cmpopts.EquateComparable(testCtx, runcommand.DefaultAPIService{}),
193193
)
194194
if diff != "" {
195195
t.Fatalf("Data does not match: %s", diff)

0 commit comments

Comments
 (0)