Skip to content

Commit

Permalink
Restore lint check for go comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mboersma committed Aug 24, 2022
1 parent 3e4628b commit fdb4a02
Show file tree
Hide file tree
Showing 32 changed files with 134 additions and 40 deletions.
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ linters-settings:
excludes:
- G307 # Deferring unsafe method "Close" on type "\*os.File"
- G108 # Profiling endpoint is automatically exposed on /debug/pprof
revive:
rules:
- name: exported
arguments:
- disableStutteringCheck
staticcheck:
go: "1.18"

Expand All @@ -121,6 +126,7 @@ issues:
- path: api/v1alpha3/azureclusteridentity_types.go
text: "methods on the same type should have the same receiver name"
include:
- EXC0002 # include "missing comments" issues from golint
- EXC0012 # revive: check for comments
- EXC0014 # revive: check for comments
max-issues-per-linter: 0
max-same-issues: 0
21 changes: 12 additions & 9 deletions api/v1alpha3/azurecluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func Convert_v1alpha3_AzureClusterStatus_To_v1beta1_AzureClusterStatus(in *Azure
return autoConvert_v1alpha3_AzureClusterStatus_To_v1beta1_AzureClusterStatus(in, out, s)
}

// Convert_v1alpha3_AzureClusterSpec_To_v1beta1_AzureClusterSpec.
// Convert_v1alpha3_AzureClusterSpec_To_v1beta1_AzureClusterSpec converts AzureCluster.Spec from v1alpha3 to v1beta1.
func Convert_v1alpha3_AzureClusterSpec_To_v1beta1_AzureClusterSpec(in *AzureClusterSpec, out *infrav1.AzureClusterSpec, s apiconversion.Scope) error {
if err := autoConvert_v1alpha3_AzureClusterSpec_To_v1beta1_AzureClusterSpec(in, out, s); err != nil {
return err
Expand Down Expand Up @@ -181,12 +181,12 @@ func Convert_v1beta1_AzureClusterSpec_To_v1alpha3_AzureClusterSpec(in *infrav1.A
return nil
}

// Convert_v1beta1_AzureClusterStatus_To_v1alpha3_AzureClusterStatus.
// Convert_v1beta1_AzureClusterStatus_To_v1alpha3_AzureClusterStatus converts an Azure cluster status from v1beta1 to v1alpha3.
func Convert_v1beta1_AzureClusterStatus_To_v1alpha3_AzureClusterStatus(in *infrav1.AzureClusterStatus, out *AzureClusterStatus, s apiconversion.Scope) error {
return autoConvert_v1beta1_AzureClusterStatus_To_v1alpha3_AzureClusterStatus(in, out, s)
}

// Convert_v1alpha3_NetworkSpec_To_v1beta1_NetworkSpec.
// Convert_v1alpha3_NetworkSpec_To_v1beta1_NetworkSpec converts a network spec from v1alpha3 to v1beta1.
func Convert_v1alpha3_NetworkSpec_To_v1beta1_NetworkSpec(in *NetworkSpec, out *infrav1.NetworkSpec, s apiconversion.Scope) error {
if err := Convert_v1alpha3_VnetSpec_To_v1beta1_VnetSpec(&in.Vnet, &out.Vnet, s); err != nil {
return err
Expand All @@ -203,7 +203,7 @@ func Convert_v1alpha3_NetworkSpec_To_v1beta1_NetworkSpec(in *NetworkSpec, out *i
return Convert_v1alpha3_LoadBalancerSpec_To_v1beta1_LoadBalancerSpec(&in.APIServerLB, &out.APIServerLB, s)
}

// Convert_v1beta1_NetworkSpec_To_v1alpha3_NetworkSpec.
// Convert_v1beta1_NetworkSpec_To_v1alpha3_NetworkSpec converts a network spec from v1beta1 to v1alpha3.
func Convert_v1beta1_NetworkSpec_To_v1alpha3_NetworkSpec(in *infrav1.NetworkSpec, out *NetworkSpec, s apiconversion.Scope) error {
if err := Convert_v1beta1_VnetSpec_To_v1alpha3_VnetSpec(&in.Vnet, &out.Vnet, s); err != nil {
return err
Expand All @@ -220,7 +220,7 @@ func Convert_v1beta1_NetworkSpec_To_v1alpha3_NetworkSpec(in *infrav1.NetworkSpec
return Convert_v1beta1_LoadBalancerSpec_To_v1alpha3_LoadBalancerSpec(&in.APIServerLB, &out.APIServerLB, s)
}

// Convert_v1beta1_VnetSpec_To_v1alpha3_VnetSpec.
// Convert_v1beta1_VnetSpec_To_v1alpha3_VnetSpec converts a virtual network spec from v1beta1 to v1alpha3.
func Convert_v1beta1_VnetSpec_To_v1alpha3_VnetSpec(in *infrav1.VnetSpec, out *VnetSpec, s apiconversion.Scope) error {
if err := autoConvert_v1beta1_VnetSpec_To_v1alpha3_VnetSpec(in, out, s); err != nil {
return err
Expand All @@ -233,7 +233,7 @@ func Convert_v1beta1_VnetSpec_To_v1alpha3_VnetSpec(in *infrav1.VnetSpec, out *Vn
return nil
}

// Convert_v1alpha3_SubnetSpec_To_v1beta1_SubnetSpec.
// Convert_v1alpha3_SubnetSpec_To_v1beta1_SubnetSpec converts a subnet spec from v1alpha3 to v1beta1.
func Convert_v1alpha3_SubnetSpec_To_v1beta1_SubnetSpec(in *SubnetSpec, out *infrav1.SubnetSpec, s apiconversion.Scope) error {
if err := autoConvert_v1alpha3_SubnetSpec_To_v1beta1_SubnetSpec(in, out, s); err != nil {
return err
Expand All @@ -246,7 +246,7 @@ func Convert_v1alpha3_SubnetSpec_To_v1beta1_SubnetSpec(in *SubnetSpec, out *infr
return nil
}

// Convert_v1beta1_SubnetSpec_To_v1alpha3_SubnetSpec.
// Convert_v1beta1_SubnetSpec_To_v1alpha3_SubnetSpec converts a subnet spec from v1beta1 to v1alpha3.
func Convert_v1beta1_SubnetSpec_To_v1alpha3_SubnetSpec(in *infrav1.SubnetSpec, out *SubnetSpec, s apiconversion.Scope) error {
if err := autoConvert_v1beta1_SubnetSpec_To_v1alpha3_SubnetSpec(in, out, s); err != nil {
return err
Expand All @@ -259,6 +259,7 @@ func Convert_v1beta1_SubnetSpec_To_v1alpha3_SubnetSpec(in *infrav1.SubnetSpec, o
return nil
}

// Convert_v1beta1_SecurityGroup_To_v1alpha3_SecurityGroup converts a security group from v1beta1 to v1alpha3.
func Convert_v1beta1_SecurityGroup_To_v1alpha3_SecurityGroup(in *infrav1.SecurityGroup, out *SecurityGroup, s apiconversion.Scope) error {
out.ID = in.ID
out.Name = in.Name
Expand All @@ -279,6 +280,7 @@ func Convert_v1beta1_SecurityGroup_To_v1alpha3_SecurityGroup(in *infrav1.Securit
return nil
}

// Convert_v1alpha3_SecurityGroup_To_v1beta1_SecurityGroup converts a security group from v1alpha3 to v1beta1.
func Convert_v1alpha3_SecurityGroup_To_v1beta1_SecurityGroup(in *SecurityGroup, out *infrav1.SecurityGroup, s apiconversion.Scope) error {
out.ID = in.ID
out.Name = in.Name
Expand All @@ -295,7 +297,7 @@ func Convert_v1alpha3_SecurityGroup_To_v1beta1_SecurityGroup(in *SecurityGroup,
return nil
}

// Convert_v1alpha3_IngressRule_To_v1beta1_SecurityRule.
// Convert_v1alpha3_IngressRule_To_v1beta1_SecurityRule converts from a v1alpha3 IngressRule to a v1beta1 SecurityRule.
func Convert_v1alpha3_IngressRule_To_v1beta1_SecurityRule(in *IngressRule, out *infrav1.SecurityRule, _ apiconversion.Scope) error {
out.Name = in.Name
out.Description = in.Description
Expand All @@ -309,7 +311,7 @@ func Convert_v1alpha3_IngressRule_To_v1beta1_SecurityRule(in *IngressRule, out *
return nil
}

// Convert_v1beta1_SecurityRule_To_v1alpha3_IngressRule.
// Convert_v1beta1_SecurityRule_To_v1alpha3_IngressRule converts from a v1beta1 SecurityRule to a v1alpha3 IngressRule.
func Convert_v1beta1_SecurityRule_To_v1alpha3_IngressRule(in *infrav1.SecurityRule, out *IngressRule, _ apiconversion.Scope) error {
out.Name = in.Name
out.Description = in.Description
Expand Down Expand Up @@ -359,6 +361,7 @@ func Convert_v1beta1_LoadBalancerSpec_To_v1alpha3_LoadBalancerSpec(in *infrav1.L
return nil
}

// Convert_v1alpha3_LoadBalancerSpec_To_v1beta1_LoadBalancerSpec converts an LB spec from v1alpha3 to v1beta1.
func Convert_v1alpha3_LoadBalancerSpec_To_v1beta1_LoadBalancerSpec(in *LoadBalancerSpec, out *infrav1.LoadBalancerSpec, s apiconversion.Scope) error {
if err := autoConvert_v1alpha3_LoadBalancerSpec_To_v1beta1_LoadBalancerSpec(in, out, s); err != nil {
return err
Expand Down
5 changes: 3 additions & 2 deletions api/v1alpha3/azureclusteridentity_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
)

const (
// AzureClusterKind is the Kubernetes Kind for AzureCluster.
AzureClusterKind = "AzureCluster"
)

Expand Down Expand Up @@ -88,12 +89,12 @@ func (dst *AzureClusterIdentity) ConvertFrom(srcRaw conversion.Hub) error {
return nil
}

// Convert_v1alpha3_AzureClusterIdentitySpec_To_v1beta1_AzureClusterIdentitySpec.
// Convert_v1alpha3_AzureClusterIdentitySpec_To_v1beta1_AzureClusterIdentitySpec converts an Azure cluster identity spec from v1alpha3 to v1beta1.
func Convert_v1alpha3_AzureClusterIdentitySpec_To_v1beta1_AzureClusterIdentitySpec(in *AzureClusterIdentitySpec, out *infrav1.AzureClusterIdentitySpec, s apiconversion.Scope) error {
return autoConvert_v1alpha3_AzureClusterIdentitySpec_To_v1beta1_AzureClusterIdentitySpec(in, out, s)
}

// Convert_v1beta1_AzureClusterIdentitySpec_To_v1alpha3_AzureClusterIdentitySpec.
// Convert_v1beta1_AzureClusterIdentitySpec_To_v1alpha3_AzureClusterIdentitySpec converts an Azure cluster identity spec from v1beta1 to v1alpha3.
func Convert_v1beta1_AzureClusterIdentitySpec_To_v1alpha3_AzureClusterIdentitySpec(in *infrav1.AzureClusterIdentitySpec, out *AzureClusterIdentitySpec, s apiconversion.Scope) error {
return autoConvert_v1beta1_AzureClusterIdentitySpec_To_v1alpha3_AzureClusterIdentitySpec(in, out, s)
}
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha3/azuremachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (dst *AzureMachineList) ConvertFrom(srcRaw conversion.Hub) error {
return Convert_v1beta1_AzureMachineList_To_v1alpha3_AzureMachineList(src, dst, nil)
}

// Convert_v1alpha3_AzureMachineSpec_To_v1beta1_AzureMachineSpec converts this AzureMachineSpec to the Hub version (v1beta1).
func Convert_v1alpha3_AzureMachineSpec_To_v1beta1_AzureMachineSpec(in *AzureMachineSpec, out *infrav1.AzureMachineSpec, s apiconversion.Scope) error {
return autoConvert_v1alpha3_AzureMachineSpec_To_v1beta1_AzureMachineSpec(in, out, s)
}
Expand Down Expand Up @@ -157,6 +158,7 @@ func Convert_v1beta1_ManagedDiskParameters_To_v1alpha3_ManagedDisk(in *infrav1.M
return nil
}

// Convert_v1beta1_AzureMarketplaceImage_To_v1alpha3_AzureMarketplaceImage converts an Azure Marketplace image from v1beta1 to v1alpha3.
func Convert_v1beta1_AzureMarketplaceImage_To_v1alpha3_AzureMarketplaceImage(in *infrav1.AzureMarketplaceImage, out *AzureMarketplaceImage, s apiconversion.Scope) error {
out.Offer = in.ImagePlan.Offer
out.Publisher = in.ImagePlan.Publisher
Expand All @@ -165,6 +167,7 @@ func Convert_v1beta1_AzureMarketplaceImage_To_v1alpha3_AzureMarketplaceImage(in
return autoConvert_v1beta1_AzureMarketplaceImage_To_v1alpha3_AzureMarketplaceImage(in, out, s)
}

// Convert_v1alpha3_AzureMarketplaceImage_To_v1beta1_AzureMarketplaceImage converts an Azure Marketplace image from v1alpha3 to v1beta1.
func Convert_v1alpha3_AzureMarketplaceImage_To_v1beta1_AzureMarketplaceImage(in *AzureMarketplaceImage, out *infrav1.AzureMarketplaceImage, s apiconversion.Scope) error {
out.ImagePlan.Offer = in.Offer
out.ImagePlan.Publisher = in.Publisher
Expand All @@ -173,6 +176,7 @@ func Convert_v1alpha3_AzureMarketplaceImage_To_v1beta1_AzureMarketplaceImage(in
return autoConvert_v1alpha3_AzureMarketplaceImage_To_v1beta1_AzureMarketplaceImage(in, out, s)
}

// Convert_v1beta1_Image_To_v1alpha3_Image converts an image from v1beta1 to v1alpha3.
func Convert_v1beta1_Image_To_v1alpha3_Image(in *infrav1.Image, out *Image, s apiconversion.Scope) error {
return autoConvert_v1beta1_Image_To_v1alpha3_Image(in, out, s)
}
2 changes: 2 additions & 0 deletions api/v1alpha3/azuremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ func (dst *AzureMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error {
return Convert_v1beta1_AzureMachineTemplateList_To_v1alpha3_AzureMachineTemplateList(src, dst, nil)
}

// Convert_v1beta1_AzureSharedGalleryImage_To_v1alpha3_AzureSharedGalleryImage converts an Azure shared gallery image from v1beta1 to v1alpha3.
func Convert_v1beta1_AzureSharedGalleryImage_To_v1alpha3_AzureSharedGalleryImage(in *infrav1.AzureSharedGalleryImage, out *AzureSharedGalleryImage, s apimachineryconversion.Scope) error {
return autoConvert_v1beta1_AzureSharedGalleryImage_To_v1alpha3_AzureSharedGalleryImage(in, out, s)
}

// Convert_v1beta1_AzureMachineTemplateResource_To_v1alpha3_AzureMachineTemplateResource converts an Azure machine template resource from v1beta1 to v1alpha3.
func Convert_v1beta1_AzureMachineTemplateResource_To_v1alpha3_AzureMachineTemplateResource(in *infrav1.AzureMachineTemplateResource, out *AzureMachineTemplateResource, s apimachineryconversion.Scope) error {
return autoConvert_v1beta1_AzureMachineTemplateResource_To_v1alpha3_AzureMachineTemplateResource(in, out, s)
}
4 changes: 3 additions & 1 deletion api/v1alpha4/azurecluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (dst *AzureClusterList) ConvertFrom(srcRaw conversion.Hub) error {
return Convert_v1beta1_AzureClusterList_To_v1alpha4_AzureClusterList(src, dst, nil)
}

// Convert_v1beta1_VnetSpec_To_v1alpha4_VnetSpec.
// Convert_v1beta1_VnetSpec_To_v1alpha4_VnetSpec converts from the Hub version (v1beta1) of the VnetSpec to this version.
func Convert_v1beta1_VnetSpec_To_v1alpha4_VnetSpec(in *infrav1.VnetSpec, out *VnetSpec, s apiconversion.Scope) error {
if err := autoConvert_v1beta1_VnetSpec_To_v1alpha4_VnetSpec(in, out, s); err != nil {
return err
Expand Down Expand Up @@ -327,6 +327,7 @@ func Convert_v1beta1_SecurityGroup_To_v1alpha4_SecurityGroup(in *infrav1.Securit
return nil
}

// Convert_v1alpha4_NatGateway_To_v1beta1_NatGateway converts a NAT gateway from v1alpha4 to v1beta1.
func Convert_v1alpha4_NatGateway_To_v1beta1_NatGateway(in *NatGateway, out *infrav1.NatGateway, s apiconversion.Scope) error {
if err := autoConvert_v1alpha4_NatGateway_To_v1beta1_NatGateway(in, out, s); err != nil {
return err
Expand All @@ -337,6 +338,7 @@ func Convert_v1alpha4_NatGateway_To_v1beta1_NatGateway(in *NatGateway, out *infr
return nil
}

// Convert_v1beta1_NatGateway_To_v1alpha4_NatGateway converts a NatGateway from v1beta1 to v1alpha4.
func Convert_v1beta1_NatGateway_To_v1alpha4_NatGateway(in *infrav1.NatGateway, out *NatGateway, s apiconversion.Scope) error {
if err := autoConvert_v1beta1_NatGateway_To_v1alpha4_NatGateway(in, out, s); err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions api/v1alpha4/azuremachine_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (dst *AzureMachineList) ConvertFrom(srcRaw conversion.Hub) error {
return Convert_v1beta1_AzureMachineList_To_v1alpha4_AzureMachineList(src, dst, nil)
}

// Convert_v1beta1_AzureMarketplaceImage_To_v1alpha4_AzureMarketplaceImage converts an Azure Marketplace image from v1beta1 to v1alpha4.
func Convert_v1beta1_AzureMarketplaceImage_To_v1alpha4_AzureMarketplaceImage(in *infrav1.AzureMarketplaceImage, out *AzureMarketplaceImage, s apiconversion.Scope) error {
out.Offer = in.ImagePlan.Offer
out.Publisher = in.ImagePlan.Publisher
Expand All @@ -82,6 +83,7 @@ func Convert_v1beta1_AzureMarketplaceImage_To_v1alpha4_AzureMarketplaceImage(in
return autoConvert_v1beta1_AzureMarketplaceImage_To_v1alpha4_AzureMarketplaceImage(in, out, s)
}

// Convert_v1alpha4_AzureMarketplaceImage_To_v1beta1_AzureMarketplaceImage converts an Azure Marketplace image from v1alpha4 to v1beta1.
func Convert_v1alpha4_AzureMarketplaceImage_To_v1beta1_AzureMarketplaceImage(in *AzureMarketplaceImage, out *infrav1.AzureMarketplaceImage, s apiconversion.Scope) error {
out.ImagePlan.Offer = in.Offer
out.ImagePlan.Publisher = in.Publisher
Expand All @@ -90,6 +92,7 @@ func Convert_v1alpha4_AzureMarketplaceImage_To_v1beta1_AzureMarketplaceImage(in
return autoConvert_v1alpha4_AzureMarketplaceImage_To_v1beta1_AzureMarketplaceImage(in, out, s)
}

// Convert_v1beta1_Image_To_v1alpha4_Image converts an image from v1beta1 to v1alpha4.
func Convert_v1beta1_Image_To_v1alpha4_Image(in *infrav1.Image, out *Image, s apiconversion.Scope) error {
return autoConvert_v1beta1_Image_To_v1alpha4_Image(in, out, s)
}
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha4/azuremachinetemplate_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func (dst *AzureMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error {
return Convert_v1beta1_AzureMachineTemplateList_To_v1alpha4_AzureMachineTemplateList(src, dst, nil)
}

// Convert_v1beta1_AzureMachineTemplateResource_To_v1alpha4_AzureMachineTemplateResource converts an Azure Machine Template Resource from v1beta1 to v1alpha4.
func Convert_v1beta1_AzureMachineTemplateResource_To_v1alpha4_AzureMachineTemplateResource(in *infrav1.AzureMachineTemplateResource, out *AzureMachineTemplateResource, s apimachineryconversion.Scope) error {
return autoConvert_v1beta1_AzureMachineTemplateResource_To_v1alpha4_AzureMachineTemplateResource(in, out, s)
}
2 changes: 2 additions & 0 deletions api/v1beta1/azurecluster_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func (c *AzureCluster) setAPIServerLBDefaults() {
}
}

// SetNodeOutboundLBDefaults sets the default values for the NodeOutboundLB.
func (c *AzureCluster) SetNodeOutboundLBDefaults() {
if c.Spec.NetworkSpec.NodeOutboundLB == nil {
if c.Spec.NetworkSpec.APIServerLB.Type == Internal {
Expand Down Expand Up @@ -230,6 +231,7 @@ func (c *AzureCluster) SetNodeOutboundLBDefaults() {
c.setOutboundLBFrontendIPs(lb, generateNodeOutboundIPName)
}

// SetControlPlaneOutboundLBDefaults sets the default values for the control plane's outbound LB.
func (c *AzureCluster) SetControlPlaneOutboundLBDefaults() {
lb := c.Spec.NetworkSpec.ControlPlaneOutboundLB

Expand Down
3 changes: 2 additions & 1 deletion api/v1beta1/azureclustertemplate_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

// AzureClusterTemplateImmutableMsg ...
// AzureClusterTemplateImmutableMsg is the message used for errors on fields that are immutable.
const AzureClusterTemplateImmutableMsg = "AzureClusterTemplate spec.template.spec field is immutable. Please create new resource instead. ref doc: https://cluster-api.sigs.k8s.io/tasks/experimental-features/cluster-class/change-clusterclass.html"

// SetupWebhookWithManager will set up the webhook to be managed by the specified manager.
func (c *AzureClusterTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
return ctrl.NewWebhookManagedBy(mgr).
For(c).
Expand Down
3 changes: 3 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type VnetPeeringSpec struct {
VnetPeeringClassSpec `json:",inline"`
}

// VnetPeeringClassSpec specifies a virtual network peering class.
type VnetPeeringClassSpec struct {
// RemoteVnetName defines name of the remote virtual network.
RemoteVnetName string `json:"remoteVnetName"`
Expand Down Expand Up @@ -169,6 +170,7 @@ type NatGateway struct {
NatGatewayClassSpec `json:",inline"`
}

// NatGatewayClassSpec defines a NAT gateway class specification.
type NatGatewayClassSpec struct {
Name string `json:"name"`
}
Expand Down Expand Up @@ -367,6 +369,7 @@ type AzureComputeGalleryImage struct {
Plan *ImagePlan `json:"plan,omitempty"`
}

// ImagePlan contains plan information for marketplace images.
type ImagePlan struct {
// Publisher is the name of the organization that created the image
// +kubebuilder:validation:MinLength=1
Expand Down
11 changes: 10 additions & 1 deletion api/v1beta1/types_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import "github.com/pkg/errors"

// AzureClusterTemplateResourceSpec specifies an Azure cluster template resource.
type AzureClusterTemplateResourceSpec struct {
AzureClusterClassSpec `json:",inline"`

Expand All @@ -30,6 +31,7 @@ type AzureClusterTemplateResourceSpec struct {
BastionSpec BastionTemplateSpec `json:"bastionSpec,omitempty"`
}

// NetworkTemplateSpec specifies a network template.
type NetworkTemplateSpec struct {
NetworkClassSpec `json:",inline"`

Expand Down Expand Up @@ -65,7 +67,7 @@ func (n *NetworkTemplateSpec) GetControlPlaneSubnetTemplate() (SubnetTemplateSpe
return SubnetTemplateSpec{}, errors.Errorf("no subnet template found with role %s", SubnetControlPlane)
}

// UpdateControlPlaneSubnet updates the cluster control plane subnet.
// UpdateControlPlaneSubnetTemplate updates the cluster control plane subnet template.
func (n *NetworkTemplateSpec) UpdateControlPlaneSubnetTemplate(subnet SubnetTemplateSpec) {
for i, sn := range n.Subnets {
if sn.Role == SubnetControlPlane {
Expand All @@ -74,6 +76,7 @@ func (n *NetworkTemplateSpec) UpdateControlPlaneSubnetTemplate(subnet SubnetTemp
}
}

// VnetTemplateSpec defines the desired state of a virtual network.
type VnetTemplateSpec struct {
VnetClassSpec `json:",inline"`

Expand All @@ -82,8 +85,10 @@ type VnetTemplateSpec struct {
Peerings VnetPeeringsTemplateSpec `json:"peerings,omitempty"`
}

// VnetPeeringsTemplateSpec defines a list of peerings of the newly created virtual network with existing virtual networks.
type VnetPeeringsTemplateSpec []VnetPeeringClassSpec

// SubnetTemplateSpec specifies a template for a subnet.
type SubnetTemplateSpec struct {
SubnetClassSpec `json:",inline"`

Expand All @@ -96,17 +101,21 @@ type SubnetTemplateSpec struct {
NatGateway NatGatewayClassSpec `json:"natGateway,omitempty"`
}

// IsNatGatewayEnabled returns true if the NAT gateway is enabled.
func (s SubnetTemplateSpec) IsNatGatewayEnabled() bool {
return s.NatGateway.Name != ""
}

// SubnetTemplatesSpec specifies a list of subnet templates.
type SubnetTemplatesSpec []SubnetTemplateSpec

// BastionTemplateSpec specifies a template for a bastion host.
type BastionTemplateSpec struct {
// +optional
AzureBastion *AzureBastionTemplateSpec `json:"azureBastion,omitempty"`
}

// AzureBastionTemplateSpec specifies a template for an Azure Bastion host.
type AzureBastionTemplateSpec struct {
// +optional
Subnet SubnetTemplateSpec `json:"subnet,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions azure/converters/subnets.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/Azure/go-autorest/autorest/to"
)

// GetSubnetAddresses returns the address prefixes contained in a subnet.
func GetSubnetAddresses(subnet network.Subnet) []string {
var addresses []string
if subnet.SubnetPropertiesFormat != nil && subnet.SubnetPropertiesFormat.AddressPrefix != nil {
Expand Down
Loading

0 comments on commit fdb4a02

Please sign in to comment.