Skip to content

Commit 13dfd73

Browse files
committed
Add descrioption to filter
1 parent 67fdc36 commit 13dfd73

10 files changed

Lines changed: 49 additions & 7 deletions

File tree

api/v1alpha1/volumesnapshot_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ type VolumeSnapshotFilter struct {
5656
// +optional
5757
Name *OpenStackName `json:"name,omitempty"`
5858

59+
// description of the existing resource
60+
// +kubebuilder:validation:MinLength:=1
61+
// +kubebuilder:validation:MaxLength:=255
62+
// +optional
63+
Description *string `json:"description,omitempty"`
64+
5965
// status of the existing resource
6066
// +kubebuilder:validation:MinLength:=1
6167
// +kubebuilder:validation:MaxLength:=255

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/models-schema/zz_generated.openapi.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/openstack.k-orc.cloud_volumesnapshots.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ spec:
9191
error state and will not continue to retry.
9292
minProperties: 1
9393
properties:
94+
description:
95+
description: description of the existing resource
96+
maxLength: 255
97+
minLength: 1
98+
type: string
9499
name:
95100
description: name of the existing resource
96101
maxLength: 255

internal/controllers/volumesnapshot/actuator.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,21 @@ func (actuator volumesnapshotActuator) ListOSResourcesForAdoption(ctx context.Co
9292
}
9393

9494
func (actuator volumesnapshotActuator) ListOSResourcesForImport(ctx context.Context, obj orcObjectPT, filter filterT) (iter.Seq2[*osResourceT, error], progress.ReconcileStatus) {
95+
var filters []osclients.ResourceFilter[osResourceT]
96+
97+
if filter.Description != nil {
98+
filters = append(filters, func(s *snapshots.Snapshot) bool {
99+
return s.Description == *filter.Description
100+
})
101+
}
102+
95103
listOpts := snapshots.ListOpts{
96104
Name: string(ptr.Deref(filter.Name, "")),
97105
Status: ptr.Deref(filter.Status, ""),
98106
VolumeID: ptr.Deref(filter.VolumeID, ""),
99107
}
100108

101-
return actuator.osClient.ListVolumeSnapshots(ctx, listOpts), nil
109+
return actuator.listOSResources(ctx, filters, listOpts), nil
102110
}
103111

104112
func (actuator volumesnapshotActuator) listOSResources(ctx context.Context, filters []osclients.ResourceFilter[osResourceT], listOpts snapshots.ListOptsBuilder) iter.Seq2[*snapshots.Snapshot, error] {

internal/controllers/volumesnapshot/tests/volumesnapshot-import-error/00-create-resources.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ spec:
2121
secretName: openstack-clouds
2222
managementPolicy: managed
2323
resource:
24-
name: volumesnapshot-import-error-external
2524
description: VolumeSnapshot from "import error" test
2625
volumeRef: volumesnapshot-import-error
2726
---
@@ -35,6 +34,5 @@ spec:
3534
secretName: openstack-clouds
3635
managementPolicy: managed
3736
resource:
38-
name: volumesnapshot-import-error-external
3937
description: VolumeSnapshot from "import error" test
4038
volumeRef: volumesnapshot-import-error

internal/controllers/volumesnapshot/tests/volumesnapshot-import-error/01-import-resource.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ spec:
1010
managementPolicy: unmanaged
1111
import:
1212
filter:
13-
name: volumesnapshot-import-error-external
13+
description: VolumeSnapshot from "import error" test

pkg/clients/applyconfiguration/api/v1alpha1/volumesnapshotfilter.go

Lines changed: 12 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/clients/applyconfiguration/internal/internal.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/docs/crd-reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,6 +4420,7 @@ _Appears in:_
44204420
| Field | Description | Default | Validation |
44214421
| --- | --- | --- | --- |
44224422
| `name` _[OpenStackName](#openstackname)_ | name of the existing resource | | MaxLength: 255 <br />MinLength: 1 <br />Pattern: `^[^,]+$` <br /> |
4423+
| `description` _string_ | description of the existing resource | | MaxLength: 255 <br />MinLength: 1 <br /> |
44234424
| `status` _string_ | status of the existing resource | | MaxLength: 255 <br />MinLength: 1 <br /> |
44244425
| `volumeID` _string_ | volumeID is the ID of the volume the snapshot was created from | | MaxLength: 255 <br />MinLength: 1 <br /> |
44254426

0 commit comments

Comments
 (0)