Skip to content

Commit 13cc828

Browse files
committed
Use key for SwiftContainer metadata entries
1 parent bae438f commit 13cc828

15 files changed

Lines changed: 55 additions & 55 deletions

File tree

api/v1alpha1/swiftcontainer_types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ type SwiftContainerName string
2727
// SwiftContainerMetadata defines a key-value pair to be set as a Swift
2828
// container metadata header (X-Container-Meta-<key>: <value>).
2929
type SwiftContainerMetadata struct {
30-
// name is the name of the metadata item. It will be used as the suffix of
30+
// key is the key of the metadata item. It will be used as the suffix of
3131
// the X-Container-Meta-* header.
3232
// +kubebuilder:validation:MinLength:=1
3333
// +kubebuilder:validation:MaxLength:=255
3434
// +required
35-
Name string `json:"name,omitempty"`
35+
Key string `json:"key,omitempty"`
3636

3737
// value is the value of the metadata item.
3838
// +kubebuilder:validation:MaxLength:=255
@@ -43,11 +43,11 @@ type SwiftContainerMetadata struct {
4343
// SwiftContainerMetadataStatus represents an observed metadata key-value pair
4444
// on a Swift container.
4545
type SwiftContainerMetadataStatus struct {
46-
// name is the name of the metadata item.
46+
// key is the key of the metadata item.
4747
// +kubebuilder:validation:MinLength:=1
4848
// +kubebuilder:validation:MaxLength:=255
4949
// +required
50-
Name string `json:"name,omitempty"`
50+
Key string `json:"key,omitempty"`
5151

5252
// value is the value of the metadata item.
5353
// +kubebuilder:validation:MaxLength:=255
@@ -103,7 +103,7 @@ type SwiftContainerResourceSpec struct {
103103
// X-Container-Meta-* headers on the Swift container.
104104
// +kubebuilder:validation:MaxItems:=64
105105
// +listType=map
106-
// +listMapKey=name
106+
// +listMapKey=key
107107
// +optional
108108
Metadata []SwiftContainerMetadata `json:"metadata,omitempty"`
109109

@@ -152,7 +152,7 @@ type SwiftContainerResourceStatus struct {
152152
// metadata is the list of observed metadata key-value pairs on the container.
153153
// +kubebuilder:validation:MaxItems:=64
154154
// +listType=map
155-
// +listMapKey=name
155+
// +listMapKey=key
156156
// +optional
157157
Metadata []SwiftContainerMetadataStatus `json:"metadata,omitempty"`
158158

cmd/models-schema/zz_generated.openapi.go

Lines changed: 8 additions & 8 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_swiftcontainers.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ spec:
185185
SwiftContainerMetadata defines a key-value pair to be set as a Swift
186186
container metadata header (X-Container-Meta-<key>: <value>).
187187
properties:
188-
name:
188+
key:
189189
description: |-
190-
name is the name of the metadata item. It will be used as the suffix of
190+
key is the key of the metadata item. It will be used as the suffix of
191191
the X-Container-Meta-* header.
192192
maxLength: 255
193193
minLength: 1
@@ -197,13 +197,13 @@ spec:
197197
maxLength: 255
198198
type: string
199199
required:
200-
- name
200+
- key
201201
- value
202202
type: object
203203
maxItems: 64
204204
type: array
205205
x-kubernetes-list-map-keys:
206-
- name
206+
- key
207207
x-kubernetes-list-type: map
208208
name:
209209
description: |-
@@ -359,8 +359,8 @@ spec:
359359
SwiftContainerMetadataStatus represents an observed metadata key-value pair
360360
on a Swift container.
361361
properties:
362-
name:
363-
description: name is the name of the metadata item.
362+
key:
363+
description: key is the key of the metadata item.
364364
maxLength: 255
365365
minLength: 1
366366
type: string
@@ -369,12 +369,12 @@ spec:
369369
maxLength: 255
370370
type: string
371371
required:
372-
- name
372+
- key
373373
type: object
374374
maxItems: 64
375375
type: array
376376
x-kubernetes-list-map-keys:
377-
- name
377+
- key
378378
x-kubernetes-list-type: map
379379
name:
380380
description: name is the name of the Swift container.

examples/swiftcontainer/full.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ spec:
1212
name: my-custom-bucket
1313
# metadata sets arbitrary key-value pairs as X-Container-Meta-* headers.
1414
metadata:
15-
- name: owner
15+
- key: owner
1616
value: myteam
17-
- name: environment
17+
- key: environment
1818
value: production
1919
# containerRead sets the X-Container-Read ACL. Use ".r:*" for public read access.
2020
containerRead: .r:*,.rlistings

internal/controllers/swiftcontainer/actuator.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (actuator swiftcontainerActuator) CreateResource(ctx context.Context, obj o
209209
if len(resource.Metadata) > 0 {
210210
metadata := make(map[string]string, len(resource.Metadata))
211211
for _, m := range resource.Metadata {
212-
metadata[m.Name] = m.Value
212+
metadata[m.Key] = m.Value
213213
}
214214
createOpts.Metadata = metadata
215215
}
@@ -322,7 +322,7 @@ func (actuator swiftcontainerActuator) reconcileMetadata(ctx context.Context, or
322322
// in Swift).
323323
desiredMetadata := make(map[string]string, len(resource.Metadata))
324324
for _, m := range resource.Metadata {
325-
desiredMetadata[strings.ToLower(m.Name)] = m.Value
325+
desiredMetadata[strings.ToLower(m.Key)] = m.Value
326326
}
327327

328328
// Find keys to add/update and keys to remove.

internal/controllers/swiftcontainer/actuator_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ func TestListOSResourcesForAdoption(t *testing.T) {
396396
actuator := swiftcontainerActuator{client}
397397
orcObject := newSwiftContainerObject("my-object", &orcv1alpha1.SwiftContainerResourceSpec{
398398
Metadata: []orcv1alpha1.SwiftContainerMetadata{
399-
{Name: "env", Value: "prod"},
400-
{Name: "team", Value: "infra"},
399+
{Key: "env", Value: "prod"},
400+
{Key: "team", Value: "infra"},
401401
},
402402
})
403403

@@ -471,8 +471,8 @@ func TestCreateResource(t *testing.T) {
471471
orcObject := newSwiftContainerObject("full-container", &orcv1alpha1.SwiftContainerResourceSpec{
472472
Name: ptr.To[orcv1alpha1.SwiftContainerName]("full-container"),
473473
Metadata: []orcv1alpha1.SwiftContainerMetadata{
474-
{Name: "project", Value: "orc"},
475-
{Name: "env", Value: "test"},
474+
{Key: "project", Value: "orc"},
475+
{Key: "env", Value: "test"},
476476
},
477477
ContainerRead: ".r:*",
478478
ContainerWrite: "account:user",

internal/controllers/swiftcontainer/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (swiftcontainerStatusWriter) ApplyResourceStatus(_ logr.Logger, osResource
8888
for _, k := range keys {
8989
resourceStatus.WithMetadata(
9090
orcapplyconfigv1alpha1.SwiftContainerMetadataStatus().
91-
WithName(k).
91+
WithKey(k).
9292
WithValue(osResource.Metadata[k]),
9393
)
9494
}

internal/controllers/swiftcontainer/tests/swiftcontainer-create-full/00-assert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ assertAll:
3030
- celExpr: "swiftcontainer.status.id != ''"
3131
- celExpr: "swiftcontainer.status.id == 'swiftcontainer-create-full-override'"
3232
- celExpr: "has(swiftcontainer.status.resource.metadata)"
33-
- celExpr: "swiftcontainer.status.resource.metadata.exists(m, m.name == 'Environment' && m.value == 'test')"
34-
- celExpr: "swiftcontainer.status.resource.metadata.exists(m, m.name == 'Owner' && m.value == 'orc-e2e')"
33+
- celExpr: "swiftcontainer.status.resource.metadata.exists(m, m.key == 'Environment' && m.value == 'test')"
34+
- celExpr: "swiftcontainer.status.resource.metadata.exists(m, m.key == 'Owner' && m.value == 'orc-e2e')"

internal/controllers/swiftcontainer/tests/swiftcontainer-create-full/00-create-resource.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ spec:
1111
resource:
1212
name: swiftcontainer-create-full-override
1313
metadata:
14-
- name: environment
14+
- key: environment
1515
value: test
16-
- name: owner
16+
- key: owner
1717
value: orc-e2e
1818
containerRead: ".r:*,.rlistings"
1919
containerWrite: "openstack:*"

internal/controllers/swiftcontainer/tests/swiftcontainer-update/01-assert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ resourceRefs:
99
assertAll:
1010
- celExpr: "swiftcontainer.status.id == 'swiftcontainer-update'"
1111
- celExpr: "has(swiftcontainer.status.resource.metadata)"
12-
- celExpr: "swiftcontainer.status.resource.metadata.exists(m, m.name == 'Environment' && m.value == 'staging')"
13-
- celExpr: "swiftcontainer.status.resource.metadata.exists(m, m.name == 'Team' && m.value == 'platform')"
12+
- celExpr: "swiftcontainer.status.resource.metadata.exists(m, m.key == 'Environment' && m.value == 'staging')"
13+
- celExpr: "swiftcontainer.status.resource.metadata.exists(m, m.key == 'Team' && m.value == 'platform')"
1414
- celExpr: "swiftcontainer.status.resource.containerRead == '.r:*,.rlistings'"
1515
- celExpr: "swiftcontainer.status.resource.containerWrite == 'openstack:*'"
1616
---

0 commit comments

Comments
 (0)