Skip to content

Commit b7a45d1

Browse files
author
Joshua Reed
committed
Cleanup and fixup of tests.
1 parent d33a9f3 commit b7a45d1

15 files changed

+31
-80
lines changed

api/v1beta1/cloudstackcluster_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
const (
2727
ClusterFinalizer = "cloudstackcluster.infrastructure.cluster.x-k8s.io"
28-
defaultIdentityRefKind = "Secret"
2928
CloudStackClusterLabelName = "cloudstackcluster.infrastructure.cluster.x-k8s.io/name"
3029
NetworkTypeIsolated = "Isolated"
3130
NetworkTypeShared = "Shared"

api/v1beta2/cloudstackcluster_webhook_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ var _ = Describe("CloudStackCluster webhooks", func() {
5454
Ω(k8sClient.Create(ctx, dummies.CSCluster)).Should(MatchError(MatchRegexp(requiredRegex,
5555
"each Zone requires a Network specification")))
5656
})
57-
58-
It("Should reject a CloudStackCluster with IdentityRef not of kind 'Secret'", func() {
59-
Ω(k8sClient.Create(ctx, dummies.CSCluster)).
60-
Should(MatchError(MatchRegexp(forbiddenRegex, "must be a Secret")))
61-
})
6257
})
6358

6459
Context("When updating a CloudStackCluster", func() {
@@ -85,13 +80,5 @@ var _ = Describe("CloudStackCluster webhooks", func() {
8580
Ω(k8sClient.Update(ctx, dummies.CSCluster)).
8681
Should(MatchError(MatchRegexp(forbiddenRegex, "controlplaneendpoint\\.port")))
8782
})
88-
It("Should reject updates to the CloudStackCluster identity reference kind", func() {
89-
Ω(k8sClient.Update(ctx, dummies.CSCluster)).
90-
Should(MatchError(MatchRegexp(forbiddenRegex, "identityref\\.kind")))
91-
})
92-
It("Should reject updates to the CloudStackCluster identity reference name", func() {
93-
Ω(k8sClient.Update(ctx, dummies.CSCluster)).
94-
Should(MatchError(MatchRegexp(forbiddenRegex, "identityref\\.name")))
95-
})
9683
})
9784
})

