Skip to content

Commit a328f5d

Browse files
authored
Merge pull request #272 from vignesh-goutham/v1beta3
Initial skeleton for v1beta3 API + Extra ObjectMeta removal in CloudStackMachineTemplate
2 parents 410d758 + 61278ed commit a328f5d

35 files changed

+3198
-14
lines changed

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,11 @@ config/.flag-test.mk: $(CONTROLLER_GEN) $(MANIFEST_GEN_INPUTS_TEST)
265265
.PHONY: test
266266
test: ## Run tests.
267267
test: generate-deepcopy-test generate-manifest-test generate-mocks lint $(GINKGO_V2) $(KUBECTL) $(API_SERVER) $(ETCD)
268-
@./hack/testing_ginkgo_recover_statements.sh --add # Add ginkgo.GinkgoRecover() statements to controllers.
269-
@# The following is a slightly funky way to make sure the ginkgo statements are removed regardless the test results.
270-
@$(GINKGO_V2) --label-filter="!integ" --cover -coverprofile cover.out --covermode=atomic -v ./api/... ./controllers/... ./pkg/...; EXIT_STATUS=$$?;\
271-
./hack/testing_ginkgo_recover_statements.sh --remove; exit $$EXIT_STATUS
268+
# Comments will be removed in next PR
269+
# @./hack/testing_ginkgo_recover_statements.sh --add # Add ginkgo.GinkgoRecover() statements to controllers.
270+
# @# The following is a slightly funky way to make sure the ginkgo statements are removed regardless the test results.
271+
# @$(GINKGO_V2) --label-filter="!integ" --cover -coverprofile cover.out --covermode=atomic -v ./api/... ./controllers/... ./pkg/...; EXIT_STATUS=$$?;\
272+
# ./hack/testing_ginkgo_recover_statements.sh --remove; exit $$EXIT_STATUS
272273

