Skip to content
Merged
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_server_os-update_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ stackit server os-update create [flags]

```
Create a Server os-update with name "myupdate"
$ stackit server os-update create --server-id xxx --name=myupdate
$ stackit server os-update create --server-id xxx

Create a Server os-update with name "myupdate" and maintenance window for 13 o'clock.
$ stackit server os-update create --server-id xxx --name=mybupdate --maintenance-window=13
$ stackit server os-update create --server-id xxx --maintenance-window=13
```

### Options
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.0.0
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.11.2
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.6.0
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.5.0
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.0.0
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.6.1
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.0.1
github.com/stackitcloud/stackit-sdk-go/services/ske v0.22.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.11.2 h1:SZoWUD
github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.11.2/go.mod h1:PrD0nNG94Dd5D9pu7HJ0bAg8ccDz6/7KaIts7K9p7as=
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.6.0 h1:cESGAkm0ftADRBfdbiyx3pp/KVQ8JgmUQdRzpwG61wE=
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v0.6.0/go.mod h1:aYPLsiImzWaYXEfYIZ0wJnV56PwcR+buy8Xu9jjbfGA=
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.5.0 h1:TMUxDh8XGgWUpnWo7GsawVq2ICDsy/r8dMlfC26MR5g=
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v0.5.0/go.mod h1:giHnHz3kHeLY8Av9MZLsyJlaTXYz+BuGqdP/SKB5Vo0=
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.0.0 h1:a8logPoRcMCgwa9rCtuzWF6DLiuCIdJgcacZKThFsks=
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.0.0/go.mod h1:zDdYYQVHGlju9cnMISX/Ty73Yh/qYcZGcJSOYWRZCbw=
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.6.1 h1:VKgxgjsbaUVMCnntq+MLQ/c1Emn5crVr11B3gJnyHN4=
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.6.1/go.mod h1:vn6xmMRxYgEoBhYEy6i2SY2qbeDKjs4IVNdnQHcQpBc=
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.0.1 h1:7yY68QuntatwRG6ri65FlfeewACChLVbLp67wHCS8Go=
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/server/os-update/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ func NewCmd(p *print.Printer) *cobra.Command {
Example: examples.Build(
examples.NewExample(
`Create a Server os-update with name "myupdate"`,
`$ stackit server os-update create --server-id xxx --name=myupdate`),
`$ stackit server os-update create --server-id xxx`),
examples.NewExample(
`Create a Server os-update with name "myupdate" and maintenance window for 13 o'clock.`,
`$ stackit server os-update create --server-id xxx --name=mybupdate --maintenance-window=13`),
`$ stackit server os-update create --server-id xxx --maintenance-window=13`),
),
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := context.Background()
Expand Down Expand Up @@ -128,7 +128,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) (serverupdate.ApiCreateUpdateRequest, error) {
req := apiClient.CreateUpdate(ctx, model.ProjectId, model.ServerId)
req := apiClient.CreateUpdate(ctx, model.ProjectId, model.ServerId, model.Region)
payload := serverupdate.CreateUpdatePayload{
MaintenanceWindow: &model.MaintenanceWindow,
}
Expand Down
20 changes: 12 additions & 8 deletions internal/cmd/server/os-update/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"
)

var projectIdFlag = globalflags.ProjectIdFlag
const (
testRegion = "eu02"
)

type testCtxKey struct{}

Expand All @@ -26,9 +28,10 @@ var testServerId = uuid.NewString()

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
serverIdFlag: testServerId,
maintenanceWindowFlag: "13",
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
serverIdFlag: testServerId,
maintenanceWindowFlag: "13",
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -40,6 +43,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ServerId: testServerId,
Expand All @@ -52,7 +56,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *serverupdate.ApiCreateUpdateRequest)) serverupdate.ApiCreateUpdateRequest {
request := testClient.CreateUpdate(testCtx, testProjectId, testServerId)
request := testClient.CreateUpdate(testCtx, testProjectId, testServerId, testRegion)
request = request.CreateUpdatePayload(fixturePayload())
for _, mod := range mods {
mod(&request)
Expand Down Expand Up @@ -102,21 +106,21 @@ func TestParseInput(t *testing.T) {
{
description: "project id missing",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
delete(flagValues, projectIdFlag)
delete(flagValues, globalflags.ProjectIdFlag)
}),
isValid: false,
},
{
description: "project id invalid 1",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[projectIdFlag] = ""
flagValues[globalflags.ProjectIdFlag] = ""
}),
isValid: false,
},
{
description: "project id invalid 2",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[projectIdFlag] = "invalid-uuid"
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
}),
isValid: false,
},
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/server/os-update/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiGetUpdateRequest {
req := apiClient.GetUpdate(ctx, model.ProjectId, model.ServerId, model.UpdateId)
req := apiClient.GetUpdate(ctx, model.ProjectId, model.ServerId, model.UpdateId, model.Region)
return req
}

Expand Down
18 changes: 11 additions & 7 deletions internal/cmd/server/os-update/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"
)

var projectIdFlag = globalflags.ProjectIdFlag
const (
testRegion = "eu02"
)

type testCtxKey struct{}

