Skip to content

Commit 9bd8ac4

Browse files
committed
Revert "customize v1beta1 affinity group conversion to v1beta2"
This reverts commit 9cefd10.
1 parent b3dd528 commit 9bd8ac4

File tree

5 files changed

+112
-59
lines changed

5 files changed

+112
-59
lines changed

api/v1beta1/cloudstackaffinitygroup_conversion.go

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ limitations under the License.
1717
package v1beta1
1818

1919
import (
20-
"context"
21-
conv "k8s.io/apimachinery/pkg/conversion"
2220
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
23-
"sigs.k8s.io/controller-runtime/pkg/client"
2421
"sigs.k8s.io/controller-runtime/pkg/conversion"
2522
)
2623

@@ -33,44 +30,3 @@ func (dst *CloudStackAffinityGroup) ConvertFrom(srcRaw conversion.Hub) error { /
3330
src := srcRaw.(*v1beta2.CloudStackAffinityGroup)
3431
return Convert_v1beta2_CloudStackAffinityGroup_To_v1beta1_CloudStackAffinityGroup(src, dst, nil)
3532
}
36-
37-
//nolint:golint,revive,stylecheck
38-
func Convert_v1beta1_CloudStackAffinityGroup_To_v1beta2_CloudStackAffinityGroup(in *CloudStackAffinityGroup, out *v1beta2.CloudStackAffinityGroup, s conv.Scope) error {
39-
out.ObjectMeta = in.ObjectMeta
40-
41-
csCluster := &v1beta2.CloudStackCluster{}
42-
clusterName := in.ObjectMeta.Labels["cluster.x-k8s.io/cluster-name"]
43-
namespace := in.ObjectMeta.Namespace
44-
key := client.ObjectKey{Name: clusterName, Namespace: namespace}
45-
if err := v1beta2.K8sClient.Get(context.TODO(), key, csCluster); err != nil {
46-
return err
47-
}
48-
49-
out.Spec = v1beta2.CloudStackAffinityGroupSpec{
50-
Type: in.Spec.Type,
51-
Name: in.Spec.Name,
52-
ID: in.Spec.ID,
53-
FailureDomainName: csCluster.Spec.FailureDomains[0].Name,
54-
}
55-
56-
out.Status = v1beta2.CloudStackAffinityGroupStatus{
57-
Ready: in.Status.Ready,
58-
}
59-
return nil
60-
}
61-
62-
//nolint:golint,revive,stylecheck
63-
func Convert_v1beta2_CloudStackAffinityGroup_To_v1beta1_CloudStackAffinityGroup(in *v1beta2.CloudStackAffinityGroup, out *CloudStackAffinityGroup, s conv.Scope) error {
64-
out.ObjectMeta = in.ObjectMeta
65-
66-
out.Spec = CloudStackAffinityGroupSpec{
67-
Type: in.Spec.Type,
68-
Name: in.Spec.Name,
69-
ID: in.Spec.ID,
70-
}
71-
72-
out.Status = CloudStackAffinityGroupStatus{
73-
Ready: in.Status.Ready,
74-
}
75-
return nil
76-
}

api/v1beta1/cloudstackaffinitygroup_types.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const (
2424
AffinityGroupFinalizer = "affinitygroup.infrastructure.cluster.x-k8s.io"
2525
)
2626

27-
//+k8s:conversion-gen=false
2827
// CloudStackAffinityGroupSpec defines the desired state of CloudStackAffinityGroup
2928
type CloudStackAffinityGroupSpec struct {
3029
// Mutually exclusive parameter with AffinityGroupIDs.
@@ -39,7 +38,6 @@ type CloudStackAffinityGroupSpec struct {
3938
ID string `json:"id,omitempty"`
4039
}
4140

42-
//+k8s:conversion-gen=false
4341
// CloudStackAffinityGroupStatus defines the observed state of CloudStackAffinityGroup
4442
type CloudStackAffinityGroupStatus struct {
4543
// Reflects the readiness of the CS Affinity Group.
@@ -48,7 +46,7 @@ type CloudStackAffinityGroupStatus struct {
4846

4947
//+kubebuilder:object:root=true
5048
//+kubebuilder:subresource:status
51-
//+k8s:conversion-gen=false
49+
5250
// CloudStackAffinityGroup is the Schema for the cloudstackaffinitygroups API
5351
type CloudStackAffinityGroup struct {
5452
metav1.TypeMeta `json:",inline"`

api/v1beta1/conversion_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2727
)
2828

29+
30+
2931
var _ = Describe("Conversion", func() {
3032
BeforeEach(func() { // Reset test vars to initial state.
3133
})

api/v1beta1/zz_generated.conversion.go

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

config/crd/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ patchesStrategicMerge:
2121
- patches/webhook_in_cloudstackmachines.yaml
2222
- patches/webhook_in_cloudstackmachinetemplates.yaml
2323
- patches/webhook_in_cloudstackisolatednetworks.yaml
24-
# - patches/webhook_in_cloudstackzones.yaml
24+
- patches/webhook_in_cloudstackzones.yaml
2525
- patches/webhook_in_cloudstackaffinitygroups.yaml
2626
- patches/webhook_in_cloudstackmachinestatecheckers.yaml
27-
# - patches/webhook_in_cloudstackfailuredomains.yaml
27+
- patches/webhook_in_cloudstackfailuredomains.yaml
2828
#+kubebuilder:scaffold:crdkustomizewebhookpatch
2929

3030
# patches here are for enabling the CA injection for each CRD

0 commit comments

Comments
 (0)