Skip to content

Commit 505e11b

Browse files
authored
Merge pull request #416 from shapeblue/add-vpc-support
Add vpc support
2 parents d892f42 + 3a28780 commit 505e11b

26 files changed

+932
-91
lines changed

api/v1beta1/conversion.go

+11
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,14 @@ func GetK8sSecret(name, namespace string) (*corev1.Secret, error) {
174174
}
175175
return endpointCredentials, nil
176176
}
177+
178+
// Convert_v1beta3_Network_To_v1beta1_Network converts from v1beta3.Network to v1beta1.Network
179+
//
180+
//nolint:golint,revive,stylecheck
181+
func Convert_v1beta3_Network_To_v1beta1_Network(in *v1beta3.Network, out *Network, _ conv.Scope) error {
182+
out.ID = in.ID
183+
out.Type = in.Type
184+
out.Name = in.Name
185+
// Skip Gateway, Netmask, and VPC fields as they do not exist in v1beta1.Network
186+
return nil
187+
}

api/v1beta1/zz_generated.conversion.go

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/conversion.go

+28
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,31 @@ limitations under the License.
1515
*/
1616

1717
package v1beta2
18+
19+
import (
20+
conv "k8s.io/apimachinery/pkg/conversion"
21+
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
22+
)
23+
24+
// Convert_v1beta3_Network_To_v1beta2_Network converts from v1beta3.Network to v1beta2.Network
25+
//
26+
//nolint:golint,revive,stylecheck
27+
func Convert_v1beta3_Network_To_v1beta2_Network(in *v1beta3.Network, out *Network, _ conv.Scope) error {
28+
out.ID = in.ID
29+
out.Type = in.Type
30+
out.Name = in.Name
31+
// Skip Gateway, Netmask, and VPC fields as they do not exist in v1beta2.Network
32+
return nil
33+
}
34+
35+
// Convert_v1beta3_CloudStackIsolatedNetworkSpec_To_v1beta2_CloudStackIsolatedNetworkSpec converts from v1beta3.CloudStackIsolatedNetworkSpec to v1beta2.CloudStackIsolatedNetworkSpec
36+
//
37+
//nolint:golint,revive,stylecheck
38+
func Convert_v1beta3_CloudStackIsolatedNetworkSpec_To_v1beta2_CloudStackIsolatedNetworkSpec(in *v1beta3.CloudStackIsolatedNetworkSpec, out *CloudStackIsolatedNetworkSpec, _ conv.Scope) error {
39+
out.Name = in.Name
40+
out.ID = in.ID
41+
out.ControlPlaneEndpoint = in.ControlPlaneEndpoint
42+
out.FailureDomainName = in.FailureDomainName
43+
// Skip Gateway, Netmask, and VPC fields as they do not exist in v1beta2.CloudStackIsolatedNetworkSpec
44+
return nil
45+
}

api/v1beta2/zz_generated.conversion.go

+38-22
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta3/cloudstackfailuredomain_types.go

+26
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,32 @@ type Network struct {
5353

5454
// Cloudstack Network Name the cluster is built in.
5555
Name string `json:"name"`
56+
57+
// Cloudstack Network Gateway the cluster is built in.
58+
// +optional
59+
Gateway string `json:"gateway,omitempty"`
60+
61+
// Cloudstack Network Netmask the cluster is built in.
62+
// +optional
63+
Netmask string `json:"netmask,omitempty"`
64+
65+
// Cloudstack VPC the network belongs to.
66+
// +optional
67+
VPC *VPC `json:"vpc,omitempty"`
68+
}
69+
70+
type VPC struct {
71+
// Cloudstack VPC ID of the network.
72+
// +optional
73+
ID string `json:"id,omitempty"`
74+
75+
// Cloudstack VPC Name of the network.
76+
// +optional
77+
Name string `json:"name"`
78+
79+
// CIDR for the VPC.
80+
// +optional
81+
CIDR string `json:"cidr,omitempty"`
5682
}
5783

5884
// CloudStackZoneSpec specifies a Zone's details.

api/v1beta3/cloudstackisolatednetwork_types.go

+19-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ type CloudStackIsolatedNetworkSpec struct {
3939

4040
// FailureDomainName -- the FailureDomain the network is placed in.
4141
FailureDomainName string `json:"failureDomainName"`
42+
43+
// Gateway for the network.
44+
// +optional
45+
Gateway string `json:"gateway,omitempty"`
46+
47+
// Netmask for the network.
48+
// +optional
49+
Netmask string `json:"netmask,omitempty"`
50+
51+
// VPC the network belongs to.
52+
// +optional
53+
VPC *VPC `json:"vpc,omitempty"`
4254
}
4355

4456
// CloudStackIsolatedNetworkStatus defines the observed state of CloudStackIsolatedNetwork
@@ -55,9 +67,13 @@ type CloudStackIsolatedNetworkStatus struct {
5567

5668
func (n *CloudStackIsolatedNetwork) Network() *Network {
5769
return &Network{
58-
Name: n.Spec.Name,
59-
Type: "IsolatedNetwork",
60-
ID: n.Spec.ID}
70+
Name: n.Spec.Name,
71+
Type: "IsolatedNetwork",
72+
ID: n.Spec.ID,
73+
Gateway: n.Spec.Gateway,
74+
Netmask: n.Spec.Netmask,
75+
VPC: n.Spec.VPC,
76+
}
6177
}
6278

6379
//+kubebuilder:object:root=true

api/v1beta3/zz_generated.deepcopy.go

+32-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)