Skip to content

Commit 09a4350

Browse files
committed
VPC: Extend VPC related API's for v2 VPC reconcile
Extend the API's used in the v2 support of reconciling VPC for the VPCCluster support.
1 parent 5b01057 commit 09a4350

6 files changed

+324
-2
lines changed

api/v1beta1/zz_generated.conversion.go

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

api/v1beta2/ibmvpccluster_types.go

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ type VPCNetworkSpec struct {
113113
// +optional
114114
ResourceGroup *string `json:"resourceGroup,omitempty"`
115115

116-
// TODO(cjschaef): Complete spec definition (SecurityGroups, VPC)
116+
// vpc defines the IBM Cloud VPC.
117+
// +optional
118+
VPC *VPCResource `json:"vpc,omitempty"`
119+
120+
// TODO(cjschaef): Complete spec definition (SecurityGroups, etc.)
117121
}
118122

119123
// VPCSecurityGroupStatus defines a vpc security group resource status with its id and respective rule's ids.
@@ -146,11 +150,22 @@ type VPCLoadBalancerStatus struct {
146150
type IBMVPCClusterStatus struct {
147151
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
148152
// Important: Run "make" to regenerate code after modifying this file
153+
// dep: rely on Network instead.
149154
VPC VPC `json:"vpc,omitempty"`
150155

156+
// network is the status of the VPC network resources.
157+
// +optional
158+
Network *VPCNetworkStatus `json:"network,omitempty"`
159+
151160
// Ready is true when the provider resource is ready.
152161
// +optional
153-
Ready bool `json:"ready"`
162+
// +kubebuilder:default=false
163+
Ready bool `json:"ready"`
164+
165+
// resourceGroup is the status of the cluster's Resource Group.
166+
// +optional
167+
ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"`
168+
154169
Subnet Subnet `json:"subnet,omitempty"`
155170
VPCEndpoint VPCEndpoint `json:"vpcEndpoint,omitempty"`
156171

@@ -163,6 +178,45 @@ type IBMVPCClusterStatus struct {
163178
Conditions capiv1beta1.Conditions `json:"conditions,omitempty"`
164179
}
165180

181+
// VPCNetworkStatus provides details on the status of VPC network resources.
182+
type VPCNetworkStatus struct {
183+
// resourceGroup references the Resource Group for Network resources for the cluster.
184+
// This can be the same or unique from the cluster's Resource Group.
185+
// +optional
186+
ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"`
187+
188+
// vpc references the IBM Cloud VPC.
189+
// +optional
190+
VPC *VPCResourceStatus `json:"vpc,omitempty"`
191+
}
192+
193+
// VPCResourceStatus identifies a VPC resource by id (and name) and whether it is ready.
194+
type VPCResourceStatus struct {
195+
// id defines the IBM Cloud ID of the resource.
196+
// +required
197+
ID string `json:"id"`
198+
199+
// name defines the name of the resource.
200+
// +optional
201+
Name *string `json:"name,omitempty"`
202+
203+
// ready defines whether the IBM Cloud VPC resource is ready.
204+
// +required
205+
// +kubebuilder:default=false
206+
Ready bool `json:"ready"`
207+
}
208+
209+
// Set sets the VPCResourceStatus fields.
210+
func (s *VPCResourceStatus) Set(resource VPCResourceStatus) {
211+
s.ID = resource.ID
212+
// Set the name if it hasn't been, or the resource.Name won't remove it (nil).
213+
if s.Name == nil && resource.Name != nil {
214+
s.Name = resource.Name
215+
}
216+
s.Name = resource.Name
217+
s.Ready = resource.Ready
218+
}
219+
166220
// VPC holds the VPC information.
167221
type VPC struct {
168222
ID string `json:"id"`

api/v1beta2/types.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,53 @@ type VPCEndpoint struct {
400400
// +optional
401401
LBID *string `json:"loadBalancerIPID,omitempty"`
402402
}
403+
404+
// GenericResourceReference represents a generic IBM Cloud resource.
405+
type GenericResourceReference struct {
406+
// id defines the generic IBM Cloud resource ID.
407+
// +required
408+
ID string `json:"id"`
409+
410+
// name defines the generic IBM Cloud resource name.
411+
// +optional
412+
Name *string `json:"name,omitempty"`
413+
}
414+
415+
// ResourceStatus identifies a resource by id (and name) and whether it is ready.
416+
type ResourceStatus struct {
417+
// id defines the Id of the IBM Cloud resource status.
418+
// +required
419+
ID string `json:"id"`
420+
421+
// name defines the name of the IBM Cloud resource status.
422+
// +optional
423+
Name *string `json:"name,omitempty"`
424+
425+
// ready defines whether the IBM Cloud resource is ready.
426+
// +required
427+
Ready bool `json:"ready"`
428+
}
429+
430+
// Set sets the ResourceStatus fields.
431+
func (s *ResourceStatus) Set(resource ResourceStatus) {
432+
s.ID = resource.ID
433+
// Set the name if it hasn't been, or the incoming name won't remove it (nil).
434+
if s.Name == nil && resource.Name != nil {
435+
s.Name = resource.Name
436+
}
437+
s.Ready = resource.Ready
438+
}
439+
440+
// VPCResource represents a VPC resource.
441+
// +kubebuilder:validation:XValidation:rule="has(self.id) || has(self.name)",message="an id or name must be provided"
442+
type VPCResource struct {
443+
// id of the resource.
444+
// +kubebuilder:validation:MinLength=1
445+
// +optional
446+
ID *string `json:"id,omitempty"`
447+
448+
// name of the resource.
449+
// +kubebuilder:validation:MinLength=1
450+
// +optional
451+
Name *string `json:"name,omitempty"`
452+
}

api/v1beta2/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)