Skip to content

Commit 1f38eb0

Browse files
committed
refactor duplicate code with util func ConvertStringMapToInterfaceMap
1 parent 8c574d4 commit 1f38eb0

File tree

3 files changed

+10
-28
lines changed

3 files changed

+10
-28
lines changed

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -574,20 +574,20 @@ github.com/stackitcloud/stackit-sdk-go/services/git v0.5.0 h1:s0A2EPBrnBxfKStKA/
574574
github.com/stackitcloud/stackit-sdk-go/services/git v0.5.0/go.mod h1:XhXHJpOVC9Rpwyf1G+EpMbprBafH9aZb8vWBdR+z0WM=
575575
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.24.0 h1:aLlZmcsDHqqc7KPsevvs+W6EPZFT51u/dx5TcVQsE6g=
576576
github.com/stackitcloud/stackit-sdk-go/services/iaas v0.24.0/go.mod h1:TaMx7kukGpRm0BkNCmS7u2x12q1pgfbD55DAnLIjOIQ=
577-
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.2.0 h1:gaTgjmEIvq7Nmji5YHh1haFvA/8dWyOgCg3lw6drjL4=
578-
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.2.0/go.mod h1:h3oM6cS23Yfynp8Df1hNr0FxtY5Alii/2g8Wqi5SIVE=
579-
github.com/stackitcloud/stackit-sdk-go/services/logme v0.24.0 h1:5J2TH9ig5cp+5pCHugrsDJuFsRnIOQHQUqsxlweRXL0=
580-
github.com/stackitcloud/stackit-sdk-go/services/logme v0.24.0/go.mod h1:+3jizYma6Dq3XVn6EMMdSBF9eIm0w6hCJvrStB3AIL0=
581-
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.24.0 h1:t/Ten9AuoWFmrDq5gAI3kVZShF3i8zEAaeBsYYqiaao=
582-
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.24.0/go.mod h1:qgvi3qiAzB1wKpMJ5CPnEaUToeiwgnQxGvlkjdisaLU=
577+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.4.0 h1:Ef4SyTBjIkfwaws4mssa6AoK+OokHFtr7ZIflUpoXVE=
578+
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.4.0/go.mod h1:FiVhDlw9+yuTiUmnyGLn2qpsLW26w9OC4TS1y78czvg=
579+
github.com/stackitcloud/stackit-sdk-go/services/logme v0.24.1 h1:hfnILDJGBwwqUIs4xt/7Jj4LBe+JsSdHy+Md2ynUg4Y=
580+
github.com/stackitcloud/stackit-sdk-go/services/logme v0.24.1/go.mod h1:XjDMHhAQogFXsVR+o138CPYG1FOe0/Nl2Vm+fAgzx2A=
581+
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.24.1 h1:7nN7ZCuWSbJMy5KqoOqSbp5JKIOvyuDqVRtxVvT1iyE=
582+
github.com/stackitcloud/stackit-sdk-go/services/mariadb v0.24.1/go.mod h1:Pb8IEV5/jP8k75dVcN5cn3kP7PHTy/4KXXKpG76oj4U=
583583
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.2.0 h1:U/IhjLOz0vG6zuxTqGhBd8f609s6JB+X9PaL6x/VM58=
584584
github.com/stackitcloud/stackit-sdk-go/services/mongodbflex v1.2.0/go.mod h1:+JSnz5/AvGN5ek/iH008frRc/NgjSr1EVOTIbyLwAuQ=
585585
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.2.0 h1:+dKIPVz9ydKbX3x6+1NvYk++OA378w74p+N6SjDmzBQ=
586586
github.com/stackitcloud/stackit-sdk-go/services/objectstorage v1.2.0/go.mod h1:iCOYS9yICXQPyMAIdUGMqJDLY8HXKiVAdiMzO/mPvtA=
587587
github.com/stackitcloud/stackit-sdk-go/services/observability v0.7.1 h1:6OObzh2zk7wg75zYstcj0kjOjaxWc4joqA6qdeo8DP4=
588588
github.com/stackitcloud/stackit-sdk-go/services/observability v0.7.1/go.mod h1:+eNo7SEeVRuW7hgujSabSketScSUKGuC88UznPS+UTE=
589-
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.23.1 h1:E6vCqPn1NiPHnbnvqLNQNz6a/cmeyRb5iA9cDUPtP58=
590-
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.23.1/go.mod h1:ifKKKCWL1U435fXGQ375SPX+burtfg1I7EGZ58COzRA=
589+
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.23.0 h1:/OaZCyrD8LFa4W6a2Vu2QSVMJwLLBr8ZdBKzX00MV1Q=
590+
github.com/stackitcloud/stackit-sdk-go/services/opensearch v0.23.0/go.mod h1:c30J6f/fXtbzcHkH3ZcabZUek3wfy5CRnEkcW5e5yXg=
591591
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.1.0 h1:r29a9GoBLVw2VZSzdPftlIsE5t7shdxobwoT6NVUIjU=
592592
github.com/stackitcloud/stackit-sdk-go/services/postgresflex v1.1.0/go.mod h1:4g/L5PHfz1xk3udEhvPy2nXiH4UgRO5Cj6iwUa7k5VQ=
593593
github.com/stackitcloud/stackit-sdk-go/services/rabbitmq v0.24.1 h1:2rDFwJtZOFYFUiJqJ9uIwM+mu+BbtuVaUHARRJtrZPU=

internal/cmd/volume/create/create.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,20 +174,11 @@ func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APICli
174174
Type: model.SourceType,
175175
}
176176

177-
var labelsMap *map[string]interface{}
178-
if model.Labels != nil && len(*model.Labels) > 0 {
179-
// convert map[string]string to map[string]interface{}
180-
labelsMap = utils.Ptr(map[string]interface{}{})
181-
for k, v := range *model.Labels {
182-
(*labelsMap)[k] = v
183-
}
184-
}
185-
186177
payload := iaas.CreateVolumePayload{
187178
AvailabilityZone: model.AvailabilityZone,
188179
Name: model.Name,
189180
Description: model.Description,
190-
Labels: labelsMap,
181+
Labels: utils.ConvertStringMapToInterfaceMap(model.Labels),
191182
PerformanceClass: model.PerformanceClass,
192183
Size: model.Size,
193184
}

internal/cmd/volume/update/update.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,10 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
135135
func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiUpdateVolumeRequest {
136136
req := apiClient.UpdateVolume(ctx, model.ProjectId, model.VolumeId)
137137

138-
var labelsMap *map[string]interface{}
139-
if model.Labels != nil && len(*model.Labels) > 0 {
140-
// convert map[string]string to map[string]interface{}
141-
labelsMap = utils.Ptr(map[string]interface{}{})
142-
for k, v := range *model.Labels {
143-
(*labelsMap)[k] = v
144-
}
145-
}
146-
147138
payload := iaas.UpdateVolumePayload{
148139
Name: model.Name,
149140
Description: model.Description,
150-
Labels: labelsMap,
141+
Labels: utils.ConvertStringMapToInterfaceMap(model.Labels),
151142
}
152143

153144
return req.UpdateVolumePayload(payload)

0 commit comments

Comments
 (0)