Skip to content

Commit 3543c69

Browse files
committed
Merge branch 'main' of https://github.com/kubernetes-sigs/cluster-api-provider-cloudstack into automated-builds
2 parents c3377bc + 154eed4 commit 3543c69

File tree

158 files changed

+7484
-1260
lines changed

Some content is hidden

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

158 files changed

+7484
-1260
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ cluster-api
2929
# Ignore output of Makefile sed operations created when generating manifests.
3030
config/default/manager_image_patch_edited.yaml
3131

32+
# Ignore output of e2e kustomization of templates.
33+
test/e2e/data/infrastructure-cloudstack/v1beta*/*yaml
34+
3235
# Test binary, build with `go test -c`
3336
*.test
3437

Makefile

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ config/.flag.mk: $(CONTROLLER_GEN) $(MANIFEST_GEN_INPUTS)
164164
$(CONTROLLER_GEN) crd:crdVersions=v1 rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
165165
@touch config/.flag.mk
166166

167+
CONVERSION_GEN_TARGET=$(shell find api -type d -name "v*1" -exec echo {}\/zz_generated.conversion.go \;)
168+
CONVERSION_GEN_INPUTS=$(shell find ./api -name "*test*" -prune -o -name "*zz_generated*" -prune -o -type f -print)
169+
.PHONY: generate-conversion
170+
generate-conversion: $(CONVERSION_GEN_TARGET) ## Generate code to convert api/v1beta1 to api/v1beta2
171+
api/%/zz_generated.conversion.go: bin/conversion-gen $(CONVERSION_GEN_INPUTS)
172+
conversion-gen --go-header-file "./hack/boilerplate.go.txt" --input-dirs "./api/v1beta1" \
173+
--output-base "." --output-file-base="zz_generated.conversion" --skip-unsafe=true
174+
167175
##@ Build
168176
## --------------------------------------
169177
## Build
@@ -183,7 +191,7 @@ $(BIN_DIR)/manager-linux-amd64: $(MANAGER_BIN_INPUTS)
183191
-o $(BIN_DIR)/manager-linux-amd64 main.go
184192

185193
.PHONY: run
186-
run: generate-deepcopy ## Run a controller from your host.
194+
run: generate-deepcopy generate-conversion ## Run a controller from your host.
187195
go run ./main.go
188196

189197
##@ Deploy
@@ -208,7 +216,7 @@ undeploy: $(KUSTOMIZE) ## Undeploy controller from the K8s cluster specified in
208216
# Using a flag file here as docker build doesn't produce a target file.
209217
DOCKER_BUILD_INPUTS=$(MANAGER_BIN_INPUTS) Dockerfile
210218
.PHONY: docker-build
211-
docker-build: generate-deepcopy build-for-docker .dockerflag.mk ## Build docker image containing the controller manager.
219+
docker-build: generate-deepcopy generate-conversion build-for-docker .dockerflag.mk ## Build docker image containing the controller manager.
212220
.dockerflag.mk: $(DOCKER_BUILD_INPUTS)
213221
docker build -t ${IMG} .
214222
@touch .dockerflag.mk
@@ -223,8 +231,8 @@ docker-push: .dockerflag.mk ## Push docker image with the manager.
223231
## --------------------------------------
224232

225233
.PHONY: tilt-up
226-
tilt-up: cluster-api kind-cluster cluster-api/tilt-settings.json generate-manifests cloud-config ## Setup and run tilt for development.
227-
export CLOUDSTACK_B64ENCODED_SECRET=$$(base64 -w0 -i cloud-config 2>/dev/null || base64 -b 0 -i cloud-config) && cd cluster-api && tilt up
234+
tilt-up: cluster-api kind-cluster cluster-api/tilt-settings.json manifests ## Setup and run tilt for development.
235+
cd cluster-api && tilt up
228236

229237
.PHONY: kind-cluster
230238
kind-cluster: cluster-api ## Create a kind cluster with a local Docker repository.
@@ -244,11 +252,12 @@ cluster-api/tilt-settings.json: hack/tilt-settings.json cluster-api
244252
export KUBEBUILDER_ASSETS=$(REPO_ROOT)/$(TOOLS_BIN_DIR)
245253
.PHONY: test
246254
test: generate-mocks lint $(GINKGO_V2) $(KUBECTL) $(API_SERVER) $(ETCD) ## Run tests. At the moment this is only unit tests.
255+
@./hack/testing_ginkgo_recover_statements.sh --add # Add ginkgo.GinkgoRecover() statements to controllers.
247256
@# The following is a slightly funky way to make sure the ginkgo statements are removed regardless the test results.
248257
@$(GINKGO_V2) --label-filter="!integ" --cover -coverprofile cover.out --covermode=atomic -v ./api/... ./controllers/... ./pkg/...; EXIT_STATUS=$$?;\
249258
./hack/testing_ginkgo_recover_statements.sh --remove; exit $$EXIT_STATUS
250259

251-
CLUSTER_TEMPLATES_INPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack/*/cluster-template*/* test/e2e/data/infrastructure-cloudstack/*/bases/* -type f)
260+
CLUSTER_TEMPLATES_INPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack/v1beta*/*/cluster-template* test/e2e/data/infrastructure-cloudstack/*/bases/* -type f)
252261
CLUSTER_TEMPLATES_OUTPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack -type d -name "cluster-template*" -exec echo {}.yaml \;)
253262
.PHONY: e2e-cluster-templates
254263
e2e-cluster-templates: $(CLUSTER_TEMPLATES_OUTPUT_FILES) ## Generate cluster template files for e2e testing.
@@ -260,6 +269,7 @@ e2e-essentials: $(GINKGO_V1) e2e-cluster-templates kind-cluster ## Fulfill essen
260269

261270
JOB ?= .*
262271
run-e2e: e2e-essentials ## Run e2e testing. JOB is an optional REGEXP to select certainn test cases to run. e.g. JOB=PR-Blocking, JOB=Conformance
272+
kubectl apply -f cloud-config.yaml && \
263273
cd test/e2e && \
264274
$(REPO_ROOT)/$(GINKGO_V1) -v -trace -tags=e2e -focus=$(JOB) -skip=Conformance -nodes=1 -noColor=false ./... -- \
265275
-e2e.artifacts-folder=${REPO_ROOT}/_artifacts \
@@ -278,6 +288,7 @@ clean: ## Cleans up everything.
278288
rm -rf bin
279289
rm -rf $(TOOLS_BIN_DIR)
280290
rm -rf cluster-api
291+
rm -rf test/e2e/data/infrastructure-cloudstack/*/*yaml
281292

