You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

mygithub.libinneed.workers.dev/stackitcloud/stackit-cli

Package Overview
Dependencies
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mygithub.libinneed.workers.dev/stackitcloud/stackit-cli - go Package Compare versions

Comparing version
v0.35.0
to
v0.36.0
+1
-0
docs/stackit_image_create.md

@@ -26,2 +26,3 @@ ## stackit image create

```
--architecture string Sets the CPU architecture. By default x86 is used.
--boot-menu Enables the BIOS bootmenu.

@@ -28,0 +29,0 @@ --cdrom-bus string Sets CDROM bus controller type.

@@ -26,2 +26,3 @@ ## stackit image update

```
--architecture string Sets the CPU architecture.
--boot-menu Enables the BIOS bootmenu.

@@ -28,0 +29,0 @@ --cdrom-bus string Sets CDROM bus controller type.

+4
-4

@@ -22,5 +22,5 @@ module github.com/stackitcloud/stackit-cli

github.com/stackitcloud/stackit-sdk-go/services/dns v0.17.0
github.com/stackitcloud/stackit-sdk-go/services/git v0.6.0
github.com/stackitcloud/stackit-sdk-go/services/git v0.7.0
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.26.0
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.2.1
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.3.0
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.24.0

@@ -31,7 +31,7 @@ github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.2.0

github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.13.0
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.0
github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.3.1
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

@@ -38,0 +38,0 @@ github.com/zalando/go-keyring v0.2.6

@@ -42,2 +42,3 @@ package create

testRescueDevice = "test-rescue-device"
testArchitecture = "arm64"
testBootmenu = true

@@ -58,2 +59,3 @@ testSecureBoot = true

localFilePathFlag: testLocalImagePath,
architectureFlag: testArchitecture,
bootMenuFlag: strconv.FormatBool(testBootmenu),

@@ -101,2 +103,3 @@ cdromBusFlag: testCdRomBus,