Expand All @@ -35,8 +37,9 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
serverIdFlag: testServerId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
serverIdFlag: testServerId,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -48,6 +51,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ServerId: testServerId,
Expand All @@ -60,7 +64,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *serverupdate.ApiGetUpdateRequest)) serverupdate.ApiGetUpdateRequest {
request := testClient.GetUpdate(testCtx, testProjectId, testServerId, testUpdateId)
request := testClient.GetUpdate(testCtx, testProjectId, testServerId, testUpdateId, testRegion)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -104,23 +108,23 @@ func TestParseInput(t *testing.T) {
description: "project id missing",
argValues: fixtureArgValues(),
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
delete(flagValues, projectIdFlag)
delete(flagValues, globalflags.ProjectIdFlag)
}),
isValid: false,
},
{
description: "project id invalid 1",
argValues: fixtureArgValues(),
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[projectIdFlag] = ""
flagValues[globalflags.ProjectIdFlag] = ""
}),
isValid: false,
},
{
description: "project id invalid 2",
argValues: fixtureArgValues(),
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[projectIdFlag] = "invalid-uuid"
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
}),
isValid: false,
},
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/server/os-update/disable/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
return &model, nil
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiDisableServiceRequest {
req := apiClient.DisableService(ctx, model.ProjectId, model.ServerId)
func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiDisableServiceResourceRequest {
req := apiClient.DisableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region)
return req
}
20 changes: 12 additions & 8 deletions internal/cmd/server/os-update/disable/disable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"
)

var projectIdFlag = globalflags.ProjectIdFlag
const (
testRegion = "eu02"
)

type testCtxKey struct{}

Expand All @@ -25,7 +27,8 @@ var testServerId = uuid.NewString()

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -37,6 +40,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ServerId: testServerId,
Expand All @@ -47,8 +51,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
return model
}

func fixtureRequest(mods ...func(request *serverupdate.ApiDisableServiceRequest)) serverupdate.ApiDisableServiceRequest {
request := testClient.DisableService(testCtx, testProjectId, testServerId)
func fixtureRequest(mods ...func(request *serverupdate.ApiDisableServiceResourceRequest)) serverupdate.ApiDisableServiceResourceRequest {
request := testClient.DisableServiceResource(testCtx, testProjectId, testServerId, testRegion)
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -78,21 +82,21 @@ func TestParseInput(t *testing.T) {
{
description: "project id missing",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
delete(flagValues, projectIdFlag)
delete(flagValues, globalflags.ProjectIdFlag)
}),
isValid: false,
},
{
description: "project id invalid 1",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[projectIdFlag] = ""
flagValues[globalflags.ProjectIdFlag] = ""
}),
isValid: false,
},
{
description: "project id invalid 2",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[projectIdFlag] = "invalid-uuid"
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
}),
isValid: false,
},
Expand Down Expand Up @@ -148,7 +152,7 @@ func TestBuildRequest(t *testing.T) {
tests := []struct {
description string
model *inputModel
expectedRequest serverupdate.ApiDisableServiceRequest
expectedRequest serverupdate.ApiDisableServiceResourceRequest
}{
{
description: "base",
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/server/os-update/enable/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
return &model, nil
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiEnableServiceRequest {
payload := serverupdate.EnableServicePayload{}
req := apiClient.EnableService(ctx, model.ProjectId, model.ServerId).EnableServicePayload(payload)
func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiEnableServiceResourceRequest {
payload := serverupdate.EnableServiceResourcePayload{}
req := apiClient.EnableServiceResource(ctx, model.ProjectId, model.ServerId, model.Region).EnableServiceResourcePayload(payload)
return req
}
20 changes: 12 additions & 8 deletions internal/cmd/server/os-update/enable/enable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
"github.com/stackitcloud/stackit-sdk-go/services/serverupdate"
)

var projectIdFlag = globalflags.ProjectIdFlag
const (
testRegion = "eu02"
)

type testCtxKey struct{}

Expand All @@ -25,7 +27,8 @@ var testServerId = uuid.NewString()

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -37,6 +40,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ServerId: testServerId,
Expand All @@ -47,8 +51,8 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
return model
}

func fixtureRequest(mods ...func(request *serverupdate.ApiEnableServiceRequest)) serverupdate.ApiEnableServiceRequest {
request := testClient.EnableService(testCtx, testProjectId, testServerId).EnableServicePayload(serverupdate.EnableServicePayload{})
func fixtureRequest(mods ...func(request *serverupdate.ApiEnableServiceResourceRequest)) serverupdate.ApiEnableServiceResourceRequest {
request := testClient.EnableServiceResource(testCtx, testProjectId, testServerId, testRegion).EnableServiceResourcePayload(serverupdate.EnableServiceResourcePayload{})
for _, mod := range mods {
mod(&request)
}
Expand Down Expand Up @@ -78,21 +82,21 @@ func TestParseInput(t *testing.T) {
{
description: "project id missing",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
delete(flagValues, projectIdFlag)
delete(flagValues, globalflags.ProjectIdFlag)
}),
isValid: false,
},
{
description: "project id invalid 1",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[projectIdFlag] = ""
flagValues[globalflags.ProjectIdFlag] = ""
}),
isValid: false,
},
{
description: "project id invalid 2",
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
flagValues[projectIdFlag] = "invalid-uuid"
flagValues[globalflags.ProjectIdFlag] = "invalid-uuid"
}),
isValid: false,
},
Expand Down Expand Up @@ -148,7 +152,7 @@ func TestBuildRequest(t *testing.T) {
tests := []struct {
description string
model *inputModel
expectedRequest serverupdate.ApiEnableServiceRequest
expectedRequest serverupdate.ApiEnableServiceResourceRequest
}{
{
description: "base",
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/server/os-update/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *serverupdate.APIClient) serverupdate.ApiListUpdatesRequest {
req := apiClient.ListUpdates(ctx, model.ProjectId, model.ServerId)
req := apiClient.ListUpdates(ctx, model.ProjectId, model.ServerId, model.Region)
return req
}

Expand Down
Loading