Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️Move CloudName into IdentityRef and make cluster IdentityRef required #1915

Merged
merged 1 commit into from
Feb 29, 2024
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
28 changes: 28 additions & 0 deletions api/v1alpha5/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha5_OpenStackClusterSpec(in *i
out.AllowAllInClusterTraffic = in.ManagedSecurityGroups.AllowAllInClusterTraffic
}

out.CloudName = in.IdentityRef.CloudName
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}

return nil
}

Expand Down Expand Up @@ -258,6 +261,11 @@ func Convert_v1alpha5_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
}
}

out.IdentityRef.CloudName = in.CloudName
if in.IdentityRef != nil {
out.IdentityRef.Name = in.IdentityRef.Name
}

return nil
}

Expand Down Expand Up @@ -321,6 +329,16 @@ func Convert_v1alpha5_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(in *O
}
out.Image = imageFilter

if in.IdentityRef != nil {
out.IdentityRef = &infrav1.OpenStackIdentityReference{Name: in.IdentityRef.Name}
}
if in.CloudName != "" {
if out.IdentityRef == nil {
out.IdentityRef = &infrav1.OpenStackIdentityReference{}
}
out.IdentityRef.CloudName = in.CloudName
}

return nil
}

Expand Down Expand Up @@ -606,6 +624,11 @@ func Convert_v1beta1_OpenStackMachineSpec_To_v1alpha5_OpenStackMachineSpec(in *i
out.ImageUUID = in.Image.ID
}

if in.IdentityRef != nil {
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}
out.CloudName = in.IdentityRef.CloudName
}

return nil
}

Expand Down Expand Up @@ -690,3 +713,8 @@ func Convert_v1alpha5_SecurityGroup_To_v1beta1_SecurityGroupStatus(in *SecurityG
func Convert_v1alpha5_OpenStackIdentityReference_To_v1beta1_OpenStackIdentityReference(in *OpenStackIdentityReference, out *infrav1.OpenStackIdentityReference, s conversion.Scope) error {
return autoConvert_v1alpha5_OpenStackIdentityReference_To_v1beta1_OpenStackIdentityReference(in, out, s)
}

func Convert_v1beta1_OpenStackIdentityReference_To_v1alpha5_OpenStackIdentityReference(in *infrav1.OpenStackIdentityReference, out *OpenStackIdentityReference, _ conversion.Scope) error {
out.Name = in.Name
return nil
}
20 changes: 14 additions & 6 deletions api/v1alpha5/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ func TestConvertFrom(t *testing.T) {
Spec: infrav1.OpenStackClusterSpec{},
},
want: &OpenStackCluster{
Spec: OpenStackClusterSpec{},
Spec: OpenStackClusterSpec{
IdentityRef: &OpenStackIdentityReference{},
},
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"managedSecurityGroups\":null,\"network\":{}},\"status\":{\"ready\":false}}",
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"apiServerLoadBalancer\":{},\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"},\"managedSecurityGroups\":null,\"network\":{}},\"status\":{\"ready\":false}}",
},
},
},
Expand All @@ -61,10 +63,16 @@ func TestConvertFrom(t *testing.T) {
Spec: infrav1.OpenStackClusterTemplateSpec{},
},
want: &OpenStackClusterTemplate{
Spec: OpenStackClusterTemplateSpec{},
Spec: OpenStackClusterTemplateSpec{
Template: OpenStackClusterTemplateResource{
Spec: OpenStackClusterSpec{
IdentityRef: &OpenStackIdentityReference{},
},
},
},
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"apiServerLoadBalancer\":{},\"cloudName\":\"\",\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"managedSecurityGroups\":null,\"network\":{}}}}}",
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"apiServerLoadBalancer\":{},\"controlPlaneEndpoint\":{\"host\":\"\",\"port\":0},\"disableAPIServerFloatingIP\":false,\"disableExternalNetwork\":false,\"externalNetwork\":{},\"identityRef\":{\"cloudName\":\"\",\"name\":\"\"},\"managedSecurityGroups\":null,\"network\":{}}}}}",
},
},
},
Expand All @@ -79,7 +87,7 @@ func TestConvertFrom(t *testing.T) {
Spec: OpenStackMachineSpec{},
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"cloudName\":\"\",\"flavor\":\"\",\"image\":{}},\"status\":{\"dependentResources\":{},\"ready\":false,\"referencedResources\":{}}}",
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"flavor\":\"\",\"image\":{}},\"status\":{\"dependentResources\":{},\"ready\":false,\"referencedResources\":{}}}",
},
},
},
Expand All @@ -94,7 +102,7 @@ func TestConvertFrom(t *testing.T) {
Spec: OpenStackMachineTemplateSpec{},
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"cloudName\":\"\",\"flavor\":\"\",\"image\":{}}}}}",
"cluster.x-k8s.io/conversion-data": "{\"spec\":{\"template\":{\"spec\":{\"flavor\":\"\",\"image\":{}}}}}",
},
},
},
Expand Down
42 changes: 10 additions & 32 deletions api/v1alpha5/zz_generated.conversion.go

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

28 changes: 28 additions & 0 deletions api/v1alpha6/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,16 @@ func Convert_v1alpha6_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(in *O
out.ServerMetadata = serverMetadata
}

if in.IdentityRef != nil {
out.IdentityRef = &infrav1.OpenStackIdentityReference{Name: in.IdentityRef.Name}
}
if in.CloudName != "" {
if out.IdentityRef == nil {
out.IdentityRef = &infrav1.OpenStackIdentityReference{}
}
out.IdentityRef.CloudName = in.CloudName
}

return nil
}

Expand Down Expand Up @@ -624,6 +634,9 @@ func Convert_v1beta1_OpenStackClusterSpec_To_v1alpha6_OpenStackClusterSpec(in *i
out.AllowAllInClusterTraffic = in.ManagedSecurityGroups.AllowAllInClusterTraffic
}

out.CloudName = in.IdentityRef.CloudName
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}

return nil
}

Expand Down Expand Up @@ -667,6 +680,11 @@ func Convert_v1alpha6_OpenStackClusterSpec_To_v1beta1_OpenStackClusterSpec(in *O
}
}

out.IdentityRef.CloudName = in.CloudName
if in.IdentityRef != nil {
out.IdentityRef.Name = in.IdentityRef.Name
}

return nil
}

Expand Down Expand Up @@ -973,6 +991,11 @@ func Convert_v1beta1_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in *i
out.ServerMetadata = serverMetadata
}

if in.IdentityRef != nil {
out.IdentityRef = &OpenStackIdentityReference{Name: in.IdentityRef.Name}
out.CloudName = in.IdentityRef.CloudName
}

return nil
}

Expand Down Expand Up @@ -1069,3 +1092,8 @@ func Convert_v1alpha6_SecurityGroup_To_v1beta1_SecurityGroupStatus(in *SecurityG
func Convert_v1alpha6_OpenStackIdentityReference_To_v1beta1_OpenStackIdentityReference(in *OpenStackIdentityReference, out *infrav1.OpenStackIdentityReference, s apiconversion.Scope) error {
return autoConvert_v1alpha6_OpenStackIdentityReference_To_v1beta1_OpenStackIdentityReference(in, out, s)
}

func Convert_v1beta1_OpenStackIdentityReference_To_v1alpha6_OpenStackIdentityReference(in *infrav1.OpenStackIdentityReference, out *OpenStackIdentityReference, _ apiconversion.Scope) error {
out.Name = in.Name
return nil
}
Loading