Skip to content

Commit 246b6f4

Browse files
committed
fix labelselector, config volumeID
1 parent 2051944 commit 246b6f4

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

internal/cmd/volume/snapshot/create/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
118118
}
119119

120120
func configureFlags(cmd *cobra.Command) {
121-
cmd.Flags().Var(flags.UUIDFlag(), volumeIdFlag, "Volume ID")
121+
cmd.Flags().Var(flags.UUIDFlag(), volumeIdFlag, "ID of the volume from which a snapshot should be created")
122122
cmd.Flags().String(nameFlag, "", "Name of the snapshot")
123123
cmd.Flags().StringToString(labelsFlag, nil, "Key-value string pairs as labels")
124124

internal/cmd/volume/snapshot/list/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command) (*inputModel, error) {
139139
func buildRequest(ctx context.Context, model *inputModel, apiClient *iaas.APIClient) iaas.ApiListSnapshotsRequest {
140140
req := apiClient.ListSnapshots(ctx, model.ProjectId)
141141
if model.LabelSelector != nil {
142-
req.LabelSelector(*model.LabelSelector)
142+
req = req.LabelSelector(*model.LabelSelector)
143143
}
144144
return req
145145
}

internal/cmd/volume/snapshot/list/list_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
5252

5353
func fixtureRequest(mods ...func(request *iaas.ApiListSnapshotsRequest)) iaas.ApiListSnapshotsRequest {
5454
request := testClient.ListSnapshots(testCtx, testProjectId)
55+
request = request.LabelSelector("key1=value1")
5556
for _, mod := range mods {
5657
mod(&request)
5758
}
@@ -174,6 +175,15 @@ func TestBuildRequest(t *testing.T) {
174175
model: fixtureInputModel(),
175176
expectedRequest: fixtureRequest(),
176177
},
178+
{
179+
description: "without label selector",
180+
model: fixtureInputModel(func(model *inputModel) {
181+
model.LabelSelector = nil
182+
}),
183+
expectedRequest: fixtureRequest(func(request *iaas.ApiListSnapshotsRequest) {
184+
*request = testClient.ListSnapshots(testCtx, testProjectId)
185+
}),
186+
},
177187
}
178188

179189
for _, tt := range tests {

0 commit comments

Comments
 (0)