mygithub.libinneed.workers.dev/stackitcloud/stackit-cli
Advanced tools
@@ -16,5 +16,5 @@ name: Renovate | ||
| - name: Self-hosted Renovate | ||
| uses: renovatebot/github-action@v42.0.4 | ||
| uses: renovatebot/github-action@v42.0.5 | ||
| with: | ||
| configurationFile: .github/renovate.json | ||
| token: ${{ secrets.RENOVATE_TOKEN }} |
+24
-24
@@ -13,3 +13,3 @@ module github.com/stackitcloud/stackit-cli | ||
| github.com/jedib0t/go-pretty/v6 v6.6.7 | ||
| github.com/lmittmann/tint v1.1.1 | ||
| github.com/lmittmann/tint v1.1.2 | ||
| github.com/mattn/go-colorable v0.1.14 | ||
@@ -20,24 +20,24 @@ github.com/spf13/cobra v1.9.1 | ||
| github.com/stackitcloud/stackit-sdk-go/core v0.17.2 | ||
| github.com/stackitcloud/stackit-sdk-go/services/alb v0.4.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/alb v0.5.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/authorization v0.7.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/dns v0.15.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/git v0.5.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/iaas v0.23.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.2.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.23.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/dns v0.15.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/git v0.5.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/iaas v0.24.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.2.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.23.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.1.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.15.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.2.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/resourcemanager v0.16.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/runcommand v1.2.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/secretsmanager v0.12.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.2.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/serverbackup v1.2.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/serverupdate v1.1.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.8.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/ske v0.24.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/serviceaccount v0.8.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/serviceenablement v1.2.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/ske v0.25.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/sqlserverflex v1.2.0 | ||
| github.com/zalando/go-keyring v0.2.6 | ||
| golang.org/x/mod v0.24.0 | ||
| golang.org/x/mod v0.25.0 | ||
| golang.org/x/oauth2 v0.30.0 | ||
| golang.org/x/term v0.32.0 | ||
| golang.org/x/text v0.25.0 | ||
| golang.org/x/text v0.26.0 | ||
| k8s.io/apimachinery v0.32.3 | ||
@@ -48,3 +48,3 @@ k8s.io/client-go v0.32.3 | ||
| require ( | ||
| golang.org/x/net v0.40.0 // indirect | ||
| golang.org/x/net v0.41.0 // indirect | ||
| golang.org/x/time v0.11.0 // indirect | ||
@@ -212,4 +212,4 @@ gopkg.in/inf.v0 v0.9.1 // indirect | ||
| golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect | ||
| golang.org/x/sync v0.14.0 // indirect | ||
| golang.org/x/tools v0.33.0 // indirect | ||
| golang.org/x/sync v0.15.0 // indirect | ||
| golang.org/x/tools v0.34.0 // indirect | ||
| google.golang.org/protobuf v1.36.6 // indirect | ||
@@ -243,9 +243,9 @@ gopkg.in/yaml.v2 v2.4.0 // indirect | ||
| github.com/spf13/cast v1.7.1 // indirect | ||
| github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.2.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/logme v0.24.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.24.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.4.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/logme v0.24.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.24.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.2.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/observability v0.7.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.24.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/redis v0.24.0 | ||
| github.com/stackitcloud/stackit-sdk-go/services/observability v0.7.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.24.1 | ||
| github.com/stackitcloud/stackit-sdk-go/services/redis v0.24.1 | ||
| github.com/subosito/gotenv v1.6.0 // indirect | ||
@@ -252,0 +252,0 @@ go.uber.org/multierr v1.11.0 // indirect |
@@ -10,3 +10,3 @@ package delete | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -97,3 +97,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -100,0 +100,0 @@ |
@@ -343,14 +343,6 @@ package create | ||
| func createPayload(_ context.Context, model *inputModel) iaas.CreateImagePayload { | ||
| var labelsMap *map[string]any | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.CreateImagePayload{ | ||
| DiskFormat: &model.DiskFormat, | ||
| Name: &model.Name, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| MinDiskSize: model.MinDiskSize, | ||
@@ -357,0 +349,0 @@ MinRam: model.MinRam, |
@@ -10,3 +10,3 @@ package delete | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -61,4 +61,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" | ||
| imageName = model.ImageId | ||
| } else if imageName == "" { | ||
| imageName = model.ImageId | ||
| } | ||
@@ -92,3 +90,3 @@ | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -95,0 +93,0 @@ |
@@ -10,3 +10,3 @@ package update | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -139,4 +139,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| imageLabel = model.Id | ||
| } else if imageLabel == "" { | ||
| imageLabel = model.Id | ||
| } | ||
@@ -199,3 +197,3 @@ | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -249,13 +247,6 @@ | ||
| payload := iaas.NewUpdateImagePayload() | ||
| var labelsMap *map[string]any | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| // Config *ImageConfig `json:"config,omitempty"` | ||
| payload.DiskFormat = model.DiskFormat | ||
| payload.Labels = labelsMap | ||
| payload.Labels = utils.ConvertStringMapToInterfaceMap(model.Labels) | ||
| payload.MinDiskSize = model.MinDiskSize | ||
@@ -262,0 +253,0 @@ payload.MinRam = model.MinRam |
@@ -127,14 +127,5 @@ package create | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.CreateKeyPairPayload{ | ||
| Name: model.Name, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| PublicKey: model.PublicKey, | ||
@@ -141,0 +132,0 @@ } |
@@ -90,12 +90,4 @@ package update | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.UpdateKeyPairPayload{ | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| } | ||
@@ -102,0 +94,0 @@ return req.UpdateKeyPairPayload(payload) |
@@ -228,3 +228,3 @@ package options | ||
| } | ||
| if model.Storages && options.Storages.Storages != nil && len(*options.Storages.Storages.StorageClasses) == 0 { | ||
| if model.Storages && options.Storages.Storages != nil && len(*options.Storages.Storages.StorageClasses) > 0 { | ||
| content = append(content, buildStoragesTable(*options.Storages.Storages)) | ||
@@ -231,0 +231,0 @@ } |
@@ -175,14 +175,5 @@ package create | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.CreateNetworkAreaPayload{ | ||
| Name: model.Name, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| AddressFamily: &iaas.CreateAreaAddressFamily{ | ||
@@ -189,0 +180,0 @@ Ipv4: &iaas.CreateAreaIPv4{ |
@@ -66,4 +66,2 @@ package delete | ||
| networkAreaLabel = model.AreaId | ||
| } else if networkAreaLabel == "" { | ||
| networkAreaLabel = model.AreaId | ||
| } | ||
@@ -70,0 +68,0 @@ |
@@ -6,2 +6,3 @@ package describe | ||
| "encoding/json" | ||
| "errors" | ||
| "fmt" | ||
@@ -83,3 +84,5 @@ "strings" | ||
| projects, err = iaasUtils.ListAttachedProjects(ctx, apiClient, *model.OrganizationId, model.AreaId) | ||
| if err != nil { | ||
| if err != nil && errors.Is(err, iaasUtils.ErrItemsNil) { | ||
| projects = []string{} | ||
| } else if err != nil { | ||
| return fmt.Errorf("get attached projects: %w", err) | ||
@@ -86,0 +89,0 @@ } |
@@ -64,4 +64,2 @@ package delete | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } else if networkAreaLabel == "" { | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } | ||
@@ -68,0 +66,0 @@ networkRangeLabel, err := iaasUtils.GetNetworkRangePrefix(ctx, apiClient, *model.OrganizationId, *model.NetworkAreaId, model.NetworkRangeId) |
@@ -11,3 +11,3 @@ package list | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -85,4 +85,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } else if networkAreaLabel == "" { | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } | ||
@@ -119,3 +117,3 @@ params.Printer.Info("No network ranges found for SNA %q\n", networkAreaLabel) | ||
| if limit != nil && *limit < 1 { | ||
| return nil, &errors.FlagValidationError{ | ||
| return nil, &cliErr.FlagValidationError{ | ||
| Flag: limitFlag, | ||
@@ -122,0 +120,0 @@ Details: "must be greater than 0", |
@@ -77,4 +77,2 @@ package create | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } else if networkAreaLabel == "" { | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } | ||
@@ -151,11 +149,2 @@ | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.CreateNetworkAreaRoutePayload{ | ||
@@ -166,3 +155,3 @@ Ipv4: &[]iaas.Route{ | ||
| Nexthop: model.Nexthop, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| }, | ||
@@ -169,0 +158,0 @@ }, |
@@ -64,4 +64,2 @@ package delete | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } else if networkAreaLabel == "" { | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } | ||
@@ -68,0 +66,0 @@ |
@@ -12,3 +12,3 @@ package list | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -84,4 +84,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } else if networkAreaLabel == "" { | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } | ||
@@ -118,3 +116,3 @@ params.Printer.Info("No static routes found for STACKIT Network Area %q\n", networkAreaLabel) | ||
| if limit != nil && *limit < 1 { | ||
| return nil, &errors.FlagValidationError{ | ||
| return nil, &cliErr.FlagValidationError{ | ||
| Flag: limitFlag, | ||
@@ -121,0 +119,0 @@ Details: "must be greater than 0", |
@@ -12,3 +12,3 @@ package update | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -74,4 +74,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } else if networkAreaLabel == "" { | ||
| networkAreaLabel = *model.NetworkAreaId | ||
| } | ||
@@ -109,3 +107,3 @@ | ||
| if labels == nil { | ||
| return nil, &errors.EmptyUpdateError{} | ||
| return nil, &cliErr.EmptyUpdateError{} | ||
| } | ||
@@ -136,10 +134,4 @@ | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap := make(map[string]interface{}) | ||
| for k, v := range *model.Labels { | ||
| labelsMap[k] = v | ||
| } | ||
| payload := iaas.UpdateNetworkAreaRoutePayload{ | ||
| Labels: &labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| } | ||
@@ -146,0 +138,0 @@ req = req.UpdateNetworkAreaRoutePayload(payload) |
@@ -156,14 +156,5 @@ package update | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.PartialUpdateNetworkAreaPayload{ | ||
| Name: model.Name, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| AddressFamily: &iaas.UpdateAreaAddressFamily{ | ||
@@ -170,0 +161,0 @@ Ipv4: &iaas.UpdateAreaIPv4{ |
@@ -210,12 +210,2 @@ package create | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| convertedMap := make(map[string]interface{}, len(*model.Labels)) | ||
| for k, v := range *model.Labels { | ||
| convertedMap[k] = v | ||
| } | ||
| labelsMap = &convertedMap | ||
| } | ||
| payload := iaas.CreateNicPayload{ | ||
@@ -225,3 +215,3 @@ AllowedAddresses: model.AllowedAddresses, | ||
| Ipv6: model.Ipv6, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| Name: model.Name, | ||
@@ -228,0 +218,0 @@ NicSecurity: model.NicSecurity, |
@@ -202,15 +202,5 @@ package update | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| convertedMap := make(map[string]interface{}, len(*model.Labels)) | ||
| for k, v := range *model.Labels { | ||
| convertedMap[k] = v | ||
| } | ||
| labelsMap = &convertedMap | ||
| } | ||
| payload := iaas.UpdateNicPayload{ | ||
| AllowedAddresses: model.AllowedAddresses, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| Name: model.Name, | ||
@@ -217,0 +207,0 @@ NicSecurity: model.NicSecurity, |
@@ -232,11 +232,2 @@ package create | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| routed := true | ||
@@ -249,3 +240,3 @@ if model.NonRouted { | ||
| Name: model.Name, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| Routed: &routed, | ||
@@ -252,0 +243,0 @@ } |
@@ -182,11 +182,2 @@ package update | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| if model.IPv6DnsNameServers != nil || model.NoIPv6Gateway || model.IPv6Gateway != nil { | ||
@@ -218,3 +209,3 @@ addressFamily.Ipv6 = &iaas.UpdateNetworkIPv6Body{ | ||
| Name: model.Name, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| } | ||
@@ -221,0 +212,0 @@ |
@@ -225,3 +225,3 @@ package options | ||
| } | ||
| if model.Storages && options.Storages.Storages != nil && len(*options.Storages.Storages.StorageClasses) == 0 { | ||
| if model.Storages && options.Storages.Storages != nil && len(*options.Storages.Storages.StorageClasses) > 0 { | ||
| content = append(content, buildStoragesTable(*options.Storages.Storages)) | ||
@@ -228,0 +228,0 @@ } |
@@ -129,14 +129,5 @@ package create | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.CreatePublicIPPayload{ | ||
| NetworkInterface: iaas.NewNullableString(model.AssociatedResourceId), | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| } | ||
@@ -143,0 +134,0 @@ |
@@ -133,13 +133,4 @@ package update | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.UpdatePublicIPPayload{ | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| } | ||
@@ -146,0 +137,0 @@ |
@@ -130,13 +130,5 @@ package create | ||
| var labelsMap *map[string]any | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.CreateSecurityGroupPayload{ | ||
| Description: model.Description, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| Name: model.Name, | ||
@@ -143,0 +135,0 @@ Stateful: model.Stateful, |
@@ -138,11 +138,3 @@ package update | ||
| payload.Description = model.Description | ||
| var labelsMap *map[string]any | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload.Labels = labelsMap | ||
| payload.Labels = utils.ConvertStringMapToInterfaceMap(model.Labels) | ||
| payload.Name = model.Name | ||
@@ -149,0 +141,0 @@ request = request.UpdateSecurityGroupPayload(*payload) |
@@ -284,10 +284,2 @@ package create | ||
| req := apiClient.CreateServer(ctx, model.ProjectId) | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
@@ -311,3 +303,3 @@ var userData *[]byte | ||
| Volumes: model.Volumes, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| } | ||
@@ -314,0 +306,0 @@ |
@@ -132,14 +132,5 @@ package update | ||
| var labelsMap *map[string]interface{} | ||
| if model.Labels != nil && len(*model.Labels) > 0 { | ||
| // convert map[string]string to map[string]interface{} | ||
| labelsMap = utils.Ptr(map[string]interface{}{}) | ||
| for k, v := range *model.Labels { | ||
| (*labelsMap)[k] = v | ||
| } | ||
| } | ||
| payload := iaas.UpdateServerPayload{ | ||
| Name: model.Name, | ||
| Labels: labelsMap, | ||
| Labels: utils.ConvertStringMapToInterfaceMap(model.Labels), | ||
| } | ||
@@ -146,0 +137,0 @@ |
@@ -12,3 +12,3 @@ package attach | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -73,4 +73,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| volumeLabel = model.VolumeId | ||
| } else if volumeLabel == "" { | ||
| volumeLabel = model.VolumeId | ||
| } | ||
@@ -120,3 +118,3 @@ | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -123,0 +121,0 @@ |
@@ -12,3 +12,3 @@ package describe | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -73,4 +73,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| volumeLabel = model.VolumeId | ||
| } else if volumeLabel == "" { | ||
| volumeLabel = model.VolumeId | ||
| } | ||
@@ -111,3 +109,3 @@ | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -114,0 +112,0 @@ |
@@ -10,3 +10,3 @@ package detach | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -63,4 +63,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| volumeLabel = model.VolumeId | ||
| } else if volumeLabel == "" { | ||
| volumeLabel = model.VolumeId | ||
| } | ||
@@ -110,3 +108,3 @@ | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -113,0 +111,0 @@ |
@@ -12,3 +12,3 @@ package list | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -87,2 +87,3 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| params.Printer.Debug(print.ErrorLevel, "get volume name: %v", err) | ||
| volumeLabel = "" | ||
| } | ||
@@ -109,3 +110,3 @@ volumeNames = append(volumeNames, volumeLabel) | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -112,0 +113,0 @@ |
@@ -12,3 +12,3 @@ package update | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -69,4 +69,2 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/flags" | ||
| volumeLabel = model.VolumeId | ||
| } else if volumeLabel == "" { | ||
| volumeLabel = model.VolumeId | ||
| } | ||
@@ -116,3 +114,3 @@ | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -119,0 +117,0 @@ |
@@ -9,3 +9,3 @@ package delete | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/args" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| cliErr "github.com/stackitcloud/stackit-cli/internal/pkg/errors" | ||
| "github.com/stackitcloud/stackit-cli/internal/pkg/examples" | ||
@@ -61,8 +61,6 @@ "github.com/stackitcloud/stackit-cli/internal/pkg/globalflags" | ||
| volumeLabel := model.VolumeId | ||
| volumeName, err := iaasUtils.GetVolumeName(ctx, apiClient, model.ProjectId, model.VolumeId) | ||
| volumeLabel, err := iaasUtils.GetVolumeName(ctx, apiClient, model.ProjectId, model.VolumeId) | ||
| if err != nil { | ||
| params.Printer.Debug(print.ErrorLevel, "get volume name: %v", err) | ||
| } else if volumeName != "" { | ||
| volumeLabel = volumeName | ||
| volumeLabel = model.VolumeId | ||
| } | ||
@@ -112,3 +110,3 @@ | ||
| if globalFlags.ProjectId == "" { | ||
| return nil, &errors.ProjectIdError{} | ||
| return nil, &cliErr.ProjectIdError{} | ||
| } | ||
@@ -115,0 +113,0 @@ |
@@ -189,2 +189,22 @@ package utils | ||
| }, | ||
| { | ||
| name: "response is nil", | ||
| args: args{ | ||
| getInstanceResp: nil, | ||
| getInstanceFails: false, | ||
| }, | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| { | ||
| name: "name in response is nil", | ||
| args: args{ | ||
| getInstanceResp: &iaas.SecurityGroup{ | ||
| Name: nil, | ||
| }, | ||
| getInstanceFails: false, | ||
| }, | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| } | ||
@@ -334,2 +354,22 @@ for _, tt := range tests { | ||
| }, | ||
| { | ||
| name: "response is nil", | ||
| args: args{ | ||
| getInstanceResp: nil, | ||
| getInstanceFails: false, | ||
| }, | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| { | ||
| name: "name in response is nil", | ||
| args: args{ | ||
| getInstanceResp: &iaas.Volume{ | ||
| Name: nil, | ||
| }, | ||
| getInstanceFails: false, | ||
| }, | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| } | ||
@@ -381,2 +421,22 @@ for _, tt := range tests { | ||
| }, | ||
| { | ||
| name: "response is nil", | ||
| args: args{ | ||
| getInstanceResp: nil, | ||
| getInstanceFails: false, | ||
| }, | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| { | ||
| name: "name in response is nil", | ||
| args: args{ | ||
| getInstanceResp: &iaas.Network{ | ||
| Name: nil, | ||
| }, | ||
| getInstanceFails: false, | ||
| }, | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| } | ||
@@ -427,3 +487,24 @@ for _, tt := range tests { | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| { | ||
| name: "response is nil", | ||
| args: args{ | ||
| getInstanceResp: nil, | ||
| getInstanceFails: false, | ||
| }, | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| { | ||
| name: "name in response is nil", | ||
| args: args{ | ||
| getInstanceResp: &iaas.NetworkArea{ | ||
| Name: nil, | ||
| }, | ||
| getInstanceFails: false, | ||
| }, | ||
| wantErr: true, | ||
| want: "", | ||
| }, | ||
| } | ||
@@ -708,7 +789,15 @@ for _, tt := range tests { | ||
| { | ||
| name: "nil name", | ||
| name: "response is nil", | ||
| imageErr: false, | ||
| imageResp: &iaas.Image{}, | ||
| imageResp: nil, | ||
| want: "", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "name in response is nil", | ||
| imageErr: false, | ||
| imageResp: &iaas.Image{Name: nil}, | ||
| want: "", | ||
| wantErr: true, | ||
| }, | ||
| } | ||
@@ -753,7 +842,19 @@ for _, tt := range tests { | ||
| { | ||
| name: "nil affinity group name", | ||
| affinityErr: false, | ||
| affinityResp: &iaas.AffinityGroup{}, | ||
| want: "", | ||
| name: "response is nil", | ||
| affinityErr: false, | ||
| affinityResp: &iaas.AffinityGroup{ | ||
| Name: nil, | ||
| }, | ||
| want: "", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "affinity group name in response is nil", | ||
| affinityErr: false, | ||
| affinityResp: &iaas.AffinityGroup{ | ||
| Name: nil, | ||
| }, | ||
| want: "", | ||
| wantErr: true, | ||
| }, | ||
| } | ||
@@ -760,0 +861,0 @@ for _, tt := range tests { |
@@ -5,2 +5,3 @@ package utils | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
@@ -11,2 +12,8 @@ | ||
| var ( | ||
| ErrResponseNil = errors.New("response is nil") | ||
| ErrNameNil = errors.New("name is nil") | ||
| ErrItemsNil = errors.New("items is nil") | ||
| ) | ||
| type IaaSClient interface { | ||
@@ -39,2 +46,6 @@ GetSecurityGroupRuleExecute(ctx context.Context, projectId, securityGroupRuleId, securityGroupId string) (*iaas.SecurityGroupRule, error) | ||
| return "", fmt.Errorf("get security group: %w", err) | ||
| } else if resp == nil { | ||
| return "", ErrResponseNil | ||
| } else if resp.Name == nil { | ||
| return "", ErrNameNil | ||
| } | ||
@@ -68,2 +79,6 @@ return *resp.Name, nil | ||
| return "", fmt.Errorf("get volume: %w", err) | ||
| } else if resp == nil { | ||
| return "", ErrResponseNil | ||
| } else if resp.Name == nil { | ||
| return "", ErrNameNil | ||
| } | ||
@@ -77,2 +92,6 @@ return *resp.Name, nil | ||
| return "", fmt.Errorf("get network: %w", err) | ||
| } else if resp == nil { | ||
| return "", ErrResponseNil | ||
| } else if resp.Name == nil { | ||
| return "", ErrNameNil | ||
| } | ||
@@ -86,2 +105,6 @@ return *resp.Name, nil | ||
| return "", fmt.Errorf("get network area: %w", err) | ||
| } else if resp == nil { | ||
| return "", ErrResponseNil | ||
| } else if resp.Name == nil { | ||
| return "", ErrNameNil | ||
| } | ||
@@ -95,2 +118,6 @@ return *resp.Name, nil | ||
| return nil, fmt.Errorf("list network area attached projects: %w", err) | ||
| } else if resp == nil { | ||
| return nil, ErrResponseNil | ||
| } else if resp.Items == nil { | ||
| return nil, ErrItemsNil | ||
| } | ||
@@ -134,6 +161,7 @@ return *resp.Items, nil | ||
| return "", fmt.Errorf("get image: %w", err) | ||
| } else if resp == nil { | ||
| return "", ErrResponseNil | ||
| } else if resp.Name == nil { | ||
| return "", ErrNameNil | ||
| } | ||
| if resp.Name == nil { | ||
| return "", nil | ||
| } | ||
| return *resp.Name, nil | ||
@@ -146,7 +174,8 @@ } | ||
| return "", fmt.Errorf("get affinity group: %w", err) | ||
| } else if resp == nil { | ||
| return "", ErrResponseNil | ||
| } else if resp.Name == nil { | ||
| return "", ErrNameNil | ||
| } | ||
| if resp.Name == nil { | ||
| return "", nil | ||
| } | ||
| return *resp.Name, nil | ||
| } |
@@ -152,1 +152,100 @@ package utils | ||
| } | ||
| func TestConvertStringMapToInterfaceMap(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| input *map[string]string | ||
| expected *map[string]interface{} | ||
| }{ | ||
| { | ||
| name: "nil input", | ||
| input: nil, | ||
| expected: nil, | ||
| }, | ||
| { | ||
| name: "empty map", | ||
| input: &map[string]string{}, | ||
| expected: nil, | ||
| }, | ||
| { | ||
| name: "single key-value pair", | ||
| input: &map[string]string{ | ||
| "key1": "value1", | ||
| }, | ||
| expected: &map[string]interface{}{ | ||
| "key1": "value1", | ||
| }, | ||
| }, | ||
| { | ||
| name: "multiple key-value pairs", | ||
| input: &map[string]string{ | ||
| "key1": "value1", | ||
| "key2": "value2", | ||
| "key3": "value3", | ||
| }, | ||
| expected: &map[string]interface{}{ | ||
| "key1": "value1", | ||
| "key2": "value2", | ||
| "key3": "value3", | ||
| }, | ||
| }, | ||
| { | ||
| name: "special characters in values", | ||
| input: &map[string]string{ | ||
| "key1": "value with spaces", | ||
| "key2": "value,with,commas", | ||
| "key3": "value\nwith\nnewlines", | ||
| }, | ||
| expected: &map[string]interface{}{ | ||
| "key1": "value with spaces", | ||
| "key2": "value,with,commas", | ||
| "key3": "value\nwith\nnewlines", | ||
| }, | ||
| }, | ||
| { | ||
| name: "empty values", | ||
| input: &map[string]string{ | ||
| "key1": "", | ||
| "key2": "value2", | ||
| }, | ||
| expected: &map[string]interface{}{ | ||
| "key1": "", | ||
| "key2": "value2", | ||
| }, | ||
| }, | ||
| } | ||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| result := ConvertStringMapToInterfaceMap(tt.input) | ||
| // Check if both are nil | ||
| if result == nil && tt.expected == nil { | ||
| return | ||
| } | ||
| // Check if one is nil and other isn't | ||
| if (result == nil && tt.expected != nil) || (result != nil && tt.expected == nil) { | ||
| t.Errorf("ConvertStringMapToInterfaceMap() = %v, want %v", result, tt.expected) | ||
| return | ||
| } | ||
| // Compare maps | ||
| if len(*result) != len(*tt.expected) { | ||
| t.Errorf("ConvertStringMapToInterfaceMap() map length = %d, want %d", len(*result), len(*tt.expected)) | ||
| return | ||
| } | ||
| for k, v := range *result { | ||
| expectedVal, ok := (*tt.expected)[k] | ||
| if !ok { | ||
| t.Errorf("ConvertStringMapToInterfaceMap() unexpected key %s in result", k) | ||
| continue | ||
| } | ||
| if v != expectedVal { | ||
| t.Errorf("ConvertStringMapToInterfaceMap() value for key %s = %v, want %v", k, v, expectedVal) | ||
| } | ||
| } | ||
| }) | ||
| } | ||
| } |
@@ -132,1 +132,16 @@ package utils | ||
| } | ||
| // ConvertStringMapToInterfaceMap converts a map[string]string to a pointer to map[string]interface{}. | ||
| // Returns nil if the input map is empty. | ||
| // | ||
| //nolint:gocritic // Linter wants to have a non-pointer type for the map, but this would mean a nil check has to be done before every usage of this func. | ||
| func ConvertStringMapToInterfaceMap(m *map[string]string) *map[string]interface{} { | ||
| if m == nil || len(*m) == 0 { | ||
| return nil | ||
| } | ||
| result := make(map[string]interface{}, len(*m)) | ||
| for k, v := range *m { | ||
| result[k] = v | ||
| } | ||
| return &result | ||
| } |
Sorry, the diff of this file is too big to display