282293
##@ Release
283294
## --------------------------------------

PROJECT

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,12 @@ resources:
7777
kind: CloudStackMachineStateChecker
7878
path: sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta1
7979
version: v1beta1
80+
- api:
81+
crdVersion: v1
82+
namespaced: true
83+
domain: cluster.x-k8s.io
84+
group: infrastructure
85+
kind: CloudStackFailureDomain
86+
path: sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2
87+
version: v1beta2
8088
version: "3"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
21+
"sigs.k8s.io/controller-runtime/pkg/conversion"
22+
)
23+
24+
func (src *CloudStackAffinityGroup) ConvertTo(dstRaw conversion.Hub) error { // nolint
25+
dst := dstRaw.(*v1beta2.CloudStackAffinityGroup)
26+
return Convert_v1beta1_CloudStackAffinityGroup_To_v1beta2_CloudStackAffinityGroup(src, dst, nil)
27+
}
28+
29+
func (dst *CloudStackAffinityGroup) ConvertFrom(srcRaw conversion.Hub) error { // nolint
30+
src := srcRaw.(*v1beta2.CloudStackAffinityGroup)
31+
return Convert_v1beta2_CloudStackAffinityGroup_To_v1beta1_CloudStackAffinityGroup(src, dst, nil)
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
21+
"sigs.k8s.io/controller-runtime/pkg/conversion"
22+
)
23+
24+
func (src *CloudStackCluster) ConvertTo(dstRaw conversion.Hub) error { // nolint
25+
dst := dstRaw.(*v1beta2.CloudStackCluster)
26+
27+
return Convert_v1beta1_CloudStackCluster_To_v1beta2_CloudStackCluster(src, dst, nil)
28+
}
29+
30+
func (dst *CloudStackCluster) ConvertFrom(srcRaw conversion.Hub) error { // nolint
31+
src := srcRaw.(*v1beta2.CloudStackCluster)
32+
33+
return Convert_v1beta2_CloudStackCluster_To_v1beta1_CloudStackCluster(src, dst, nil)
34+
}

