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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.2.0
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.9.0
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.1
github.com/stackitcloud/stackit-sdk-go/services/ske v0.27.0
github.com/stackitcloud/stackit-sdk-go/services/ske v1.0.0
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.0
github.com/zalando/go-keyring v0.2.6
golang.org/x/mod v0.25.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.9.0 h1:2d28WFQ
github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.9.0/go.mod h1:t77MA8uyEU9KZd1On5JpnxI3xhVPKIS8WutStqvU8Cw=
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.1 h1:h1TsWatlsexLeKdkb3L8chcxaXJOy/cLXctsRxhb4xg=
github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.1/go.mod h1:M4xZ2BnmROvLV2MrAP6A8o9BnyT0CkvpEcP8lBOfRs8=
github.com/stackitcloud/stackit-sdk-go/services/ske v0.27.0 h1:bwLmLXvtCl1XkPRP+YrXwfz+lBMaGWH/crlNbYtxeqE=
github.com/stackitcloud/stackit-sdk-go/services/ske v0.27.0/go.mod h1:V09NmPahuUiuZEogVPgxuVqqti0th5B7TVAjuiM09mE=
github.com/stackitcloud/stackit-sdk-go/services/ske v1.0.0 h1:PX8VTo2UhPd6BeEaCHFlpIkDbk9OFQEO6eJJ8JkxesA=
github.com/stackitcloud/stackit-sdk-go/services/ske v1.0.0/go.mod h1:V09NmPahuUiuZEogVPgxuVqqti0th5B7TVAjuiM09mE=
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.0 h1:pUl/981oAXPnZd7++69NfEWv6JwW9UpxER16XxQUdOk=
github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.3.0/go.mod h1:S04/QsQrB2EgYGjl62BO+9QUswrlRBoBosigrhdmccM=
github.com/stbenjam/no-sprintf-host-port v0.2.0 h1:i8pxvGrt1+4G0czLr/WnmyH7zbZ8Bg8etvARQ1rpyl4=
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/ske/cluster/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
}

