Skip to content

Commit b868824

Browse files
committed
add required backup payload
1 parent 088d62b commit b868824

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

internal/cmd/volume/backup/create/create.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/stackitcloud/stackit-cli/internal/pkg/projectname"
1717
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
1818
"github.com/stackitcloud/stackit-cli/internal/pkg/spinner"
19+
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1920

2021
"github.com/spf13/cobra"
2122
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
@@ -184,6 +185,25 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
184185

185186
func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiCreateBackupRequest {
186187
req := apiClient.CreateBackup(ctx, model.ProjectId)
188+
189+
// Convert map[string]string to map[string]interface{}
190+
var labelsMap *map[string]interface{}
191+
if len(model.Labels) > 0 {
192+
labelsMap = utils.Ptr(map[string]interface{}{})
193+
for k, v := range model.Labels {
194+
(*labelsMap)[k] = v
195+
}
196+
}
197+
198+
createPayload := iaas.NewCreateBackupPayloadWithDefaults()
199+
createPayload.Name = model.Name
200+
createPayload.Labels = labelsMap
201+
createPayload.Source = &iaas.BackupSource{
202+
Id: &model.SourceID,
203+
Type: &model.SourceType,
204+
}
205+
206+
req = req.CreateBackupPayload(*createPayload)
187207
return req
188208
}
189209

0 commit comments

Comments
 (0)