api/v1beta1/cloudstackcluster_types.go

Lines changed: 7 additions & 7 deletions
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"
@@ -49,7 +48,7 @@ type Network struct {
4948
ID string `json:"id,omitempty"`
5049

5150
// Cloudstack Network Type the cluster is built in.
52-
// + optional
51+
// +optional
5352
Type string `json:"type,omitempty"`
5453

5554
// Cloudstack Network Name the cluster is built in.
@@ -61,11 +60,11 @@ type ZoneStatusMap map[string]Zone
6160

6261
type Zone struct {
6362
// Name.
64-
//+optional
63+
// +optional
6564
Name string `json:"name,omitempty"`
6665

6766
// ID.
68-
//+optional
67+
// +optional
6968
ID string `json:"id,omitempty"`
7069

7170
// The network within the Zone to use.
@@ -82,6 +81,7 @@ func (z *Zone) MetaName() string {
8281
return strings.ToLower(s)
8382
}
8483

84+
//+k8s:conversion-gen=false
8585
// CloudStackClusterSpec defines the desired state of CloudStackCluster.
8686
type CloudStackClusterSpec struct {
8787
Zones []Zone `json:"zones"`
@@ -98,10 +98,10 @@ type CloudStackClusterSpec struct {
9898
Domain string `json:"domain,omitempty"`
9999

100100
// +optional
101-
// +k8s:conversion-gen=false
102101
IdentityRef *CloudStackIdentityReference `json:"identityRef,omitempty"`
103102
}
104103

104+
//+k8s:conversion-gen=false
105105
// The status of the abstract CS k8s (not an actual Cloudstack Cluster) cluster.
106106
type CloudStackClusterStatus struct {
107107

@@ -132,7 +132,7 @@ type CloudStackClusterStatus struct {
132132

133133
//+kubebuilder:object:root=true
134134
//+kubebuilder:subresource:status
135-
135+
//+k8s:conversion-gen=false
136136
// CloudStackCluster is the Schema for the cloudstackclusters API
137137
type CloudStackCluster struct {
138138
metav1.TypeMeta `json:",inline"`
@@ -145,7 +145,7 @@ type CloudStackCluster struct {
145145
}
146146

147147
//+kubebuilder:object:root=true
148-
148+
//+k8s:conversion-gen=false
149149
// CloudStackClusterList contains a list of CloudStackCluster
150150
type CloudStackClusterList struct {
151151
metav1.TypeMeta `json:",inline"`
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
21+
"sigs.k8s.io/controller-runtime/pkg/conversion"
22+
)
23+
24+
func (src *CloudStackIsolatedNetwork) ConvertTo(dstRaw conversion.Hub) error { // nolint
25+
dst := dstRaw.(*v1beta2.CloudStackIsolatedNetwork)
26+
return Convert_v1beta1_CloudStackIsolatedNetwork_To_v1beta2_CloudStackIsolatedNetwork(src, dst, nil)
27+
}
28+
29+
func (dst *CloudStackIsolatedNetwork) ConvertFrom(srcRaw conversion.Hub) error { // nolint
30+
src := srcRaw.(*v1beta2.CloudStackIsolatedNetwork)
31+
return Convert_v1beta2_CloudStackIsolatedNetwork_To_v1beta1_CloudStackIsolatedNetwork(src, dst, nil)
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
21+
"sigs.k8s.io/controller-runtime/pkg/conversion"
22+
)
23+
24+
func (src *CloudStackMachine) ConvertTo(dstRaw conversion.Hub) error { // nolint
25+
dst := dstRaw.(*v1beta2.CloudStackMachine)
26+
return Convert_v1beta1_CloudStackMachine_To_v1beta2_CloudStackMachine(src, dst, nil)
27+
}
28+
29+
func (dst *CloudStackMachine) ConvertFrom(srcRaw conversion.Hub) error { // nolint
30+
src := srcRaw.(*v1beta2.CloudStackMachine)
31+
return Convert_v1beta2_CloudStackMachine_To_v1beta1_CloudStackMachine(src, dst, nil)
32+
}

api/v1beta1/cloudstackmachine_types.go

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

1919
import (
20+
"time"
21+
2022
corev1 "k8s.io/api/core/v1"
2123
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
"time"
2324
)
2425

2526
const (
@@ -79,12 +80,14 @@ type CloudStackMachineSpec struct {
7980
ProviderID *string `json:"providerID,omitempty"`
8081

8182
// Optionally settable Zone ID to land the machine in.
83+
// +k8s:conversion-gen=false
8284
ZoneID string `json:"zoneID,omitempty"`
8385

86+
// +k8s:conversion-gen=false
8487
// Optionally settable Zone Name to land the machine in.
8588
ZoneName string `json:"zoneName,omitempty"`
8689

87-
// IdentityRef is a reference to a identity to be used when reconciling this cluster
90+
// IdentityRef is a reference to an identity to be used when reconciling this cluster
8891
// +optional
8992
// +k8s:conversion-gen=false
9093
IdentityRef *CloudStackIdentityReference `json:"identityRef,omitempty"`
@@ -122,6 +125,7 @@ type InstanceState string
122125
type CloudStackMachineStatus struct {
123126
// Zone ID is used so that the zone can be computed once per reconcile and then propagate.
124127
// +optional
128+
// +k8s:conversion-gen=false
125129
ZoneID string `json:"zoneID,omitempty"`
126130

127131
// Addresses contains a CloudStack VM instance's IP addresses.
@@ -150,7 +154,6 @@ func (s *CloudStackMachineStatus) TimeSinceLastStateChange() time.Duration {
150154

151155
// +kubebuilder:object:root=true
152156
// +kubebuilder:resource:path=cloudstackmachines,scope=Namespaced,categories=cluster-api,shortName=csm
153-
// +kubebuilder:storageversion
154157
// +kubebuilder:subresource:status
155158
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this CloudStackMachine belongs"
156159
// +kubebuilder:printcolumn:name="InstanceState",type="string",JSONPath=".status.instanceState",description="CloudStack instance state"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright 2022 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
21+
"sigs.k8s.io/controller-runtime/pkg/conversion"
22+
)
23+
24+
func (src *CloudStackMachineStateChecker) ConvertTo(dstRaw conversion.Hub) error { // nolint
25+
dst := dstRaw.(*v1beta2.CloudStackMachineStateChecker)
26+
return Convert_v1beta1_CloudStackMachineStateChecker_To_v1beta2_CloudStackMachineStateChecker(src, dst, nil)
27+
}
28+
29+
func (dst *CloudStackMachineStateChecker) ConvertFrom(srcRaw conversion.Hub) error { // nolint
30+
src := srcRaw.(*v1beta2.CloudStackMachineStateChecker)
31+
return Convert_v1beta2_CloudStackMachineStateChecker_To_v1beta1_CloudStackMachineStateChecker(src, dst, nil)
32+
}

0 commit comments

Comments
 (0)