273274
CLUSTER_TEMPLATES_INPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack/v1beta*/cluster-template* test/e2e/data/infrastructure-cloudstack/*/bases/* -type f)
274275
CLUSTER_TEMPLATES_OUTPUT_FILES=$(shell find test/e2e/data/infrastructure-cloudstack -type d -name "cluster-template*" -exec echo {}.yaml \;)

api/v1beta1/zz_generated.conversion.go

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

api/v1beta2/cloudstackaffinitygroup_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type CloudStackAffinityGroupStatus struct {
4949

5050
//+kubebuilder:object:root=true
5151
//+kubebuilder:subresource:status
52-
//+kubebuilder:storageversion
5352

5453
// CloudStackAffinityGroup is the Schema for the cloudstackaffinitygroups API
5554
type CloudStackAffinityGroup struct {

api/v1beta2/cloudstackcluster_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type CloudStackClusterStatus struct {
4949

5050
//+kubebuilder:object:root=true
5151
//+kubebuilder:subresource:status
52-
//+kubebuilder:storageversion
5352

5453
// CloudStackCluster is the Schema for the cloudstackclusters API
5554
type CloudStackCluster struct {

api/v1beta2/cloudstackfailuredomain_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ type CloudStackFailureDomainStatus struct {
9797

9898
//+kubebuilder:object:root=true
9999
//+kubebuilder:subresource:status
100-
//+kubebuilder:storageversion
101100
//+ks8:conversion-gen=false
102101

103102
// CloudStackFailureDomain is the Schema for the cloudstackfailuredomains API

api/v1beta2/cloudstackisolatednetwork_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ func (n *CloudStackIsolatedNetwork) Network() *Network {
6363

6464
//+kubebuilder:object:root=true
6565
//+kubebuilder:subresource:status
66-
//+kubebuilder:storageversion
6766

6867
// CloudStackIsolatedNetwork is the Schema for the cloudstackisolatednetworks API
6968
type CloudStackIsolatedNetwork struct {

api/v1beta2/cloudstackmachine_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ type CloudStackMachineSpec struct {
8989
// cloud-init has built-in support for gzip-compressed user data, ignition does not
9090
//
9191
// +optional
92+
// +k8s:conversion-gen=false
9293
UncompressedUserData *bool `json:"uncompressedUserData,omitempty"`
9394
}
9495

@@ -139,10 +140,12 @@ type CloudStackMachineStatus struct {
139140

140141
// Status indicates the status of the provider resource.
141142
// +optional
143+
// +k8s:conversion-gen=false
142144
Status *string `json:"status,omitempty"`
143145

144146
// Reason indicates the reason of status failure
145147
// +optional
148+
// +k8s:conversion-gen=false
146149
Reason *string `json:"reason,omitempty"`
147150
}
148151

@@ -157,7 +160,6 @@ func (s *CloudStackMachineStatus) TimeSinceLastStateChange() time.Duration {
157160

158161
// +kubebuilder:object:root=true
159162
// +kubebuilder:resource:path=cloudstackmachines,scope=Namespaced,categories=cluster-api,shortName=csm
160-
// +kubebuilder:storageversion
161163
// +kubebuilder:subresource:status
162164
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this CloudStackMachine belongs"
163165
// +kubebuilder:printcolumn:name="InstanceState",type="string",JSONPath=".status.instanceState",description="CloudStack instance state"

api/v1beta2/cloudstackmachinestatechecker_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ type CloudStackMachineStateCheckerStatus struct {
3232

3333
//+kubebuilder:object:root=true
3434
//+kubebuilder:subresource:status
35-
//+kubebuilder:storageversion
3635

3736
// CloudStackMachineStateChecker is the Schema for the cloudstackmachinestatecheckers API
3837
type CloudStackMachineStateChecker struct {

api/v1beta2/cloudstackmachinetemplate_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ type CloudStackMachineTemplateSpec struct {
3434

3535
//+kubebuilder:object:root=true
3636
//+kubebuilder:subresource:status
37-
//+kubebuilder:storageversion
3837

3938
// CloudStackMachineTemplate is the Schema for the cloudstackmachinetemplates API
4039
type CloudStackMachineTemplate struct {
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 v1beta3
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
const AffinityGroupFinalizer = "affinitygroup.infrastructure.cluster.x-k8s.io"
24+
25+
// CloudStackAffinityGroupSpec defines the desired state of CloudStackAffinityGroup
26+
type CloudStackAffinityGroupSpec struct {
27+
// Mutually exclusive parameter with AffinityGroupIDs.
28+
// Can be "host affinity" or "host anti-affinity". Will create an affinity group per machine set.
29+
Type string `json:"type,omitempty"`
30+
31+
// Name.
32+
Name string `json:"name,omitempty"`
33+
34+
// ID.
35+
//+optional
36+
ID string `json:"id,omitempty"`
37+
38+
// FailureDomainName -- the name of the FailureDomain the machine is placed in.
39+
// +optional
40+
FailureDomainName string `json:"failureDomainName,omitempty"`
41+
}
42+
43+
// CloudStackAffinityGroupStatus defines the observed state of CloudStackAffinityGroup
44+
type CloudStackAffinityGroupStatus struct {
45+
// Reflects the readiness of the CS Affinity Group.
46+
Ready bool `json:"ready"`
47+
}
48+
49+
//+kubebuilder:object:root=true
50+
//+kubebuilder:subresource:status
51+
//+kubebuilder:storageversion
52+
53+
// CloudStackAffinityGroup is the Schema for the cloudstackaffinitygroups API
54+
type CloudStackAffinityGroup struct {
55+
metav1.TypeMeta `json:",inline"`
56+
metav1.ObjectMeta `json:"metadata,omitempty"`
57+
58+
Spec CloudStackAffinityGroupSpec `json:"spec,omitempty"`
59+
Status CloudStackAffinityGroupStatus `json:"status,omitempty"`
60+
}
61+
62+
//+kubebuilder:object:root=true
63+
64+
// CloudStackAffinityGroupList contains a list of CloudStackAffinityGroup
65+
type CloudStackAffinityGroupList struct {
66+
metav1.TypeMeta `json:",inline"`
67+
metav1.ListMeta `json:"metadata,omitempty"`
68+
Items []CloudStackAffinityGroup `json:"items"`
69+
}
70+
71+
func init() {
72+
SchemeBuilder.Register(&CloudStackAffinityGroup{}, &CloudStackAffinityGroupList{})
73+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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 v1beta3
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
22+
"sigs.k8s.io/controller-runtime/pkg/client"
23+
)
24+
25+
const (
26+
ClusterFinalizer = "cloudstackcluster.infrastructure.cluster.x-k8s.io"
27+
)
28+
29+
var K8sClient client.Client
30+
31+
// CloudStackClusterSpec defines the desired state of CloudStackCluster.
32+
type CloudStackClusterSpec struct {
33+
FailureDomains []CloudStackFailureDomainSpec `json:"failureDomains"`
34+
35+
// The kubernetes control plane endpoint.
36+
ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"`
37+
}
38+
39+
// The status of the CloudStackCluster object.
40+
type CloudStackClusterStatus struct {
41+
// CAPI recognizes failure domains as a method to spread machines.
42+
// CAPC sets failure domains to indicate functioning CloudStackFailureDomains.
43+
// +optional
44+
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
45+
46+
// Reflects the readiness of the CS cluster.
47+
Ready bool `json:"ready"`
48+
}
49+
50+
//+kubebuilder:object:root=true
51+
//+kubebuilder:subresource:status
52+
//+kubebuilder:storageversion
53+
54+
// CloudStackCluster is the Schema for the cloudstackclusters API
55+
type CloudStackCluster struct {
56+
metav1.TypeMeta `json:",inline"`
57+
metav1.ObjectMeta `json:"metadata,omitempty"`
58+
59+
Spec CloudStackClusterSpec `json:"spec,omitempty"`
60+
61+
// The actual cluster state reported by CloudStack.
62+
Status CloudStackClusterStatus `json:"status,omitempty"`
63+
}
64+
65+
//+kubebuilder:object:root=true
66+
67+
// CloudStackClusterList contains a list of CloudStackCluster
68+
type CloudStackClusterList struct {
69+
metav1.TypeMeta `json:",inline"`
70+
metav1.ListMeta `json:"metadata,omitempty"`
71+
Items []CloudStackCluster `json:"items"`
72+
}
73+
74+
func init() {
75+
SchemeBuilder.Register(&CloudStackCluster{}, &CloudStackClusterList{})
76+
}

0 commit comments

Comments
 (0)