api/v1beta2/cloudstackfailuredomain_types.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ const (
3030
type Network struct {
3131
// Cloudstack Network ID the cluster is built in.
3232
// +optional
33-
ID string `json:"id"`
33+
ID string `json:"id,omitempty"`
3434

3535
// Cloudstack Network Type the cluster is built in.
3636
// + optional
37-
Type string `json:"type"`
37+
Type string `json:"type,omitempty"`
3838

3939
// Cloudstack Network Name the cluster is built in.
4040
Name string `json:"name"`
@@ -44,11 +44,11 @@ type Network struct {
4444
type CloudStackZoneSpec struct {
4545
// Name.
4646
//+optional
47-
Name string `json:"name"`
47+
Name string `json:"name,omitempty"`
4848

4949
// ID.
5050
//+optional
51-
ID string `json:"id"`
51+
ID string `json:"id,omitempty"`
5252

5353
// The network within the Zone to use.
5454
Network Network `json:"network"`
@@ -64,11 +64,11 @@ type CloudStackFailureDomainSpec struct {
6464

6565
// CloudStack account.
6666
// +optional
67-
Account string `json:"account"`
67+
Account string `json:"account,omitempty"`
6868

6969
// CloudStack domain.
7070
// +optional
71-
Domain string `json:"domain"`
71+
Domain string `json:"domain,omitempty"`
7272

7373
// Apache CloudStack Endpoint secret reference.
7474
ACSEndpoint corev1.SecretReference `json:"acsendpoint"`
@@ -90,7 +90,7 @@ type CloudStackFailureDomain struct {
9090
metav1.ObjectMeta `json:"metadata,omitempty"`
9191

9292
Spec CloudStackFailureDomainSpec `json:"spec"`
93-
Status CloudStackFailureDomainStatus `json:"status"`
93+
Status CloudStackFailureDomainStatus `json:"status,omitempty"`
9494
}
9595

9696
//+kubebuilder:object:root=true

api/v1beta2/cloudstackmachine_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ type CloudStackResourceDiskOffering struct {
112112
// Type pulled mostly from the CloudStack API.
113113
type CloudStackMachineStatus struct {
114114
// Addresses contains a CloudStack VM instance's IP addresses.
115-
Addresses []corev1.NodeAddress `json:"addresses"`
115+
Addresses []corev1.NodeAddress `json:"addresses,omitempty"`
116116

117117
// InstanceState is the state of the CloudStack instance for this machine.
118118
// +optional
119-
InstanceState string `json:"instanceState"`
119+
InstanceState string `json:"instanceState,omitempty"`
120120

121121
// InstanceStateLastUpdated is the time the instance state was last updated.
122122
// +optional

api/v1beta2/cloudstackmachine_webhook_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ var _ = Describe("CloudStackMachine webhook", func() {
7070
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).
7171
Should(MatchError(MatchRegexp(requiredRegex, "Template")))
7272
})
73-
74-
It("should reject a CloudStackMachine with IdentityRef not of kind 'Secret'", func() {
75-
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).
76-
Should(MatchError(MatchRegexp(forbiddenRegex, "must be a Secret")))
77-
})
7873
})
7974

8075
Context("When updating a CloudStackMachine", func() {
@@ -106,16 +101,6 @@ var _ = Describe("CloudStackMachine webhook", func() {
106101
Should(MatchError(MatchRegexp(forbiddenRegex, "details")))
107102
})
108103

109-
It("should reject identity reference kind updates to the CloudStackMachine", func() {
110-
Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
111-
Should(MatchError(MatchRegexp(forbiddenRegex, "identityRef\\.Kind")))
112-
})
113-
114-
It("should reject identity reference name updates to the CloudStackMachine", func() {
115-
Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
116-
Should(MatchError(MatchRegexp(forbiddenRegex, "identityRef\\.Name")))
117-
})
118-
119104
It("should reject updates to the list of affinty groups of the CloudStackMachine", func() {
120105
dummies.CSMachine1.Spec.AffinityGroupIDs = []string{"28b907b8-75a7-4214-bd3d-6c61961fc2af"}
121106
Ω(k8sClient.Update(ctx, dummies.CSMachine1)).

api/v1beta2/cloudstackmachinetemplate_webhook_test.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ var _ = Describe("CloudStackMachineTemplate webhook", func() {
6060
Expect(k8sClient.Create(ctx, dummies.CSMachineTemplate1)).
6161
Should(MatchError(MatchRegexp(requiredRegex, "Template")))
6262
})
63-
64-
It("should reject a CloudStackMachineTemplate with IdentityRef not of kind 'Secret'", func() {
65-
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).
66-
Should(MatchError(MatchRegexp(forbiddenRegex, "must be a Secret")))
67-
})
6863
})
6964

7065
Context("When updating a CloudStackMachineTemplate", func() {
@@ -97,16 +92,6 @@ var _ = Describe("CloudStackMachineTemplate webhook", func() {
9792
Should(MatchError(MatchRegexp(forbiddenRegex, "details")))
9893
})
9994

100-
It("should reject identity reference kind updates to the CloudStackMachineTemplate", func() {
101-
Ω(k8sClient.Update(ctx, dummies.CSMachineTemplate1)).
102-
Should(MatchError(MatchRegexp(forbiddenRegex, "identityRef\\.Kind")))
103-
})
104-
105-
It("should reject identity reference name updates to the CloudStackMachineTemplate", func() {
106-
Ω(k8sClient.Update(ctx, dummies.CSMachineTemplate1)).
107-
Should(MatchError(MatchRegexp(forbiddenRegex, "identityRef\\.Name")))
108-
})
109-
11095
It("should reject updates to the list of AffinityGroupIDs of the CloudStackMachineTemplate", func() {
11196
dummies.CSMachineTemplate1.Spec.Spec.Spec.AffinityGroupIDs = []string{"28b907b8-75a7-4214-bd3d-6c61961fc2ag"}
11297
Ω(k8sClient.Update(ctx, dummies.CSMachineTemplate1)).ShouldNot(Succeed())

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackclusters.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ spec:
273273
type: string
274274
required:
275275
- name
276-
- type
277276
type: object
278277
required:
279278
- network

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackfailuredomains.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ spec:
8484
type: string
8585
required:
8686
- name
87-
- type
8887
type: object
8988
required:
9089
- network
@@ -106,7 +105,6 @@ spec:
106105
type: object
107106
required:
108107
- spec
109-
- status
110108
type: object
111109
served: true
112110
storage: true

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackisolatednetworks.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ spec:
169169
type: string
170170
required:
171171
- name
172-
- type
173172
type: object
174173
required:
175174
- network

config/crd/bases/infrastructure.cluster.x-k8s.io_cloudstackmachines.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ spec:
461461
description: Ready indicates the readiness of the provider resource.
462462
type: boolean
463463
required:
464-
- addresses
465464
- ready
466465
type: object
467466
type: object

0 commit comments

Comments
 (0)