Skip to content

Commit 19ddf0a

Browse files
authored
Merge pull request #2148 from spjmurray/flavor_ids
✨ Support Flavor IDs
2 parents ddc26ee + 32b19de commit 19ddf0a

File tree

51 files changed

+658
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+658
-175
lines changed

api/v1alpha1/openstackserver_types.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232
)
3333

3434
// OpenStackServerSpec defines the desired state of OpenStackServer.
35+
// +kubebuilder:validation:XValidation:message="at least one of flavor or flavorID must be set",rule=(has(self.flavor) || has(self.flavorID))
3536
type OpenStackServerSpec struct {
3637
// AdditionalBlockDevices is a list of specifications for additional block devices to attach to the server instance.
3738
// +listType=map
@@ -48,8 +49,15 @@ type OpenStackServerSpec struct {
4849
ConfigDrive optional.Bool `json:"configDrive,omitempty"`
4950

5051
// The flavor reference for the flavor for the server instance.
51-
// +required
52-
Flavor string `json:"flavor"`
52+
// +optional
53+
// +kubebuilder:validation:MinLength=1
54+
Flavor *string `json:"flavor,omitempty"`
55+
56+
// FlavorID allows flavors to be specified by ID. This field takes precedence
57+
// over Flavor.
58+
// +optional
59+
// +kubebuilder:validation:MinLength=1
60+
FlavorID *string `json:"flavorID,omitempty"`
5361

5462
// FloatingIPPoolRef is a reference to a FloatingIPPool to allocate a floating IP from.
5563
// +optional

api/v1alpha1/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ type ResolvedServerSpec struct {
3030
// +optional
3131
ImageID string `json:"imageID,omitempty"`
3232

33+
// FlavorID is the ID of the flavor to use.
34+
// +optional
35+
FlavorID string `json:"flavorID,omitempty"`
36+
3337
// Ports is the fully resolved list of ports to create for the server.
3438
// +optional
3539
Ports []infrav1.ResolvedPortSpec `json:"ports,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

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

api/v1alpha6/conversion_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -582,10 +582,10 @@ func TestMachineConversionControllerSpecFields(t *testing.T) {
582582
{
583583
name: "Non-ignored change",
584584
modifyUp: func(up *infrav1.OpenStackMachine) {
585-
up.Spec.Flavor = "new-flavor"
585+
up.Spec.Flavor = ptr.To("new-flavor")
586586
},
587587
testAfter: func(g gomega.Gomega, after *OpenStackMachine) {
588-
g.Expect(after.Spec.Flavor).To(gomega.Equal("new-flavor"))
588+
g.Expect(after.Spec.Flavor).To(gomega.Equal(ptr.To("new-flavor")))
589589
},
590590
expectNetworkDiff: true,
591591
},
@@ -613,11 +613,11 @@ func TestMachineConversionControllerSpecFields(t *testing.T) {
613613
name: "Set ProviderID and non-ignored change",
614614
modifyUp: func(up *infrav1.OpenStackMachine) {
615615
up.Spec.ProviderID = ptr.To("new-provider-id")
616-
up.Spec.Flavor = "new-flavor"
616+
up.Spec.Flavor = ptr.To("new-flavor")
617617
},
618618
testAfter: func(g gomega.Gomega, after *OpenStackMachine) {
619619
g.Expect(after.Spec.ProviderID).To(gomega.Equal(ptr.To("new-provider-id")))
620-
g.Expect(after.Spec.Flavor).To(gomega.Equal("new-flavor"))
620+
g.Expect(after.Spec.Flavor).To(gomega.Equal(ptr.To("new-flavor")))
621621
},
622622
expectNetworkDiff: true,
623623
},

api/v1alpha6/openstackmachine_types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ type OpenStackMachineSpec struct {
4343
CloudName string `json:"cloudName"`
4444

4545
// The flavor reference for the flavor for your server instance.
46-
Flavor string `json:"flavor"`
46+
// +kubebuilder:validation:MinLength=1
47+
Flavor *string `json:"flavor,omitempty"`
48+
49+
// FlavorID allows flavors to be specified by ID. This field takes precedence
50+
// over Flavor.
51+
// +kubebuilder:validation:MinLength=1
52+
FlavorID *string `json:"flavorID,omitempty"`
4753

4854
// The name of the image to use for your server instance.
4955
// If the RootVolume is specified, this will be ignored and use rootVolume directly.

api/v1alpha6/zz_generated.conversion.go

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

api/v1alpha6/zz_generated.deepcopy.go

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

api/v1alpha7/conversion_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ func TestMachineConversionControllerSpecFields(t *testing.T) {
191191
{
192192
name: "Non-ignored change",
193193
modifyUp: func(up *infrav1.OpenStackMachine) {
194-
up.Spec.Flavor = "new-flavor"
194+
up.Spec.Flavor = ptr.To("new-flavor")
195195
},
196196
testAfter: func(g gomega.Gomega, after *OpenStackMachine) {
197-
g.Expect(after.Spec.Flavor).To(gomega.Equal("new-flavor"))
197+
g.Expect(after.Spec.Flavor).To(gomega.Equal(ptr.To("new-flavor")))
198198
},
199199
expectIdentityRefDiff: true,
200200
},
@@ -222,11 +222,11 @@ func TestMachineConversionControllerSpecFields(t *testing.T) {
222222
name: "Set ProviderID and non-ignored change",
223223
modifyUp: func(up *infrav1.OpenStackMachine) {
224224
up.Spec.ProviderID = ptr.To("new-provider-id")
225-
up.Spec.Flavor = "new-flavor"
225+
up.Spec.Flavor = ptr.To("new-flavor")
226226
},
227227
testAfter: func(g gomega.Gomega, after *OpenStackMachine) {
228228
g.Expect(after.Spec.ProviderID).To(gomega.Equal(ptr.To("new-provider-id")))
229-
g.Expect(after.Spec.Flavor).To(gomega.Equal("new-flavor"))
229+
g.Expect(after.Spec.Flavor).To(gomega.Equal(ptr.To("new-flavor")))
230230
},
231231
expectIdentityRefDiff: true,
232232
},

api/v1alpha7/openstackmachine_types.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,13 @@ type OpenStackMachineSpec struct {
4343
CloudName string `json:"cloudName"`
4444

4545
// The flavor reference for the flavor for your server instance.
46-
Flavor string `json:"flavor"`
46+
// +kubebuilder:validation:MinLength=1
47+
Flavor *string `json:"flavor,omitempty"`
48+
49+
// FlavorID allows flavors to be specified by ID. This field takes precedence
50+
// over Flavor.
51+
// +kubebuilder:validation:MinLength=1
52+
FlavorID *string `json:"flavorID,omitempty"`
4753

4854
// The name of the image to use for your server instance.
4955
// If the RootVolume is specified, this will be ignored and use rootVolume directly.

api/v1alpha7/zz_generated.conversion.go

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

0 commit comments

Comments
 (0)