Config: &imageConfig{
Architecture: &testArchitecture,
BootMenu: &testBootmenu,

@@ -129,2 +132,3 @@ CdromBus: &testCdRomBus,

Config: &iaas.ImageConfig{
Architecture: &testArchitecture,
BootMenu: &testBootmenu,

@@ -131,0 +135,0 @@ CdromBus: iaas.NewNullableString(&testCdRomBus),

@@ -34,2 +34,3 @@ package create

architectureFlag = "architecture"
bootMenuFlag = "boot-menu"

@@ -57,2 +58,3 @@ cdromBusFlag = "cdrom-bus"

type imageConfig struct {
Architecture *string
BootMenu *bool

@@ -266,2 +268,3 @@ CdromBus *string

cmd.Flags().String(architectureFlag, "", "Sets the CPU architecture. By default x86 is used.")
cmd.Flags().Bool(bootMenuFlag, false, "Enables the BIOS bootmenu.")

@@ -308,2 +311,3 @@ cmd.Flags().String(cdromBusFlag, "", "Sets CDROM bus controller type.")

Config: &imageConfig{
Architecture: flags.FlagToStringPointer(p, cmd, architectureFlag),
BootMenu: flags.FlagToBoolPointer(p, cmd, bootMenuFlag),

@@ -355,18 +359,44 @@ CdromBus: flags.FlagToStringPointer(p, cmd, cdromBusFlag),

}
if model.Config != nil {
payload.Config = &iaas.ImageConfig{
BootMenu: model.Config.BootMenu,
CdromBus: iaas.NewNullableString(model.Config.CdromBus),
DiskBus: iaas.NewNullableString(model.Config.DiskBus),
NicModel: iaas.NewNullableString(model.Config.NicModel),
OperatingSystem: model.Config.OperatingSystem,
OperatingSystemDistro: iaas.NewNullableString(model.Config.OperatingSystemDistro),
OperatingSystemVersion: iaas.NewNullableString(model.Config.OperatingSystemVersion),
RescueBus: iaas.NewNullableString(model.Config.RescueBus),
RescueDevice: iaas.NewNullableString(model.Config.RescueDevice),
SecureBoot: model.Config.SecureBoot,
Uefi: utils.Ptr(model.Config.Uefi),
VideoModel: iaas.NewNullableString(model.Config.VideoModel),
VirtioScsi: model.Config.VirtioScsi,
if config := model.Config; config != nil {
payload.Config = &iaas.ImageConfig{}
payload.Config.Uefi = utils.Ptr(config.Uefi)
if config.Architecture != nil {
payload.Config.Architecture = model.Config.Architecture
}
if config.BootMenu != nil {
payload.Config.BootMenu = model.Config.BootMenu
}
if config.CdromBus != nil {
payload.Config.CdromBus = iaas.NewNullableString(model.Config.CdromBus)
}
if config.DiskBus != nil {
payload.Config.DiskBus = iaas.NewNullableString(config.DiskBus)
}
if config.NicModel != nil {
payload.Config.NicModel = iaas.NewNullableString(config.NicModel)
}
if config.OperatingSystem != nil {
payload.Config.OperatingSystem = config.OperatingSystem
}
if config.OperatingSystemDistro != nil {
payload.Config.OperatingSystemDistro = iaas.NewNullableString(config.OperatingSystemDistro)
}
if config.OperatingSystemVersion != nil {
payload.Config.OperatingSystemVersion = iaas.NewNullableString(config.OperatingSystemVersion)
}
if config.RescueBus != nil {
payload.Config.RescueBus = iaas.NewNullableString(config.RescueBus)
}
if config.RescueDevice != nil {
payload.Config.RescueDevice = iaas.NewNullableString(config.RescueDevice)
}
if config.SecureBoot != nil {
payload.Config.SecureBoot = config.SecureBoot
}
if config.VideoModel != nil {
payload.Config.VideoModel = iaas.NewNullableString(config.VideoModel)
}
if config.VirtioScsi != nil {
payload.Config.VirtioScsi = config.VirtioScsi
}
}

@@ -373,0 +403,0 @@

@@ -144,2 +144,6 @@ package describe

if config := resp.Config; config != nil {
if architecture := config.Architecture; architecture != nil {
table.AddRow("ARCHITECTURE", *architecture)
table.AddSeparator()
}
if os := config.OperatingSystem; os != nil {

@@ -146,0 +150,0 @@ table.AddRow("OPERATING SYSTEM", *os)

@@ -168,10 +168,14 @@ package list

table := tables.NewTable()
table.SetHeader("ID", "NAME", "OS", "DISTRIBUTION", "VERSION", "LABELS")
table.SetHeader("ID", "NAME", "OS", "ARCHITECTURE", "DISTRIBUTION", "VERSION", "LABELS")
for _, item := range items {
var (
os string = "n/a"
distro string = "n/a"
version string = "n/a"
architecture string = "n/a"
os string = "n/a"
distro string = "n/a"
version string = "n/a"
)
if cfg := item.Config; cfg != nil {
if v := cfg.Architecture; v != nil {
architecture = *v
}
if v := cfg.OperatingSystem; v != nil {

@@ -190,2 +194,3 @@ os = *v

os,
architecture,
distro,

@@ -192,0 +197,0 @@ version,

@@ -301,2 +301,16 @@ package update

},
{
description: "update only name",
flagValues: map[string]string{
projectIdFlag: testProjectId,
nameFlag: "foo",
},
args: testImageId,
isValid: true,
expectedModel: &inputModel{
Name: utils.Ptr("foo"),
GlobalFlagModel: &globalflags.GlobalFlagModel{ProjectId: testProjectId, Verbosity: globalflags.VerbosityDefault},
Id: testImageId[0],
},
},
}

@@ -404,2 +418,13 @@

},
{
description: "no config set",
model: fixtureInputModel(func(model *inputModel) {
model.Config = nil
}),
expectedRequest: fixtureRequest(func(request *iaas.ApiUpdateImageRequest) {
*request = (*request).UpdateImagePayload(fixtureCreatePayload(func(payload *iaas.UpdateImagePayload) {
payload.Config = nil
}))
}),
},
}

@@ -406,0 +431,0 @@

@@ -23,2 +23,3 @@ package update

type imageConfig struct {
Architecture *string
BootMenu *bool

@@ -84,2 +85,3 @@ CdromBus *string

architectureFlag = "architecture"
bootMenuFlag = "boot-menu"

@@ -103,3 +105,2 @@ cdromBusFlag = "cdrom-bus"

minRamFlag = "min-ram"
ownerFlag = "owner"
protectedFlag = "protected"

@@ -172,2 +173,3 @@ )

cmd.Flags().String(architectureFlag, "", "Sets the CPU architecture.")
cmd.Flags().Bool(bootMenuFlag, false, "Enables the BIOS bootmenu.")

@@ -210,2 +212,3 @@ cmd.Flags().String(cdromBusFlag, "", "Sets CDROM bus controller type.")

Config: &imageConfig{
Architecture: flags.FlagToStringPointer(p, cmd, architectureFlag),
BootMenu: flags.FlagToBoolPointer(p, cmd, bootMenuFlag),

@@ -234,2 +237,6 @@ CdromBus: flags.FlagToStringPointer(p, cmd, cdromBusFlag),

if model.Config.isEmpty() {
model.Config = nil
}
if p.IsVerbosityDebug() {

@@ -258,19 +265,45 @@ modelStr, err := print.BuildDebugStrFromInputModel(model)

payload.Protected = model.Protected
payload.Config = nil
if model.Config != nil {
payload.Config = &iaas.ImageConfig{
BootMenu: model.Config.BootMenu,
CdromBus: iaas.NewNullableString(model.Config.CdromBus),
DiskBus: iaas.NewNullableString(model.Config.DiskBus),
NicModel: iaas.NewNullableString(model.Config.NicModel),
OperatingSystem: model.Config.OperatingSystem,
OperatingSystemDistro: iaas.NewNullableString(model.Config.OperatingSystemDistro),
OperatingSystemVersion: iaas.NewNullableString(model.Config.OperatingSystemVersion),
RescueBus: iaas.NewNullableString(model.Config.RescueBus),
RescueDevice: iaas.NewNullableString(model.Config.RescueDevice),
SecureBoot: model.Config.SecureBoot,
Uefi: model.Config.Uefi,
VideoModel: iaas.NewNullableString(model.Config.VideoModel),
VirtioScsi: model.Config.VirtioScsi,
if config := model.Config; config != nil {
payload.Config = &iaas.ImageConfig{}
if model.Config.BootMenu != nil {
payload.Config.BootMenu = model.Config.BootMenu
}
if model.Config.CdromBus != nil {
payload.Config.CdromBus = iaas.NewNullableString(model.Config.CdromBus)
}
if model.Config.DiskBus != nil {
payload.Config.DiskBus = iaas.NewNullableString(model.Config.DiskBus)
}
if model.Config.NicModel != nil {
payload.Config.NicModel = iaas.NewNullableString(model.Config.NicModel)
}
if model.Config.OperatingSystem != nil {
payload.Config.OperatingSystem = model.Config.OperatingSystem
}
if model.Config.OperatingSystemDistro != nil {
payload.Config.OperatingSystemDistro = iaas.NewNullableString(model.Config.OperatingSystemDistro)
}
if model.Config.OperatingSystemVersion != nil {
payload.Config.OperatingSystemVersion = iaas.NewNullableString(model.Config.OperatingSystemVersion)
}
if model.Config.RescueBus != nil {
payload.Config.RescueBus = iaas.NewNullableString(model.Config.RescueBus)
}
if model.Config.RescueDevice != nil {
payload.Config.RescueDevice = iaas.NewNullableString(model.Config.RescueDevice)
}
if model.Config.SecureBoot != nil {
payload.Config.SecureBoot = model.Config.SecureBoot
}
if model.Config.Uefi != nil {
payload.Config.Uefi = model.Config.Uefi
}
if model.Config.VideoModel != nil {
payload.Config.VideoModel = iaas.NewNullableString(model.Config.VideoModel)
}
if model.Config.VirtioScsi != nil {
payload.Config.VirtioScsi = model.Config.VirtioScsi
}
}

@@ -277,0 +310,0 @@

@@ -29,2 +29,4 @@ package create

const testRegion = "eu01"
var testPayload = &ske.CreateOrUpdateClusterPayload{

@@ -85,3 +87,4 @@ Kubernetes: &ske.Kubernetes{

flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
payloadFlag: fmt.Sprintf(`{

@@ -133,2 +136,3 @@ "name": "cli-jp",

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -146,3 +150,3 @@ },

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)

@@ -149,0 +153,0 @@ for _, mod := range mods {

@@ -111,3 +111,3 @@ package create

// 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 {

@@ -122,3 +122,3 @@ return err

if model.Payload == nil {
defaultPayload, err := skeUtils.GetDefaultPayload(ctx, apiClient)
defaultPayload, err := skeUtils.GetDefaultPayload(ctx, apiClient, model.Region)
if err != nil {

@@ -142,3 +142,3 @@ return fmt.Errorf("get default payload: %w", err)

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 {

@@ -198,3 +198,3 @@ return fmt.Errorf("wait for SKE cluster creation: %w", err)

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)

@@ -201,0 +201,0 @@ req = req.CreateOrUpdateClusterPayload(*model.Payload)

@@ -26,2 +26,4 @@ package delete

const testRegion = "eu01"
func fixtureArgValues(mods ...func(argValues []string)) []string {

@@ -39,3 +41,4 @@ argValues := []string{

flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
}

@@ -52,2 +55,3 @@ for _, mod := range mods {

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -64,3 +68,3 @@ },

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 {

@@ -67,0 +71,0 @@ mod(&request)

@@ -73,3 +73,3 @@ package delete

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 {

@@ -118,4 +118,4 @@ return fmt.Errorf("wait for SKE cluster deletion: %w", err)

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
}

@@ -26,2 +26,4 @@ package describe

const testRegion = "eu01"
func fixtureArgValues(mods ...func(argValues []string)) []string {

@@ -39,3 +41,4 @@ argValues := []string{

flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
}

@@ -52,2 +55,3 @@ for _, mod := range mods {

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -64,3 +68,3 @@ },

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 {

@@ -67,0 +71,0 @@ mod(&request)

@@ -96,3 +96,3 @@ package describe

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

@@ -99,0 +99,0 @@ }

@@ -31,7 +31,10 @@ package generatepayload

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,
}

@@ -48,2 +51,3 @@ for _, mod := range mods {

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -61,3 +65,3 @@ },

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 {

@@ -64,0 +68,0 @@ mod(&request)

@@ -73,3 +73,3 @@ package generatepayload

if model.ClusterName == nil {
payload, err = skeUtils.GetDefaultPayload(ctx, apiClient)
payload, err = skeUtils.GetDefaultPayload(ctx, apiClient, model.Region)
if err != nil {

@@ -134,3 +134,3 @@ return err

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

@@ -137,0 +137,0 @@ }

@@ -27,6 +27,9 @@ package list

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",
}

@@ -43,2 +46,3 @@ for _, mod := range mods {

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -55,3 +59,3 @@ },

func fixtureRequest(mods ...func(request *ske.ApiListClustersRequest)) ske.ApiListClustersRequest {
request := testClient.ListClusters(testCtx, testProjectId)
request := testClient.ListClusters(testCtx, testProjectId, testRegion)
for _, mod := range mods {

@@ -58,0 +62,0 @@ mod(&request)

@@ -147,3 +147,3 @@ package list

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

@@ -176,3 +176,3 @@ }

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"

@@ -179,0 +179,0 @@ }

@@ -29,2 +29,4 @@ package update

const testRegion = "eu01"
var testPayload = ske.CreateOrUpdateClusterPayload{

@@ -85,3 +87,4 @@ Kubernetes: &ske.Kubernetes{

flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
payloadFlag: fmt.Sprintf(`{

@@ -133,2 +136,3 @@ "name": "cli-jp",

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -146,3 +150,3 @@ },

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)

@@ -149,0 +153,0 @@ for _, mod := range mods {

@@ -82,3 +82,3 @@ package update

// 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 {

@@ -103,3 +103,3 @@ return err

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 {

@@ -159,3 +159,3 @@ return fmt.Errorf("wait for SKE cluster update: %w", err)

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)

@@ -162,0 +162,0 @@ req = req.CreateOrUpdateClusterPayload(model.Payload)

@@ -26,2 +26,4 @@ package completerotation

const testRegion = "eu01"
func fixtureArgValues(mods ...func(argValues []string)) []string {

@@ -39,3 +41,4 @@ argValues := []string{

flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
}

@@ -52,2 +55,3 @@ for _, mod := range mods {

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -64,3 +68,3 @@ },

func fixtureRequest(mods ...func(request *ske.ApiCompleteCredentialsRotationRequest)) ske.ApiCompleteCredentialsRotationRequest {
request := testClient.CompleteCredentialsRotation(testCtx, testProjectId, testClusterName)
request := testClient.CompleteCredentialsRotation(testCtx, testProjectId, testRegion, testClusterName)
for _, mod := range mods {

@@ -67,0 +71,0 @@ mod(&request)

@@ -90,3 +90,3 @@ package completerotation

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 {

@@ -136,4 +136,4 @@ return fmt.Errorf("wait for completing SKE credentials rotation %w", err)

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
}

@@ -26,2 +26,4 @@ package startrotation

const testRegion = "eu01"
func fixtureArgValues(mods ...func(argValues []string)) []string {

@@ -39,3 +41,4 @@ argValues := []string{

flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
}

@@ -52,2 +55,3 @@ for _, mod := range mods {

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -64,3 +68,3 @@ },

func fixtureRequest(mods ...func(request *ske.ApiStartCredentialsRotationRequest)) ske.ApiStartCredentialsRotationRequest {
request := testClient.StartCredentialsRotation(testCtx, testProjectId, testClusterName)
request := testClient.StartCredentialsRotation(testCtx, testProjectId, testRegion, testClusterName)
for _, mod := range mods {

@@ -67,0 +71,0 @@ mod(&request)

@@ -93,3 +93,3 @@ package startrotation

s.Start("Starting credentials rotation")
_, err = wait.StartCredentialsRotationWaitHandler(ctx, apiClient, model.ProjectId, model.ClusterName).WaitWithContext(ctx)
_, err = wait.StartCredentialsRotationWaitHandler(ctx, apiClient, model.ProjectId, model.Region, model.ClusterName).WaitWithContext(ctx)
if err != nil {

@@ -139,4 +139,4 @@ return fmt.Errorf("wait for start SKE credentials rotation %w", err)

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

@@ -26,2 +26,4 @@ package create

const testRegion = "eu01"
func fixtureArgValues(mods ...func(argValues []string)) []string {

@@ -39,3 +41,4 @@ argValues := []string{

flagValues := map[string]string{
projectIdFlag: testProjectId,
globalflags.ProjectIdFlag: testProjectId,
globalflags.RegionFlag: testRegion,
}

@@ -52,2 +55,3 @@ for _, mod := range mods {

ProjectId: testProjectId,
Region: testRegion,
Verbosity: globalflags.VerbosityDefault,

@@ -64,3 +68,3 @@ },

func fixtureRequest(mods ...func(request *ske.ApiCreateKubeconfigRequest)) ske.ApiCreateKubeconfigRequest {
request := testClient.CreateKubeconfig(testCtx, testProjectId, testClusterName)
request := testClient.CreateKubeconfig(testCtx, testProjectId, testRegion, testClusterName)
request = request.CreateKubeconfigPayload(ske.CreateKubeconfigPayload{})

@@ -67,0 +71,0 @@ for _, mod := range mods {

@@ -231,3 +231,3 @@ package create

func buildRequestCreate(ctx context.Context, model *inputModel, apiClient *ske.APIClient) (ske.ApiCreateKubeconfigRequest, error) {
req := apiClient.CreateKubeconfig(ctx, model.ProjectId, model.ClusterName)
req := apiClient.CreateKubeconfig(ctx, model.ProjectId, model.Region, model.ClusterName)

@@ -244,3 +244,3 @@ payload := ske.CreateKubeconfigPayload{}

func buildRequestLogin(ctx context.Context, model *inputModel, apiClient *ske.APIClient) (ske.ApiGetLoginKubeconfigRequest, error) {
return apiClient.GetLoginKubeconfig(ctx, model.ProjectId, model.ClusterName), nil
return apiClient.GetLoginKubeconfig(ctx, model.ProjectId, model.Region, model.ClusterName), nil
}

@@ -247,0 +247,0 @@

@@ -25,2 +25,4 @@ package login

const testRegion = "eu01"
func fixtureClusterConfig(mods ...func(clusterConfig *clusterConfig)) *clusterConfig {

@@ -31,2 +33,3 @@ clusterConfig := &clusterConfig{

cacheKey: "",
Region: testRegion,
}

@@ -40,3 +43,3 @@ for _, mod := range mods {

func fixtureRequest(mods ...func(request *ske.ApiCreateKubeconfigRequest)) ske.ApiCreateKubeconfigRequest {
request := testClient.CreateKubeconfig(testCtx, testProjectId, testClusterName)
request := testClient.CreateKubeconfig(testCtx, testProjectId, testRegion, testClusterName)
request = request.CreateKubeconfigPayload(ske.CreateKubeconfigPayload{})

@@ -43,0 +46,0 @@ for _, mod := range mods {

@@ -17,2 +17,3 @@ package login

"github.com/stackitcloud/stackit-cli/internal/pkg/cache"
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
"k8s.io/client-go/rest"

@@ -59,3 +60,3 @@

),
RunE: func(_ *cobra.Command, _ []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
ctx := context.Background()

@@ -74,3 +75,3 @@

clusterConfig, err := parseClusterConfig()
clusterConfig, err := parseClusterConfig(params.Printer, cmd)
if err != nil {

@@ -129,5 +130,6 @@ return fmt.Errorf("parseClusterConfig: %w", err)

cacheKey string
Region string
}
func parseClusterConfig() (*clusterConfig, error) {
func parseClusterConfig(p *print.Printer, cmd *cobra.Command) (*clusterConfig, error) {
obj, _, err := exec.LoadExecCredentialFromEnv()

@@ -162,2 +164,5 @@ if err != nil {

globalFlags := globalflags.Parse(p, cmd)
config.Region = globalFlags.Region
return config, nil

@@ -208,3 +213,3 @@ }

func buildRequest(ctx context.Context, apiClient *ske.APIClient, clusterConfig *clusterConfig) ske.ApiCreateKubeconfigRequest {
req := apiClient.CreateKubeconfig(ctx, clusterConfig.STACKITProjectID, clusterConfig.ClusterName)
req := apiClient.CreateKubeconfig(ctx, clusterConfig.STACKITProjectID, clusterConfig.Region, clusterConfig.ClusterName)
expirationSeconds := strconv.Itoa(expirationSeconds)

@@ -211,0 +216,0 @@

@@ -21,2 +21,4 @@ package options

const testRegion = "eu01"
func fixtureFlagValues(mods ...func(flagValues map[string]string)) map[string]string {

@@ -29,2 +31,3 @@ flagValues := map[string]string{

volumeTypesFlag: "false",
globalflags.RegionFlag: testRegion,
}

@@ -39,3 +42,3 @@ for _, mod := range mods {

model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{Verbosity: globalflags.VerbosityDefault},
GlobalFlagModel: &globalflags.GlobalFlagModel{Region: testRegion, Verbosity: globalflags.VerbosityDefault},
AvailabilityZones: false,

@@ -55,3 +58,3 @@ KubernetesVersions: false,

model := &inputModel{
GlobalFlagModel: &globalflags.GlobalFlagModel{Verbosity: globalflags.VerbosityDefault},
GlobalFlagModel: &globalflags.GlobalFlagModel{Region: testRegion, Verbosity: globalflags.VerbosityDefault},
AvailabilityZones: true,

@@ -83,6 +86,8 @@ KubernetesVersions: true,

{
description: "no values",
flagValues: map[string]string{},
isValid: true,
expectedModel: fixtureInputModelAllTrue(),
description: "no values",
flagValues: map[string]string{},
isValid: true,
expectedModel: fixtureInputModelAllTrue(func(model *inputModel) {
model.Region = ""
}),
},

@@ -98,2 +103,3 @@ {

model.AvailabilityZones = true
model.Region = ""
}),

@@ -112,2 +118,3 @@ },

model.MachineTypes = true
model.Region = ""
}),

@@ -121,4 +128,6 @@ },

},
isValid: true,
expectedModel: fixtureInputModelAllTrue(),
isValid: true,
expectedModel: fixtureInputModelAllTrue(func(model *inputModel) {
model.Region = ""
}),
},

@@ -180,3 +189,3 @@ }

description: "base",
expectedRequest: testClient.ListProviderOptions(testCtx),
expectedRequest: testClient.ListProviderOptions(testCtx, testRegion),
},

@@ -187,3 +196,3 @@ }

t.Run(tt.description, func(t *testing.T) {
request := buildRequest(testCtx, testClient)
request := buildRequest(testCtx, testClient, fixtureInputModelAllTrue())

@@ -190,0 +199,0 @@ diff := cmp.Diff(request, tt.expectedRequest,

@@ -75,3 +75,3 @@ package options

// Call API
req := buildRequest(ctx, apiClient)
req := buildRequest(ctx, apiClient, model)
resp, err := req.Execute()

@@ -135,4 +135,4 @@ if err != nil {

func buildRequest(ctx context.Context, apiClient *ske.APIClient) ske.ApiListProviderOptionsRequest {
req := apiClient.ListProviderOptions(ctx)
func buildRequest(ctx context.Context, apiClient *ske.APIClient, model *inputModel) ske.ApiListProviderOptionsRequest {
req := apiClient.ListProviderOptions(ctx, model.Region)
return req

@@ -139,0 +139,0 @@ }

@@ -30,4 +30,3 @@ package client

} else {
region := viper.GetString(config.RegionKey)
cfgOptions = append(cfgOptions, authCfgOption, sdkConfig.WithRegion(region))
cfgOptions = append(cfgOptions, authCfgOption)
}

@@ -34,0 +33,0 @@

@@ -73,3 +73,5 @@ package utils

func (m *skeClientMocked) ListClustersExecute(_ context.Context, _ string) (*ske.ListClustersResponse, error) {
const testRegion = "eu01"
func (m *skeClientMocked) ListClustersExecute(_ context.Context, _, _ string) (*ske.ListClustersResponse, error) {
if m.listClustersFails {

@@ -81,3 +83,3 @@ return nil, fmt.Errorf("could not list clusters")

func (m *skeClientMocked) ListProviderOptionsExecute(_ context.Context) (*ske.ProviderOptions, error) {
func (m *skeClientMocked) ListProviderOptionsExecute(_ context.Context, _ string) (*ske.ProviderOptions, error) {
if m.listProviderOptionsFails {

@@ -129,3 +131,3 @@ return nil, fmt.Errorf("could not list provider options")

exists, err := ClusterExists(context.Background(), client, testProjectId, testClusterName)
exists, err := ClusterExists(context.Background(), client, testProjectId, testRegion, testClusterName)

@@ -406,3 +408,3 @@ if tt.isValid && err != nil {

output, err := GetDefaultPayload(context.Background(), client)
output, err := GetDefaultPayload(context.Background(), client, testRegion)

@@ -409,0 +411,0 @@ if tt.isValid && err != nil {

@@ -35,8 +35,8 @@ package utils

type SKEClient interface {
ListClustersExecute(ctx context.Context, projectId string) (*ske.ListClustersResponse, error)
ListProviderOptionsExecute(ctx context.Context) (*ske.ProviderOptions, error)
ListClustersExecute(ctx context.Context, projectId, region string) (*ske.ListClustersResponse, error)
ListProviderOptionsExecute(ctx context.Context, region string) (*ske.ProviderOptions, error)
}
func ClusterExists(ctx context.Context, apiClient SKEClient, projectId, clusterName string) (bool, error) {
clusters, err := apiClient.ListClustersExecute(ctx, projectId)
func ClusterExists(ctx context.Context, apiClient SKEClient, projectId, region, clusterName string) (bool, error) {
clusters, err := apiClient.ListClustersExecute(ctx, projectId, region)
if err != nil {

@@ -53,4 +53,4 @@ return false, fmt.Errorf("list SKE clusters: %w", err)

func GetDefaultPayload(ctx context.Context, apiClient SKEClient) (*ske.CreateOrUpdateClusterPayload, error) {
resp, err := apiClient.ListProviderOptionsExecute(ctx)
func GetDefaultPayload(ctx context.Context, apiClient SKEClient, region string) (*ske.CreateOrUpdateClusterPayload, error) {
resp, err := apiClient.ListProviderOptionsExecute(ctx, region)
if err != nil {

@@ -57,0 +57,0 @@ return nil, fmt.Errorf("get SKE provider options: %w", err)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display