Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vpc support #416

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions api/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,14 @@ func GetK8sSecret(name, namespace string) (*corev1.Secret, error) {
}
return endpointCredentials, nil
}

// Convert_v1beta3_Network_To_v1beta1_Network converts from v1beta3.Network to v1beta1.Network
//
//nolint:golint,revive,stylecheck
func Convert_v1beta3_Network_To_v1beta1_Network(in *v1beta3.Network, out *Network, _ conv.Scope) error {
out.ID = in.ID
out.Type = in.Type
out.Name = in.Name
// Skip Gateway, Netmask, and VPC fields as they do not exist in v1beta1.Network
return nil
}
21 changes: 11 additions & 10 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions api/v1beta2/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,31 @@ limitations under the License.
*/

package v1beta2

import (
conv "k8s.io/apimachinery/pkg/conversion"
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
)

// Convert_v1beta3_Network_To_v1beta2_Network converts from v1beta3.Network to v1beta2.Network
//
//nolint:golint,revive,stylecheck
func Convert_v1beta3_Network_To_v1beta2_Network(in *v1beta3.Network, out *Network, _ conv.Scope) error {
out.ID = in.ID
out.Type = in.Type
out.Name = in.Name
// Skip Gateway, Netmask, and VPC fields as they do not exist in v1beta2.Network
return nil
}

// Convert_v1beta3_CloudStackIsolatedNetworkSpec_To_v1beta2_CloudStackIsolatedNetworkSpec converts from v1beta3.CloudStackIsolatedNetworkSpec to v1beta2.CloudStackIsolatedNetworkSpec
//
//nolint:golint,revive,stylecheck
func Convert_v1beta3_CloudStackIsolatedNetworkSpec_To_v1beta2_CloudStackIsolatedNetworkSpec(in *v1beta3.CloudStackIsolatedNetworkSpec, out *CloudStackIsolatedNetworkSpec, _ conv.Scope) error {
out.Name = in.Name
out.ID = in.ID
out.ControlPlaneEndpoint = in.ControlPlaneEndpoint
out.FailureDomainName = in.FailureDomainName
// Skip Gateway, Netmask, and VPC fields as they do not exist in v1beta2.CloudStackIsolatedNetworkSpec
return nil
}
60 changes: 38 additions & 22 deletions api/v1beta2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions api/v1beta3/cloudstackfailuredomain_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ type Network struct {

// 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.
Expand Down
22 changes: 19 additions & 3 deletions api/v1beta3/cloudstackisolatednetwork_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ type CloudStackIsolatedNetworkSpec struct {

// FailureDomainName -- the FailureDomain the network is placed in.
FailureDomainName string `json:"failureDomainName"`

// Gateway for the network.
// +optional
Gateway string `json:"gateway,omitempty"`

// Netmask for the network.
// +optional
Netmask string `json:"netmask,omitempty"`

// VPC the network belongs to.
// +optional
VPC *VPC `json:"vpc,omitempty"`
}

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

func (n *CloudStackIsolatedNetwork) Network() *Network {
return &Network{
Name: n.Spec.Name,
Type: "IsolatedNetwork",
ID: n.Spec.ID}
Name: n.Spec.Name,
Type: "IsolatedNetwork",
ID: n.Spec.ID,
Gateway: n.Spec.Gateway,
Netmask: n.Spec.Netmask,
VPC: n.Spec.VPC,
}
}

//+kubebuilder:object:root=true
Expand Down
37 changes: 32 additions & 5 deletions api/v1beta3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading