forked from kubernetes-sigs/cluster-api-provider-cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudstackfailuredomain_types.go
152 lines (118 loc) · 4.4 KB
/
cloudstackfailuredomain_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta3
import (
"crypto/md5" // #nosec G501 -- weak cryptographic primitive doesn't matter here. Not security related.
"fmt"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// FailureDomainHashedMetaName returns an MD5 name generated from the FailureDomain and Cluster name.
// FailureDomains must have a unique name even when potentially sharing a namespace with other clusters.
// In the future we may remove the ability to run multiple clusters in a single namespace, but today
// this is a consequence of being upstream of EKS-A which does run multiple clusters in a single namepace.
func FailureDomainHashedMetaName(fdName, clusterName string) string {
return fmt.Sprintf("%x", md5.Sum([]byte(fdName+clusterName))) // #nosec G401 -- weak cryptographic primitive doesn't matter here. Not security related.
}
const (
FailureDomainFinalizer = "cloudstackfailuredomain.infrastructure.cluster.x-k8s.io"
FailureDomainLabelName = "cloudstackfailuredomain.infrastructure.cluster.x-k8s.io/name"
)
const (
NetworkTypeIsolated = "Isolated"
NetworkTypeShared = "Shared"
)
type Network struct {
// Cloudstack Network ID the cluster is built in.
// +optional
ID string `json:"id,omitempty"`
// Cloudstack Network Type the cluster is built in.
// + optional
Type string `json:"type,omitempty"`
// Cloudstack Network Name the cluster is built in.
Name string `json:"name"`
// Cloudstack Network Gateway the cluster is built in.
// +optional
Gateway string `json:"gateway,omitempty"`
// Cloudstack Network Netmask the cluster is built in.
// +optional
Netmask string `json:"netmask,omitempty"`
// Cloudstack VPC the network belongs to.
// +optional
VPC *VPC `json:"vpc,omitempty"`
}
type VPC struct {
// Cloudstack VPC ID of the network.
// +optional
ID string `json:"id,omitempty"`
// Cloudstack VPC Name of the network.
// +optional
Name string `json:"name"`
// CIDR for the VPC.
// +optional
CIDR string `json:"cidr,omitempty"`
}
// CloudStackZoneSpec specifies a Zone's details.
type CloudStackZoneSpec struct {
// Name.
//+optional
Name string `json:"name,omitempty"`
// ID.
//+optional
ID string `json:"id,omitempty"`
// The network within the Zone to use.
Network Network `json:"network"`
}
// CloudStackFailureDomainSpec defines the desired state of CloudStackFailureDomain
type CloudStackFailureDomainSpec struct {
// The failure domain unique name.
Name string `json:"name"`
// The ACS Zone for this failure domain.
Zone CloudStackZoneSpec `json:"zone"`
// CloudStack account.
// +optional
Account string `json:"account,omitempty"`
// CloudStack domain.
// +optional
Domain string `json:"domain,omitempty"`
// CloudStack project.
// +optional
Project string `json:"project,omitempty"`
// Apache CloudStack Endpoint secret reference.
ACSEndpoint corev1.SecretReference `json:"acsEndpoint"`
}
// CloudStackFailureDomainStatus defines the observed state of CloudStackFailureDomain
type CloudStackFailureDomainStatus struct {
// Reflects the readiness of the CloudStack Failure Domain.
Ready bool `json:"ready"`
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:storageversion
// CloudStackFailureDomain is the Schema for the cloudstackfailuredomains API
type CloudStackFailureDomain struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec CloudStackFailureDomainSpec `json:"spec"`
Status CloudStackFailureDomainStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// CloudStackFailureDomainList contains a list of CloudStackFailureDomain
type CloudStackFailureDomainList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CloudStackFailureDomain `json:"items"`
}
func init() {
SchemeBuilder.Register(&CloudStackFailureDomain{}, &CloudStackFailureDomainList{})
}