Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/v1/hypervisor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ type Aggregate struct {

// UUID is the unique identifier of the aggregate.
UUID string `json:"uuid"`

// Metadata is the metadata of the aggregate as key-value pairs.
// +kubebuilder:validation:Optional
Metadata map[string]string `json:"metadata,omitempty"`
}

type HyperVisorUpdateStatus struct {
Expand Down
11 changes: 10 additions & 1 deletion api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 17 additions & 2 deletions applyconfigurations/api/v1/aggregate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ spec:
description: Aggregate represents an OpenStack aggregate with its
name and UUID.
properties:
metadata:
additionalProperties:
type: string
description: Metadata is the metadata of the aggregate as key-value
pairs.
type: object
name:
description: Name is the name of the aggregate.
type: string
Expand Down
5 changes: 3 additions & 2 deletions internal/openstack/aggregates.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ func ApplyAggregates(ctx context.Context, serviceClient *gophercloud.ServiceClie
for _, name := range desiredAggregates {
agg := aggregateMap[name] // exists as per "Verify all desired aggregates exist" check
result = append(result, kvmv1.Aggregate{
Name: agg.Name,
UUID: agg.UUID,
Name: agg.Name,
UUID: agg.UUID,
Metadata: agg.Metadata,
})
}

Expand Down
11 changes: 9 additions & 2 deletions internal/openstack/aggregates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ var _ = Describe("ApplyAggregates", func() {
"deleted": false,
"id": 1,
"uuid": "uuid-agg1",
"hosts": ["test-host"]
"hosts": ["test-host"],
"metadata": {"key1": "value1", "key2": "value2"}
},
{
"name": "agg2",
Expand All @@ -54,7 +55,8 @@ var _ = Describe("ApplyAggregates", func() {
"deleted": false,
"id": 3,
"uuid": "uuid-agg3",
"hosts": []
"hosts": [],
"metadata": {}
}
]
}`
Expand Down Expand Up @@ -119,12 +121,17 @@ var _ = Describe("ApplyAggregates", func() {
// Check we have the right aggregates by name and UUID
names := make([]string, len(aggregates))
uuids := make([]string, len(aggregates))
metadata := make([]map[string]string, len(aggregates))
for i, agg := range aggregates {
names[i] = agg.Name
uuids[i] = agg.UUID
metadata[i] = agg.Metadata
}
Expect(names).To(ConsistOf("agg1", "agg2", "agg3"))
Expect(uuids).To(ConsistOf("uuid-agg1", "uuid-agg2", "uuid-agg3"))
Expect(metadata[0]).To(Equal(map[string]string{"key1": "value1", "key2": "value2"})) // agg1 metadata should be preserved
Expect(metadata[1]).To(BeNil()) // agg2 has no metadata field, should be nil
Expect(metadata[2]).To(BeEmpty()) // agg3 has empty metadata, should be preserved
})
})

Expand Down
Loading