// Check if cluster exists
exists, err := skeUtils.ClusterExists(ctx, apiClient, model.ProjectId, model.ClusterName)
exists, err := skeUtils.ClusterExists(ctx, apiClient, model.ProjectId, model.Region, model.ClusterName)
if err != nil {
return err
}
Expand All @@ -118,7 +118,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {

// Fill in default payload, if needed
if model.Payload == nil {
defaultPayload, err := skeUtils.GetDefaultPayload(ctx, apiClient)
defaultPayload, err := skeUtils.GetDefaultPayload(ctx, apiClient, model.Region)
if err != nil {
return fmt.Errorf("get default payload: %w", err)
}
Expand All @@ -137,7 +137,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Creating cluster")
_, err = wait.CreateOrUpdateClusterWaitHandler(ctx, apiClient, model.ProjectId, name).WaitWithContext(ctx)
_, err = wait.CreateOrUpdateClusterWaitHandler(ctx, apiClient, model.ProjectId, model.Region, name).WaitWithContext(ctx)
if err != nil {
return fmt.Errorf("wait for SKE cluster creation: %w", err)
}
Expand Down Expand Up @@ -192,7 +192,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiCreateOrUpdateClusterRequest {
req := apiClient.CreateOrUpdateCluster(ctx, model.ProjectId, model.ClusterName)
req := apiClient.CreateOrUpdateCluster(ctx, model.ProjectId, model.Region, model.ClusterName)

req = req.CreateOrUpdateClusterPayload(*model.Payload)
return req
Expand Down
8 changes: 6 additions & 2 deletions internal/cmd/ske/cluster/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var testClient = &ske.APIClient{}
var testProjectId = uuid.NewString()
var testClusterName = "cluster"

const testRegion = "eu01"

var testPayload = &ske.CreateOrUpdateClusterPayload{
Kubernetes: &ske.Kubernetes{
Version: utils.Ptr("1.25.15"),
Expand Down Expand Up @@ -81,7 +83,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
payloadFlag: fmt.Sprintf(`{
"name": "cli-jp",
"kubernetes": {
Expand Down Expand Up @@ -128,6 +131,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ClusterName: testClusterName,
Expand All @@ -140,7 +144,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *ske.ApiCreateOrUpdateClusterRequest)) ske.ApiCreateOrUpdateClusterRequest {
request := testClient.CreateOrUpdateCluster(testCtx, testProjectId, fixtureInputModel().ClusterName)
request := testClient.CreateOrUpdateCluster(testCtx, testProjectId, testRegion, fixtureInputModel().ClusterName)
request = request.CreateOrUpdateClusterPayload(*testPayload)
for _, mod := range mods {
mod(&request)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/ske/cluster/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Deleting cluster")
_, err = wait.DeleteClusterWaitHandler(ctx, apiClient, model.ProjectId, model.ClusterName).WaitWithContext(ctx)
_, err = wait.DeleteClusterWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ClusterName).WaitWithContext(ctx)
if err != nil {
return fmt.Errorf("wait for SKE cluster deletion: %w", err)
}
Expand Down Expand Up @@ -114,6 +114,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiDeleteClusterRequest {
req := apiClient.DeleteCluster(ctx, model.ProjectId, model.ClusterName)
req := apiClient.DeleteCluster(ctx, model.ProjectId, model.Region, model.ClusterName)
return req
}
8 changes: 6 additions & 2 deletions internal/cmd/ske/cluster/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var testClient = &ske.APIClient{}
var testProjectId = uuid.NewString()
var testClusterName = "cluster"

const testRegion = "eu01"

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

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 @@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ClusterName: testClusterName,
Expand All @@ -58,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *ske.ApiDeleteClusterRequest)) ske.ApiDeleteClusterRequest {
request := testClient.DeleteCluster(testCtx, testProjectId, testClusterName)
request := testClient.DeleteCluster(testCtx, testProjectId, testRegion, testClusterName)
for _, mod := range mods {
mod(&request)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/ske/cluster/describe/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiGetClusterRequest {
req := apiClient.GetCluster(ctx, model.ProjectId, model.ClusterName)
req := apiClient.GetCluster(ctx, model.ProjectId, model.Region, model.ClusterName)
return req
}

Expand Down
8 changes: 6 additions & 2 deletions internal/cmd/ske/cluster/describe/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var testClient = &ske.APIClient{}
var testProjectId = uuid.NewString()
var testClusterName = "cluster"

const testRegion = "eu01"

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

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 @@ -47,6 +50,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ClusterName: testClusterName,
Expand All @@ -58,7 +62,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *ske.ApiGetClusterRequest)) ske.ApiGetClusterRequest {
request := testClient.GetCluster(testCtx, testProjectId, testClusterName)
request := testClient.GetCluster(testCtx, testProjectId, testRegion, testClusterName)
for _, mod := range mods {
mod(&request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {

var payload *ske.CreateOrUpdateClusterPayload
if model.ClusterName == nil {
payload, err = skeUtils.GetDefaultPayload(ctx, apiClient)
payload, err = skeUtils.GetDefaultPayload(ctx, apiClient, model.Region)
if err != nil {
return err
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiGetClusterRequest {
req := apiClient.GetCluster(ctx, model.ProjectId, *model.ClusterName)
req := apiClient.GetCluster(ctx, model.ProjectId, model.Region, *model.ClusterName)
return req
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ const (
testFilePath = "example-file"
)

const testRegion = "eu01"

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
clusterNameFlag: testClusterName,
filePathFlag: testFilePath,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
clusterNameFlag: testClusterName,
filePathFlag: testFilePath,
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -44,6 +47,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ClusterName: utils.Ptr(testClusterName),
Expand All @@ -56,7 +60,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *ske.ApiGetClusterRequest)) ske.ApiGetClusterRequest {
request := testClient.GetCluster(testCtx, testProjectId, testClusterName)
request := testClient.GetCluster(testCtx, testProjectId, testRegion, testClusterName)
for _, mod := range mods {
mod(&request)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/ske/cluster/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiListClustersRequest {
req := apiClient.ListClusters(ctx, model.ProjectId)
req := apiClient.ListClusters(ctx, model.ProjectId, model.Region)
return req
}

Expand Down Expand Up @@ -172,7 +172,7 @@ func outputResult(p *print.Printer, outputFormat string, clusters []ske.Cluster)
for i := range clusters {
c := clusters[i]
monitoring := "Disabled"
if c.Extensions != nil && c.Extensions.Argus != nil && *c.Extensions.Argus.Enabled {
if c.Extensions != nil && c.Extensions.Observability != nil && *c.Extensions.Observability.Enabled {
monitoring = "Enabled"
}
statusAggregated, kubernetesVersion := "", ""
Expand Down
10 changes: 7 additions & 3 deletions internal/cmd/ske/cluster/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ var testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
var testClient = &ske.APIClient{}
var testProjectId = uuid.NewString()

const testRegion = "eu01"

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
limitFlag: "10",
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
limitFlag: "10",
}
for _, mod := range mods {
mod(flagValues)
Expand All @@ -39,6 +42,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
Limit: utils.Ptr(int64(10)),
Expand All @@ -50,7 +54,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *ske.ApiListClustersRequest)) ske.ApiListClustersRequest {
request := testClient.ListClusters(testCtx, testProjectId)
request := testClient.ListClusters(testCtx, testProjectId, testRegion)
for _, mod := range mods {
mod(&request)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/ske/cluster/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
}

// Check if cluster exists
exists, err := skeUtils.ClusterExists(ctx, apiClient, model.ProjectId, model.ClusterName)
exists, err := skeUtils.ClusterExists(ctx, apiClient, model.ProjectId, model.Region, model.ClusterName)
if err != nil {
return err
}
Expand All @@ -99,7 +99,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Updating cluster")
_, err = wait.CreateOrUpdateClusterWaitHandler(ctx, apiClient, model.ProjectId, name).WaitWithContext(ctx)
_, err = wait.CreateOrUpdateClusterWaitHandler(ctx, apiClient, model.ProjectId, model.Region, name).WaitWithContext(ctx)
if err != nil {
return fmt.Errorf("wait for SKE cluster update: %w", err)
}
Expand Down Expand Up @@ -154,7 +154,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiCreateOrUpdateClusterRequest {
req := apiClient.CreateOrUpdateCluster(ctx, model.ProjectId, model.ClusterName)
req := apiClient.CreateOrUpdateCluster(ctx, model.ProjectId, model.Region, model.ClusterName)

req = req.CreateOrUpdateClusterPayload(model.Payload)
return req
Expand Down
8 changes: 6 additions & 2 deletions internal/cmd/ske/cluster/update/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var testClient = &ske.APIClient{}
var testProjectId = uuid.NewString()
var testClusterName = "cluster"

const testRegion = "eu01"

var testPayload = ske.CreateOrUpdateClusterPayload{
Kubernetes: &ske.Kubernetes{
Version: utils.Ptr("1.25.15"),
Expand Down Expand Up @@ -81,7 +83,8 @@ func fixtureArgValues(mods ...func(argValues []string)) []string {

func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {
flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
payloadFlag: fmt.Sprintf(`{
"name": "cli-jp",
"kubernetes": {
Expand Down Expand Up @@ -128,6 +131,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{
ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,
},
ClusterName: testClusterName,
Expand All @@ -140,7 +144,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
}

func fixtureRequest(mods ...func(request *ske.ApiCreateOrUpdateClusterRequest)) ske.ApiCreateOrUpdateClusterRequest {
request := testClient.CreateOrUpdateCluster(testCtx, testProjectId, fixtureInputModel().ClusterName)
request := testClient.CreateOrUpdateCluster(testCtx, testProjectId, testRegion, fixtureInputModel().ClusterName)
request = request.CreateOrUpdateClusterPayload(testPayload)
for _, mod := range mods {
mod(&request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
if !model.Async {
s := spinner.New(params.Printer)
s.Start("Completing credentials rotation")
_, err = wait.CompleteCredentialsRotationWaitHandler(ctx, apiClient, model.ProjectId, model.ClusterName).WaitWithContext(ctx)
_, err = wait.CompleteCredentialsRotationWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ClusterName).WaitWithContext(ctx)
if err != nil {
return fmt.Errorf("wait for completing SKE credentials rotation %w", err)
}
Expand Down Expand Up @@ -132,6 +132,6 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
}

func buildRequest(ctx context.Context, model *inputModel, apiClient *ske.APIClient) ske.ApiCompleteCredentialsRotationRequest {
req := apiClient.CompleteCredentialsRotation(ctx, model.ProjectId, model.ClusterName)
req := apiClient.CompleteCredentialsRotation(ctx, model.ProjectId, model.Region, model.ClusterName)
return req
}
Loading
Loading