Skip to content

Commit

Permalink
Merge pull request #1991 from shiftstack/servergroupparam
Browse files Browse the repository at this point in the history
⚠️ ServerGroupFilter to ServerGroupParam
  • Loading branch information
k8s-ci-robot authored Apr 2, 2024
2 parents f5b0181 + 8ea3ccf commit e636957
Show file tree
Hide file tree
Showing 19 changed files with 243 additions and 68 deletions.
8 changes: 3 additions & 5 deletions api/v1alpha5/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,7 @@ func Convert_v1alpha5_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(in *O
}

if in.ServerGroupID != "" {
out.ServerGroup = &infrav1.ServerGroupFilter{ID: in.ServerGroupID}
} else {
out.ServerGroup = &infrav1.ServerGroupFilter{}
out.ServerGroup = &infrav1.ServerGroupParam{ID: &in.ServerGroupID}
}

imageParam := infrav1.ImageParam{}
Expand Down Expand Up @@ -682,8 +680,8 @@ func Convert_v1beta1_OpenStackMachineSpec_To_v1alpha5_OpenStackMachineSpec(in *i
return err
}

if in.ServerGroup != nil {
out.ServerGroupID = in.ServerGroup.ID
if in.ServerGroup != nil && in.ServerGroup.ID != nil {
out.ServerGroupID = *in.ServerGroup.ID
}

if in.Image.ID != nil {
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha6/openstackcluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ func Convert_v1alpha6_Bastion_To_v1beta1_Bastion(in *Bastion, out *infrav1.Basti
}

if in.Instance.ServerGroupID != "" {
out.Spec.ServerGroup = &infrav1.ServerGroupFilter{ID: in.Instance.ServerGroupID}
out.Spec.ServerGroup = &infrav1.ServerGroupParam{ID: &in.Instance.ServerGroupID}
} else {
out.Spec.ServerGroup = nil
}
Expand Down Expand Up @@ -471,8 +471,8 @@ func Convert_v1beta1_Bastion_To_v1alpha6_Bastion(in *infrav1.Bastion, out *Basti
return err
}

if in.Spec.ServerGroup != nil && in.Spec.ServerGroup.ID != "" {
out.Instance.ServerGroupID = in.Spec.ServerGroup.ID
if in.Spec.ServerGroup != nil && in.Spec.ServerGroup.ID != nil {
out.Instance.ServerGroupID = *in.Spec.ServerGroup.ID
}
}

Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha6/openstackmachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func Convert_v1alpha6_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(in *O
}

if in.ServerGroupID != "" {
out.ServerGroup = &infrav1.ServerGroupFilter{ID: in.ServerGroupID}
out.ServerGroup = &infrav1.ServerGroupParam{ID: &in.ServerGroupID}
} else {
out.ServerGroup = nil
}
Expand Down Expand Up @@ -336,8 +336,8 @@ func Convert_v1beta1_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in *i
return err
}

if in.ServerGroup != nil {
out.ServerGroupID = in.ServerGroup.ID
if in.ServerGroup != nil && in.ServerGroup.ID != nil {
out.ServerGroupID = *in.ServerGroup.ID
}

if in.Image.ID != nil {
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha7/openstackcluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func Convert_v1alpha7_Bastion_To_v1beta1_Bastion(in *Bastion, out *infrav1.Basti
}

if in.Instance.ServerGroupID != "" {
out.Spec.ServerGroup = &infrav1.ServerGroupFilter{ID: in.Instance.ServerGroupID}
out.Spec.ServerGroup = &infrav1.ServerGroupParam{ID: &in.Instance.ServerGroupID}
} else {
out.Spec.ServerGroup = nil
}
Expand Down Expand Up @@ -436,8 +436,8 @@ func Convert_v1beta1_Bastion_To_v1alpha7_Bastion(in *infrav1.Bastion, out *Basti
return err
}

if in.Spec.ServerGroup != nil && in.Spec.ServerGroup.ID != "" {
out.Instance.ServerGroupID = in.Spec.ServerGroup.ID
if in.Spec.ServerGroup != nil && in.Spec.ServerGroup.ID != nil {
out.Instance.ServerGroupID = *in.Spec.ServerGroup.ID
}
}

Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha7/openstackmachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func Convert_v1alpha7_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(in *O
}

if in.ServerGroupID != "" {
out.ServerGroup = &infrav1.ServerGroupFilter{ID: in.ServerGroupID}
out.ServerGroup = &infrav1.ServerGroupParam{ID: &in.ServerGroupID}
} else {
out.ServerGroup = nil
}
Expand Down Expand Up @@ -246,8 +246,8 @@ func Convert_v1beta1_OpenStackMachineSpec_To_v1alpha7_OpenStackMachineSpec(in *i
return err
}

if in.ServerGroup != nil {
out.ServerGroupID = in.ServerGroup.ID
if in.ServerGroup != nil && in.ServerGroup.ID != nil {
out.ServerGroupID = *in.ServerGroup.ID
}

if in.Image.ID != nil {
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/openstackmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ type OpenStackMachineSpec struct {

// The server group to assign the machine to.
// +optional
ServerGroup *ServerGroupFilter `json:"serverGroup,omitempty"`
ServerGroup *ServerGroupParam `json:"serverGroup,omitempty"`

// IdentityRef is a reference to a secret holding OpenStack credentials
// to be used when reconciling this machine. If not specified, the
Expand Down
25 changes: 23 additions & 2 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,30 @@ type AdditionalBlockDevice struct {
Storage BlockDeviceStorage `json:"storage"`
}

// ServerGroupParam specifies an OpenStack server group. It may be specified by ID or filter, but not both.
// +kubebuilder:validation:MaxProperties:=1
// +kubebuilder:validation:MinProperties:=1
type ServerGroupParam struct {
// ID is the ID of the server group to use.
// +kubebuilder:validation:Format:=uuid
ID optional.String `json:"id,omitempty"`

// Filter specifies a query to select an OpenStack server group. If provided, it cannot be empty.
Filter *ServerGroupFilter `json:"filter,omitempty"`
}

// ServerGroupFilter specifies a query to select an OpenStack server group. At least one property must be set.
// +kubebuilder:validation:MinProperties:=1
type ServerGroupFilter struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
// Name is the name of a server group to look for.
Name optional.String `json:"name,omitempty"`
}

func (f *ServerGroupFilter) IsZero() bool {
if f == nil {
return true
}
return f.Name == nil
}

// BlockDeviceType defines the type of block device to create.
Expand Down
34 changes: 32 additions & 2 deletions api/v1beta1/zz_generated.deepcopy.go

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

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

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

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

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

2 changes: 1 addition & 1 deletion controllers/openstackmachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func getDefaultOpenStackMachine() *infrav1.OpenStackMachine {
},
ConfigDrive: pointer.Bool(true),
SecurityGroups: []infrav1.SecurityGroupParam{},
ServerGroup: &infrav1.ServerGroupFilter{ID: serverGroupUUID},
ServerGroup: &infrav1.ServerGroupParam{ID: pointer.String(serverGroupUUID)},
},
Status: infrav1.OpenStackMachineStatus{
Resolved: &infrav1.ResolvedMachineSpec{
Expand Down
Loading

0 comments on commit e636957

Please sign in to comment.