From 653d6e9196b1a5e67003da6c5e8850dd7690dd83 Mon Sep 17 00:00:00 2001 From: killianmuldoon Date: Mon, 25 Sep 2023 09:52:22 +0100 Subject: [PATCH] Remove lint ignore for comments Signed-off-by: killianmuldoon --- .golangci.yml | 34 +++++++------------ apis/v1alpha3/vsphereclusteridentity_types.go | 2 ++ apis/v1alpha4/vspherecluster_types.go | 2 ++ apis/v1alpha4/vsphereclusteridentity_types.go | 2 ++ apis/v1beta1/types.go | 17 +++++----- apis/v1beta1/vspherecluster_types.go | 12 ++++--- apis/v1beta1/vsphereclusteridentity_types.go | 21 +++++++++--- apis/v1beta1/vsphereclustertemplate_types.go | 6 ++-- apis/v1beta1/vspheredeploymentzone_types.go | 13 ++++--- apis/v1beta1/vspherefailuredomain_types.go | 18 ++++++---- apis/v1beta1/vspheremachine_types.go | 11 +++--- apis/v1beta1/vspheremachinetemplate_types.go | 7 ++-- apis/v1beta1/vspherevm_types.go | 11 +++--- apis/vmware/v1beta1/conditions_consts.go | 26 ++++++++------ .../v1beta1/providerserviceaccount_types.go | 3 +- apis/vmware/v1beta1/types.go | 3 +- apis/vmware/v1beta1/vspherecluster_types.go | 11 +++--- .../v1beta1/vsphereclustertemplate_types.go | 8 ++--- apis/vmware/v1beta1/vspheremachine_types.go | 11 +++--- .../v1beta1/vspheremachinetemplate_types.go | 8 ++--- ...ter.x-k8s.io_vsphereclusteridentities.yaml | 5 ++- ...ture.cluster.x-k8s.io_vsphereclusters.yaml | 6 ++-- ...ster.x-k8s.io_vsphereclustertemplates.yaml | 8 +++-- ...uster.x-k8s.io_vspheredeploymentzones.yaml | 5 +-- ...luster.x-k8s.io_vspherefailuredomains.yaml | 4 +-- ...ture.cluster.x-k8s.io_vspheremachines.yaml | 8 ++--- ...ster.x-k8s.io_vspheremachinetemplates.yaml | 8 ++--- ...structure.cluster.x-k8s.io_vspherevms.yaml | 6 ++-- ...ture.cluster.x-k8s.io_vsphereclusters.yaml | 6 ++-- ...ster.x-k8s.io_vsphereclustertemplates.yaml | 7 ++-- ...ture.cluster.x-k8s.io_vspheremachines.yaml | 6 ++-- ...ster.x-k8s.io_vspheremachinetemplates.yaml | 8 ++--- controllers/clustermodule_reconciler.go | 3 ++ controllers/serviceaccount_controller.go | 3 ++ controllers/servicediscovery_controller.go | 7 +++- .../vmware/vspherecluster_reconciler.go | 3 ++ controllers/vspherecluster_reconciler.go | 8 +++-- .../vsphereclusteridentity_controller.go | 1 + controllers/vspheremachine_controller.go | 1 - feature/feature.go | 1 + main.go | 1 + packaging/flavorgen/cloudprovider/csi.go | 1 + packaging/flavorgen/cmd/root.go | 1 + packaging/flavorgen/flavors/crs/cpi.go | 1 + .../flavors/crs/types/cloudprovider_types.go | 2 +- .../flavorgen/flavors/env/envsubts_consts.go | 10 +++--- packaging/flavorgen/flavors/flavors.go | 2 ++ packaging/flavorgen/flavors/util/helpers.go | 1 + packaging/flavorgen/main.go | 1 + pkg/clustermodule/error.go | 1 + pkg/clustermodule/fake/service.go | 1 + pkg/clustermodule/interfaces.go | 2 ++ pkg/clustermodule/service.go | 1 + pkg/clustermodule/types.go | 1 + pkg/clustermodule/util.go | 1 + pkg/config/config.go | 25 -------------- pkg/constants/constants.go | 5 ++- pkg/context/fake/constants.go | 1 + pkg/context/interfaces.go | 2 ++ pkg/context/machine_context.go | 6 ++++ pkg/context/vm_context.go | 1 + pkg/context/vmware/cluster_context.go | 1 + pkg/context/vmware/machine_context.go | 4 +++ pkg/context/vspheredeploymentzone_context.go | 5 +++ pkg/identity/identity.go | 6 ++++ pkg/manager/constants.go | 2 ++ pkg/manager/manager.go | 1 + pkg/manager/network.go | 7 ++-- pkg/manager/options_test.go | 5 ++- pkg/record/recorder.go | 1 + pkg/services/fake/vmservice.go | 1 + pkg/services/govmomi/cluster/rule.go | 2 ++ pkg/services/govmomi/cluster/service.go | 2 ++ pkg/services/govmomi/cluster/vmgroup.go | 1 + .../govmomi/clustermodules/provider.go | 8 +++++ pkg/services/govmomi/constants.go | 1 + pkg/services/govmomi/extra/config.go | 1 + pkg/services/govmomi/find/object.go | 2 ++ pkg/services/govmomi/ipam/error.go | 1 + pkg/services/govmomi/ipam/status.go | 2 ++ pkg/services/govmomi/metadata/metadata.go | 2 ++ pkg/services/govmomi/net/net.go | 1 + pkg/services/govmomi/pci/device.go | 3 ++ pkg/services/govmomi/template/template.go | 1 + pkg/services/govmomi/vcenter/clone.go | 1 + pkg/services/network/constants.go | 9 +++-- pkg/services/network/netop_provider.go | 6 ++++ pkg/services/vimmachine.go | 8 +++++ pkg/services/vmoperator/constants.go | 12 +++++-- pkg/services/vmoperator/vmopmachine.go | 7 ++++ pkg/session/error.go | 1 + pkg/session/session.go | 11 ++++++ pkg/taggable/get.go | 2 ++ pkg/taggable/object.go | 2 ++ pkg/util/constants.go | 1 + pkg/util/errors.go | 1 + pkg/util/fetch_object.go | 3 ++ pkg/util/machines.go | 1 + pkg/util/networkutil.go | 22 ++++++++---- pkg/util/supervisor.go | 1 + pkg/util/vmware/util.go | 3 +- test/e2e/common.go | 1 + test/helpers/envtest.go | 2 ++ test/helpers/vcsim/simulator.go | 1 + test/helpers/vmware/unit_test_context.go | 1 + test/helpers/webhook.go | 4 ++- 106 files changed, 367 insertions(+), 190 deletions(-) delete mode 100644 pkg/config/config.go diff --git a/.golangci.yml b/.golangci.yml index 85d26f3b57..a8f0640e82 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -261,35 +261,25 @@ issues: - stylecheck text: "ST1016: methods on the same type should have the same receiver name" path: ^apis\/.*\/.*conversion.*\.go$ - - # FIXME: All below excludes should get removed over time. - - # missing comments + # missing comments on v1alpha3 and v1alpha4 packages. These rules should be removed when those packages are removed. - linters: - - revive + - revive text: "package-comments" - path: ^(main|(packaging|apis|controllers|feature|test|pkg)\/.*)\.go$ + path: ^(apis/(v1alpha3|v1alpha4)\/.*)\.go$ - linters: - - stylecheck + - stylecheck text: "ST1000" - path: ^(main|(packaging|apis|controllers|feature|test|pkg)\/.*)\.go$ + path: ^(apis/(v1alpha3|v1alpha4)\/.*)\.go$ - linters: - - revive + - revive text: exported (.*) should have comment (.*)or be unexported - path: "^(apis|controllers|packaging|pkg)/.*.go" - - # wrong comment + path: ^(apis/(v1alpha3|v1alpha4)\/.*)\.go$ + # wrong comment - linters: - - revive + - revive text: comment on exported (.*) should be of the form (.*) - path: "^(apis|packaging|pkg/(constants|services|util))/" + path: ^(apis/(v1alpha3|v1alpha4)\/.*)\.go$ - linters: - - stylecheck + - stylecheck text: ST1021|ST1020 - path: "^(apis|packaging|pkg/(constants|services|util))/" - - # gosec - - linters: - - gosec - text: "G104: Errors unhandled." - path: ^(controllers/vspherecluster_reconciler|pkg/manager/options_test|test/helpers/webhook)\.go$ + path: ^(apis/(v1alpha3|v1alpha4)\/.*)\.go$ diff --git a/apis/v1alpha3/vsphereclusteridentity_types.go b/apis/v1alpha3/vsphereclusteridentity_types.go index 77db74825b..0e01e926d8 100644 --- a/apis/v1alpha3/vsphereclusteridentity_types.go +++ b/apis/v1alpha3/vsphereclusteridentity_types.go @@ -22,6 +22,7 @@ import ( ) const ( + // SecretIdentitySetFinalizer is the finalizer for VSphereCluster credentials secrets . SecretIdentitySetFinalizer = "vspherecluster/infrastructure.cluster.x-k8s.io" ) @@ -94,6 +95,7 @@ type VSphereClusterIdentity struct { } // +kubebuilder:object:root=true + // VSphereClusterIdentityList contains a list of VSphereClusterIdentity // // Deprecated: This type will be removed in one of the next releases. diff --git a/apis/v1alpha4/vspherecluster_types.go b/apis/v1alpha4/vspherecluster_types.go index 1432637100..df17a5bd9c 100644 --- a/apis/v1alpha4/vspherecluster_types.go +++ b/apis/v1alpha4/vspherecluster_types.go @@ -81,10 +81,12 @@ type VSphereCluster struct { Status VSphereClusterStatus `json:"status,omitempty"` } +// GetConditions returns the conditions for the VSphereCluster. func (c *VSphereCluster) GetConditions() clusterv1alpha4.Conditions { return c.Status.Conditions } +// GetConditions sets conditions on the VSphereCluster. func (c *VSphereCluster) SetConditions(conditions clusterv1alpha4.Conditions) { c.Status.Conditions = conditions } diff --git a/apis/v1alpha4/vsphereclusteridentity_types.go b/apis/v1alpha4/vsphereclusteridentity_types.go index 4217a78673..5ed3b6a866 100644 --- a/apis/v1alpha4/vsphereclusteridentity_types.go +++ b/apis/v1alpha4/vsphereclusteridentity_types.go @@ -22,6 +22,7 @@ import ( ) const ( + // SecretIdentitySetFinalizer is the finalizer for VSphereCluster credentials secrets . SecretIdentitySetFinalizer = "vspherecluster/infrastructure.cluster.x-k8s.io" ) @@ -94,6 +95,7 @@ type VSphereClusterIdentity struct { } // +kubebuilder:object:root=true + // VSphereClusterIdentityList contains a list of VSphereClusterIdentity // // Deprecated: This type will be removed in one of the next releases. diff --git a/apis/v1beta1/types.go b/apis/v1beta1/types.go index 0e79d22f13..99885028dd 100644 --- a/apis/v1beta1/types.go +++ b/apis/v1beta1/types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -206,7 +205,7 @@ type VirtualMachineCloneSpec struct { HardwareVersion string `json:"hardwareVersion,omitempty"` } -// VSphereMachineTemplateResource describes the data needed to create a VSphereMachine from a template +// VSphereMachineTemplateResource describes the data needed to create a VSphereMachine from a template. type VSphereMachineTemplateResource struct { // Standard object's metadata. @@ -218,10 +217,10 @@ type VSphereMachineTemplateResource struct { Spec VSphereMachineSpec `json:"spec"` } -// VSphereMachineProviderConditionType is a valid value for VSphereMachineProviderCondition.Type +// VSphereMachineProviderConditionType is a valid value for VSphereMachineProviderCondition.Type. type VSphereMachineProviderConditionType string -// Valid conditions for an VSphere machine instance +// Valid conditions for an VSphere machine instance. const ( // MachineCreated indicates whether the machine has been created or not. If not, // it should include a reason and message for the failure. @@ -247,7 +246,7 @@ func (v APIEndpoint) String() string { return fmt.Sprintf("%s:%d", v.Host, v.Port) } -// PCIDeviceSpec defines virtual machine's PCI configuration +// PCIDeviceSpec defines virtual machine's PCI configuration. type PCIDeviceSpec struct { // DeviceID is the device ID of a virtual machine's PCI, in integer. // Defaults to the eponymous property value in the template from which the @@ -461,17 +460,17 @@ const ( VirtualMachineStateReady = "ready" ) -// VirtualMachinePowerState describe the power state of a VM +// VirtualMachinePowerState describe the power state of a VM. type VirtualMachinePowerState string const ( - // VirtualMachinePowerStatePoweredOn is the string representing a VM in powered on state + // VirtualMachinePowerStatePoweredOn is the string representing a VM in powered on state. VirtualMachinePowerStatePoweredOn VirtualMachinePowerState = "poweredOn" - // VirtualMachinePowerStatePoweredOff is the string representing a VM in powered off state + // VirtualMachinePowerStatePoweredOff is the string representing a VM in powered off state. VirtualMachinePowerStatePoweredOff = "poweredOff" - // VirtualMachinePowerStateSuspended is the string representing a VM in suspended state + // VirtualMachinePowerStateSuspended is the string representing a VM in suspended state. VirtualMachinePowerStateSuspended = "suspended" ) diff --git a/apis/v1beta1/vspherecluster_types.go b/apis/v1beta1/vspherecluster_types.go index aaa07a5829..15c5036207 100644 --- a/apis/v1beta1/vspherecluster_types.go +++ b/apis/v1beta1/vspherecluster_types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -32,11 +31,12 @@ const ( // VCenterVersion conveys the API version of the vCenter instance. type VCenterVersion string +// NewVCenterVersion returns a VCenterVersion for the passed string. func NewVCenterVersion(version string) VCenterVersion { return VCenterVersion(version) } -// VSphereClusterSpec defines the desired state of VSphereCluster +// VSphereClusterSpec defines the desired state of VSphereCluster. type VSphereClusterSpec struct { // Server is the address of the vSphere endpoint. Server string `json:"server,omitempty"` @@ -84,7 +84,7 @@ type ClusterModule struct { ModuleUUID string `json:"moduleUUID"` } -// VSphereClusterStatus defines the observed state of VSphereClusterSpec +// VSphereClusterStatus defines the observed state of VSphereClusterSpec. type VSphereClusterStatus struct { // +optional Ready bool `json:"ready,omitempty"` @@ -109,7 +109,7 @@ type VSphereClusterStatus struct { // +kubebuilder:printcolumn:name="ControlPlaneEndpoint",type="string",JSONPath=".spec.controlPlaneEndpoint[0]",description="API Endpoint",priority=1 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Machine" -// VSphereCluster is the Schema for the vsphereclusters API +// VSphereCluster is the Schema for the vsphereclusters API. type VSphereCluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -118,17 +118,19 @@ type VSphereCluster struct { Status VSphereClusterStatus `json:"status,omitempty"` } +// GetConditions returns the conditions for the VSphereCluster. func (c *VSphereCluster) GetConditions() clusterv1.Conditions { return c.Status.Conditions } +// SetConditions sets conditions on the VSphereCluster. func (c *VSphereCluster) SetConditions(conditions clusterv1.Conditions) { c.Status.Conditions = conditions } // +kubebuilder:object:root=true -// VSphereClusterList contains a list of VSphereCluster +// VSphereClusterList contains a list of VSphereCluster. type VSphereClusterList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/apis/v1beta1/vsphereclusteridentity_types.go b/apis/v1beta1/vsphereclusteridentity_types.go index c215875314..97130334d3 100644 --- a/apis/v1beta1/vsphereclusteridentity_types.go +++ b/apis/v1beta1/vsphereclusteridentity_types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -23,10 +22,13 @@ import ( ) const ( - SecretIdentitySetFinalizer = "vspherecluster/infrastructure.cluster.x-k8s.io" + // SecretIdentitySetFinalizer is the finalizer for VSphereCluster credentials secrets . + SecretIdentitySetFinalizer = "vspherecluster/infrastructure.cluster.x-k8s.io" + // VSphereClusterIdentityFinalizer is the finalizer for VSphereClusterIdentity credentials secrets. VSphereClusterIdentityFinalizer = "vsphereclusteridentity/infrastructure.cluster.x-k8s.io" ) +// VSphereClusterIdentitySpec contains a secret reference and a group of allowed namespaces. type VSphereClusterIdentitySpec struct { // SecretName references a Secret inside the controller namespace with the credentials to use // +kubebuilder:validation:MinLength=1 @@ -39,6 +41,7 @@ type VSphereClusterIdentitySpec struct { AllowedNamespaces *AllowedNamespaces `json:"allowedNamespaces,omitempty"` } +// VSphereClusterIdentityStatus contains the status of the VSphereClusterIdentity. type VSphereClusterIdentityStatus struct { // +optional Ready bool `json:"ready,omitempty"` @@ -48,19 +51,24 @@ type VSphereClusterIdentityStatus struct { Conditions clusterv1.Conditions `json:"conditions,omitempty"` } +// AllowedNamespaces restricts the namespaces this VSphereClusterIdentity can be used from. type AllowedNamespaces struct { // Selector is a standard Kubernetes LabelSelector. A label query over a set of resources. // +optional Selector metav1.LabelSelector `json:"selector"` } +// VSphereIdentityKind is the kind of mechanism used to handle credentials for the VCenter API. type VSphereIdentityKind string var ( + // VSphereClusterIdentityKind is used when a VSphereClusterIdentity is referenced in a VSphereCluster. VSphereClusterIdentityKind = VSphereIdentityKind("VSphereClusterIdentity") - SecretKind = VSphereIdentityKind("Secret") + // SecretKind is used when a secret is referenced directly in a VSphereCluster. + SecretKind = VSphereIdentityKind("Secret") ) +// VSphereIdentityReference is the mechanism used to handle credentials for the VCenter API. type VSphereIdentityReference struct { // Kind of the identity. Can either be VSphereClusterIdentity or Secret // +kubebuilder:validation:Enum=VSphereClusterIdentity;Secret @@ -71,10 +79,12 @@ type VSphereIdentityReference struct { Name string `json:"name"` } +// GetConditions returns the conditions for the VSphereClusterIdentity. func (c *VSphereClusterIdentity) GetConditions() clusterv1.Conditions { return c.Status.Conditions } +// SetConditions sets the conditions on the VSphereClusterIdentity. func (c *VSphereClusterIdentity) SetConditions(conditions clusterv1.Conditions) { c.Status.Conditions = conditions } @@ -84,7 +94,7 @@ func (c *VSphereClusterIdentity) SetConditions(conditions clusterv1.Conditions) // +kubebuilder:storageversion // +kubebuilder:subresource:status -// VSphereClusterIdentity defines the account to be used for reconciling clusters +// VSphereClusterIdentity defines the account to be used for reconciling clusters. type VSphereClusterIdentity struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -94,7 +104,8 @@ type VSphereClusterIdentity struct { } // +kubebuilder:object:root=true -// VSphereClusterIdentityList contains a list of VSphereClusterIdentity + +// VSphereClusterIdentityList contains a list of VSphereClusterIdentity. type VSphereClusterIdentityList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/apis/v1beta1/vsphereclustertemplate_types.go b/apis/v1beta1/vsphereclustertemplate_types.go index f8106c9219..eec52b1b22 100644 --- a/apis/v1beta1/vsphereclustertemplate_types.go +++ b/apis/v1beta1/vsphereclustertemplate_types.go @@ -14,14 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// VSphereClusterTemplateSpec defines the desired state of VSphereClusterTemplate +// VSphereClusterTemplateSpec defines the desired state of VSphereClusterTemplate. type VSphereClusterTemplateSpec struct { Template VSphereClusterTemplateResource `json:"template"` } @@ -30,7 +29,7 @@ type VSphereClusterTemplateSpec struct { // +kubebuilder:resource:path=vsphereclustertemplates,scope=Namespaced,categories=cluster-api // +kubebuilder:storageversion -// VSphereClusterTemplate is the Schema for the vsphereclustertemplates API +// VSphereClusterTemplate is the Schema for the vsphereclustertemplates API. type VSphereClusterTemplate struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -51,6 +50,7 @@ func init() { objectTypes = append(objectTypes, &VSphereClusterTemplate{}, &VSphereClusterTemplateList{}) } +// VSphereClusterTemplateResource describes the data for creating a VSphereCluster from a template. type VSphereClusterTemplateResource struct { Spec VSphereClusterSpec `json:"spec"` } diff --git a/apis/v1beta1/vspheredeploymentzone_types.go b/apis/v1beta1/vspheredeploymentzone_types.go index ca6314312b..efdbc60b61 100644 --- a/apis/v1beta1/vspheredeploymentzone_types.go +++ b/apis/v1beta1/vspheredeploymentzone_types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -29,7 +28,7 @@ const ( DeploymentZoneFinalizer = "vspheredeploymentzone.infrastructure.cluster.x-k8s.io" ) -// VSphereDeploymentZoneSpec defines the desired state of VSphereDeploymentZone +// VSphereDeploymentZoneSpec defines the desired state of VSphereDeploymentZone. type VSphereDeploymentZoneSpec struct { // Server is the address of the vSphere endpoint. @@ -47,7 +46,7 @@ type VSphereDeploymentZoneSpec struct { PlacementConstraint PlacementConstraint `json:"placementConstraint"` } -// PlacementConstraint is the context information for VM placements within a failure domain +// PlacementConstraint is the context information for VM placements within a failure domain. type PlacementConstraint struct { // ResourcePool is the name or inventory path of the resource pool in which // the virtual machine is created/located. @@ -60,6 +59,7 @@ type PlacementConstraint struct { Folder string `json:"folder,omitempty"` } +// Network holds information about the network. type Network struct { // Name is the network name for this machine's VM. Name string `json:"name,omitempty"` @@ -73,6 +73,7 @@ type Network struct { DHCP6 *bool `json:"dhcp6,omitempty"` } +// VSphereDeploymentZoneStatus contains the status for a VSphereDeploymentZone. type VSphereDeploymentZoneStatus struct { // Ready is true when the VSphereDeploymentZone resource is ready. // If set to false, it will be ignored by VSphereClusters @@ -89,7 +90,7 @@ type VSphereDeploymentZoneStatus struct { // +kubebuilder:resource:path=vspheredeploymentzones,scope=Cluster,categories=cluster-api // +kubebuilder:subresource:status -// VSphereDeploymentZone is the Schema for the vspheredeploymentzones API +// VSphereDeploymentZone is the Schema for the vspheredeploymentzones API. type VSphereDeploymentZone struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -98,17 +99,19 @@ type VSphereDeploymentZone struct { Status VSphereDeploymentZoneStatus `json:"status,omitempty"` } +// GetConditions returns the conditions for the VSphereDeploymentZone. func (z *VSphereDeploymentZone) GetConditions() clusterv1.Conditions { return z.Status.Conditions } +// SetConditions sets the conditions on the VSphereDeploymentZone. func (z *VSphereDeploymentZone) SetConditions(conditions clusterv1.Conditions) { z.Status.Conditions = conditions } // +kubebuilder:object:root=true -// VSphereDeploymentZoneList contains a list of VSphereDeploymentZone +// VSphereDeploymentZoneList contains a list of VSphereDeploymentZone. type VSphereDeploymentZoneList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/apis/v1beta1/vspherefailuredomain_types.go b/apis/v1beta1/vspherefailuredomain_types.go index d2c8377d4f..bcb139a97f 100644 --- a/apis/v1beta1/vspherefailuredomain_types.go +++ b/apis/v1beta1/vspherefailuredomain_types.go @@ -14,22 +14,25 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// FailureDomainType defines the VCenter object the failure domain represents. type FailureDomainType string const ( - HostGroupFailureDomain FailureDomainType = "HostGroup" + // HostGroupFailureDomain is a failure domain for a host group. + HostGroupFailureDomain FailureDomainType = "HostGroup" + // ComputeClusterFailureDomain is a failure domain for a compute cluster. ComputeClusterFailureDomain FailureDomainType = "ComputeCluster" - DatacenterFailureDomain FailureDomainType = "Datacenter" + // DatacenterFailureDomain is a failure domain for a datacenter. + DatacenterFailureDomain FailureDomainType = "Datacenter" ) -// VSphereFailureDomainSpec defines the desired state of VSphereFailureDomain +// VSphereFailureDomainSpec defines the desired state of VSphereFailureDomain. type VSphereFailureDomainSpec struct { // Region defines the name and type of a region @@ -42,6 +45,7 @@ type VSphereFailureDomainSpec struct { Topology Topology `json:"topology"` } +// FailureDomain contains data to identify and configure a failure domain. type FailureDomain struct { // Name is the name of the tag that represents this failure domain Name string `json:"name"` @@ -59,6 +63,7 @@ type FailureDomain struct { AutoConfigure *bool `json:"autoConfigure,omitempty"` } +// Topology describes a given failure domain using vSphere constructs. type Topology struct { // Datacenter as the failure domain. // +kubebuilder:validation:Required @@ -82,6 +87,7 @@ type Topology struct { Datastore string `json:"datastore,omitempty"` } +// FailureDomainHosts has information required for placement of machines on VSphere hosts. type FailureDomainHosts struct { // VMGroupName is the name of the VM group VMGroupName string `json:"vmGroupName"` @@ -94,7 +100,7 @@ type FailureDomainHosts struct { // +kubebuilder:storageversion // +kubebuilder:resource:path=vspherefailuredomains,scope=Cluster,categories=cluster-api -// VSphereFailureDomain is the Schema for the vspherefailuredomains API +// VSphereFailureDomain is the Schema for the vspherefailuredomains API. type VSphereFailureDomain struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -104,7 +110,7 @@ type VSphereFailureDomain struct { // +kubebuilder:object:root=true -// VSphereFailureDomainList contains a list of VSphereFailureDomain +// VSphereFailureDomainList contains a list of VSphereFailureDomain. type VSphereFailureDomainList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/apis/v1beta1/vspheremachine_types.go b/apis/v1beta1/vspheremachine_types.go index ae704e6b70..40c7682ce5 100644 --- a/apis/v1beta1/vspheremachine_types.go +++ b/apis/v1beta1/vspheremachine_types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -30,7 +29,7 @@ const ( MachineFinalizer = "vspheremachine.infrastructure.cluster.x-k8s.io" ) -// VSphereMachineSpec defines the desired state of VSphereMachine +// VSphereMachineSpec defines the desired state of VSphereMachine. type VSphereMachineSpec struct { VirtualMachineCloneSpec `json:",inline"` @@ -71,7 +70,7 @@ type VSphereMachineSpec struct { GuestSoftPowerOffTimeout *metav1.Duration `json:"guestSoftPowerOffTimeout,omitempty"` } -// VSphereMachineStatus defines the observed state of VSphereMachine +// VSphereMachineStatus defines the observed state of VSphereMachine. type VSphereMachineStatus struct { // Ready is true when the provider resource is ready. // +optional @@ -138,7 +137,7 @@ type VSphereMachineStatus struct { // +kubebuilder:printcolumn:name="Machine",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Machine\")].name",description="Machine object which owns with this VSphereMachine",priority=1 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of Machine" -// VSphereMachine is the Schema for the vspheremachines API +// VSphereMachine is the Schema for the vspheremachines API. type VSphereMachine struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -147,17 +146,19 @@ type VSphereMachine struct { Status VSphereMachineStatus `json:"status,omitempty"` } +// GetConditions returns the conditions for a VSphereMachine. func (m *VSphereMachine) GetConditions() clusterv1.Conditions { return m.Status.Conditions } +// SetConditions sets the conditions on a VSphereMachine. func (m *VSphereMachine) SetConditions(conditions clusterv1.Conditions) { m.Status.Conditions = conditions } // +kubebuilder:object:root=true -// VSphereMachineList contains a list of VSphereMachine +// VSphereMachineList contains a list of VSphereMachine. type VSphereMachineList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/apis/v1beta1/vspheremachinetemplate_types.go b/apis/v1beta1/vspheremachinetemplate_types.go index 0f47adafc9..25b7d9296b 100644 --- a/apis/v1beta1/vspheremachinetemplate_types.go +++ b/apis/v1beta1/vspheremachinetemplate_types.go @@ -14,14 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// VSphereMachineTemplateSpec defines the desired state of VSphereMachineTemplate +// VSphereMachineTemplateSpec defines the desired state of VSphereMachineTemplate. type VSphereMachineTemplateSpec struct { Template VSphereMachineTemplateResource `json:"template"` } @@ -30,7 +29,7 @@ type VSphereMachineTemplateSpec struct { // +kubebuilder:resource:path=vspheremachinetemplates,scope=Namespaced,categories=cluster-api // +kubebuilder:storageversion -// VSphereMachineTemplate is the Schema for the vspheremachinetemplates API +// VSphereMachineTemplate is the Schema for the vspheremachinetemplates API. type VSphereMachineTemplate struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -40,7 +39,7 @@ type VSphereMachineTemplate struct { // +kubebuilder:object:root=true -// VSphereMachineTemplateList contains a list of VSphereMachineTemplate +// VSphereMachineTemplateList contains a list of VSphereMachineTemplate. type VSphereMachineTemplateList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/apis/v1beta1/vspherevm_types.go b/apis/v1beta1/vspherevm_types.go index f0da736975..13a827b550 100644 --- a/apis/v1beta1/vspherevm_types.go +++ b/apis/v1beta1/vspherevm_types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -31,7 +30,7 @@ const ( // with a VSphereVM before removing it from the API Server. VMFinalizer = "vspherevm.infrastructure.cluster.x-k8s.io" - // IPClaimFinalizer allows the reconciler to prevent deletion of an + // IPAddressClaimFinalizer allows the reconciler to prevent deletion of an // IPAddressClaim that is in use. IPAddressClaimFinalizer = "vspherevm.infrastructure.cluster.x-k8s.io/ip-claim-protection" @@ -87,7 +86,7 @@ type VSphereVMSpec struct { GuestSoftPowerOffTimeout *metav1.Duration `json:"guestSoftPowerOffTimeout,omitempty"` } -// VSphereVMStatus defines the observed state of VSphereVM +// VSphereVMStatus defines the observed state of VSphereVM. type VSphereVMStatus struct { // Host describes the hostname or IP address of the infrastructure host // that the VSphereVM is residing on. @@ -186,7 +185,7 @@ type VSphereVMStatus struct { // +kubebuilder:storageversion // +kubebuilder:subresource:status -// VSphereVM is the Schema for the vspherevms API +// VSphereVM is the Schema for the vspherevms API. type VSphereVM struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -195,17 +194,19 @@ type VSphereVM struct { Status VSphereVMStatus `json:"status,omitempty"` } +// GetConditions returns the conditions for a VSphereVM. func (r *VSphereVM) GetConditions() clusterv1.Conditions { return r.Status.Conditions } +// SetConditions sets the conditions on a VSphereVM. func (r *VSphereVM) SetConditions(conditions clusterv1.Conditions) { r.Status.Conditions = conditions } // +kubebuilder:object:root=true -// VSphereVMList contains a list of VSphereVM +// VSphereVMList contains a list of VSphereVM. type VSphereVMList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/apis/vmware/v1beta1/conditions_consts.go b/apis/vmware/v1beta1/conditions_consts.go index 6e5fc8e019..010e181677 100644 --- a/apis/vmware/v1beta1/conditions_consts.go +++ b/apis/vmware/v1beta1/conditions_consts.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" @@ -34,7 +33,7 @@ const ( // Cluster Network. ClusterNetworkReadyCondition clusterv1.ConditionType = "ClusterNetworkReady" - // ClusterNetworkProvisionStarted is used when waiting for Cluster + // ClusterNetworkProvisionStartedReason is used when waiting for Cluster // Network to be Ready. ClusterNetworkProvisionStartedReason = "ClusterNetworkProvisionStarted" // ClusterNetworkProvisionFailedReason is used when any errors occur @@ -73,25 +72,30 @@ const ( const ( // ProviderServiceAccountsReadyCondition documents the status of provider service accounts - // and related Roles, RoleBindings and Secrets are created + // and related Roles, RoleBindings and Secrets are created. ProviderServiceAccountsReadyCondition clusterv1.ConditionType = "ProviderServiceAccountsReady" - // ProviderServiceAccountsReconciliationFailedReason reports that provider service accounts related resources reconciliation failed + // ProviderServiceAccountsReconciliationFailedReason reports that provider service accounts related resources reconciliation failed. ProviderServiceAccountsReconciliationFailedReason = "ProviderServiceAccountsReconciliationFailed" ) const ( + // SupervisorLoadBalancerSvcNamespace is the namespace for the Supervisor load balancer service. SupervisorLoadBalancerSvcNamespace = "kube-system" - SupervisorLoadBalancerSvcName = "kube-apiserver-lb-svc" - SupervisorAPIServerPort = 6443 - + // SupervisorLoadBalancerSvcName is the name for the Supervisor load balancer service. + SupervisorLoadBalancerSvcName = "kube-apiserver-lb-svc" + // SupervisorAPIServerPort is the port for the Supervisor apiserver when using the load balancer service. + SupervisorAPIServerPort = 6443 + // SupervisorHeadlessSvcNamespace is the namespace for the Supervisor headless service. SupervisorHeadlessSvcNamespace = "default" - SupervisorHeadlessSvcName = "supervisor" - SupervisorHeadlessSvcPort = 6443 + // SupervisorHeadlessSvcName is the name for the Supervisor headless service. + SupervisorHeadlessSvcName = "supervisor" + // SupervisorHeadlessSvcPort is the port for the Supervisor apiserver when using the headless service. + SupervisorHeadlessSvcPort = 6443 - // ServiceDiscoveryReadyCondition documents the status of service discoveries + // ServiceDiscoveryReadyCondition documents the status of service discoveries. ServiceDiscoveryReadyCondition clusterv1.ConditionType = "ServiceDiscoveryReady" - // SupervisorHeadlessServiceSetupFailedReason documents the headless service setup for svc api server failed + // SupervisorHeadlessServiceSetupFailedReason documents the headless service setup for svc api server failed. SupervisorHeadlessServiceSetupFailedReason = "SupervisorHeadlessServiceSetupFailed" ) diff --git a/apis/vmware/v1beta1/providerserviceaccount_types.go b/apis/vmware/v1beta1/providerserviceaccount_types.go index 4ef9498b97..7aaff8aa65 100644 --- a/apis/vmware/v1beta1/providerserviceaccount_types.go +++ b/apis/vmware/v1beta1/providerserviceaccount_types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -65,7 +64,7 @@ type ProviderServiceAccount struct { // +kubebuilder:object:root=true -// ProviderServiceAccountList contains a list of ProviderServiceAccount +// ProviderServiceAccountList contains a list of ProviderServiceAccount. type ProviderServiceAccountList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/apis/vmware/v1beta1/types.go b/apis/vmware/v1beta1/types.go index b5facb1c47..0936d111f9 100644 --- a/apis/vmware/v1beta1/types.go +++ b/apis/vmware/v1beta1/types.go @@ -14,10 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 -// VSphereMachineTemplateResource describes the data needed to create a VSphereMachine from a template +// VSphereMachineTemplateResource describes the data needed to create a VSphereMachine from a template. type VSphereMachineTemplateResource struct { // Spec is the specification of the desired behavior of the machine. Spec VSphereMachineSpec `json:"spec"` diff --git a/apis/vmware/v1beta1/vspherecluster_types.go b/apis/vmware/v1beta1/vspherecluster_types.go index 2ff81a64b4..6fe2f30724 100644 --- a/apis/vmware/v1beta1/vspherecluster_types.go +++ b/apis/vmware/v1beta1/vspherecluster_types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -29,12 +28,12 @@ const ( ClusterFinalizer = "vspherecluster.vmware.infrastructure.cluster.x-k8s.io" ) -// VSphereClusterSpec defines the desired state of VSphereCluster +// VSphereClusterSpec defines the desired state of VSphereCluster. type VSphereClusterSpec struct { ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` } -// VSphereClusterStatus defines the observed state of VSphereClusterSpec +// VSphereClusterStatus defines the observed state of VSphereClusterSpec. type VSphereClusterStatus struct { // Ready indicates the infrastructure required to deploy this cluster is // ready. @@ -60,7 +59,7 @@ type VSphereClusterStatus struct { // +kubebuilder:storageversion // +kubebuilder:subresource:status -// VSphereCluster is the Schema for the VSphereClusters API +// VSphereCluster is the Schema for the VSphereClusters API. type VSphereCluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -71,17 +70,19 @@ type VSphereCluster struct { // +kubebuilder:object:root=true -// VSphereClusterList contains a list of VSphereCluster +// VSphereClusterList contains a list of VSphereCluster. type VSphereClusterList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []VSphereCluster `json:"items"` } +// GetConditions returns conditions for VSphereCluster. func (r *VSphereCluster) GetConditions() clusterv1.Conditions { return r.Status.Conditions } +// SetConditions sets conditions on the VSphereCluster. func (r *VSphereCluster) SetConditions(conditions clusterv1.Conditions) { r.Status.Conditions = conditions } diff --git a/apis/vmware/v1beta1/vsphereclustertemplate_types.go b/apis/vmware/v1beta1/vsphereclustertemplate_types.go index 8de94309f1..8504e0b3d4 100644 --- a/apis/vmware/v1beta1/vsphereclustertemplate_types.go +++ b/apis/vmware/v1beta1/vsphereclustertemplate_types.go @@ -14,14 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// VSphereClusterTemplateSpec defines the desired state of VSphereClusterTemplate +// VSphereClusterTemplateSpec defines the desired state of VSphereClusterTemplate. type VSphereClusterTemplateSpec struct { Template VSphereClusterTemplateResource `json:"template"` } @@ -30,7 +29,7 @@ type VSphereClusterTemplateSpec struct { // +kubebuilder:resource:path=vsphereclustertemplates,scope=Namespaced,categories=cluster-api // +kubebuilder:storageversion -// VSphereClusterTemplate is the Schema for the vsphereclustertemplates API +// VSphereClusterTemplate is the Schema for the vsphereclustertemplates API. type VSphereClusterTemplate struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -40,7 +39,7 @@ type VSphereClusterTemplate struct { //+kubebuilder:object:root=true -// VSphereClusterTemplateList contains a list of VSphereClusterTemplate +// VSphereClusterTemplateList contains a list of VSphereClusterTemplate. type VSphereClusterTemplateList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` @@ -51,6 +50,7 @@ func init() { objectTypes = append(objectTypes, &VSphereClusterTemplate{}, &VSphereClusterTemplateList{}) } +// VSphereClusterTemplateResource defines the template structure. type VSphereClusterTemplateResource struct { Spec VSphereClusterSpec `json:"spec"` } diff --git a/apis/vmware/v1beta1/vspheremachine_types.go b/apis/vmware/v1beta1/vspheremachine_types.go index dad04976a1..3252a5cbf3 100644 --- a/apis/vmware/v1beta1/vspheremachine_types.go +++ b/apis/vmware/v1beta1/vspheremachine_types.go @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot package v1beta1 import ( @@ -24,7 +23,7 @@ import ( "sigs.k8s.io/cluster-api/errors" ) -// VSphereMachineVolume defines a PVC attachment +// VSphereMachineVolume defines a PVC attachment. type VSphereMachineVolume struct { // Name is suffix used to name this PVC as: VSphereMachine.Name + "-" + Name Name string `json:"name"` @@ -35,7 +34,7 @@ type VSphereMachineVolume struct { StorageClass string `json:"storageClass,omitempty"` } -// VSphereMachineSpec defines the desired state of VSphereMachine +// VSphereMachineSpec defines the desired state of VSphereMachine. type VSphereMachineSpec struct { // ProviderID is the virtual machine's BIOS UUID formated as // vsphere://12345678-1234-1234-1234-123456789abc. @@ -82,7 +81,7 @@ type VSphereMachineSpec struct { PowerOffMode VirtualMachinePowerOpMode `json:"powerOffMode,omitempty"` } -// VSphereMachineStatus defines the observed state of VSphereMachine +// VSphereMachineStatus defines the observed state of VSphereMachine. type VSphereMachineStatus struct { // Ready is true when the provider resource is ready. // This is required at runtime by CAPI. Do not remove this field. @@ -166,17 +165,19 @@ type VSphereMachine struct { // +kubebuilder:object:root=true -// VSphereMachineList contains a list of VSphereMachine +// VSphereMachineList contains a list of VSphereMachine. type VSphereMachineList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` Items []VSphereMachine `json:"items"` } +// GetConditions returns the conditions for the VSphereMachine. func (r *VSphereMachine) GetConditions() clusterv1.Conditions { return r.Status.Conditions } +// SetConditions sets conditions on the VSphereMachine. func (r *VSphereMachine) SetConditions(conditions clusterv1.Conditions) { r.Status.Conditions = conditions } diff --git a/apis/vmware/v1beta1/vspheremachinetemplate_types.go b/apis/vmware/v1beta1/vspheremachinetemplate_types.go index 0f47adafc9..6f36e10587 100644 --- a/apis/vmware/v1beta1/vspheremachinetemplate_types.go +++ b/apis/vmware/v1beta1/vspheremachinetemplate_types.go @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -//nolint:godot +// Package v1beta1 contains API types. package v1beta1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// VSphereMachineTemplateSpec defines the desired state of VSphereMachineTemplate +// VSphereMachineTemplateSpec defines the desired state of VSphereMachineTemplate. type VSphereMachineTemplateSpec struct { Template VSphereMachineTemplateResource `json:"template"` } @@ -30,7 +30,7 @@ type VSphereMachineTemplateSpec struct { // +kubebuilder:resource:path=vspheremachinetemplates,scope=Namespaced,categories=cluster-api // +kubebuilder:storageversion -// VSphereMachineTemplate is the Schema for the vspheremachinetemplates API +// VSphereMachineTemplate is the Schema for the vspheremachinetemplates API. type VSphereMachineTemplate struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` @@ -40,7 +40,7 @@ type VSphereMachineTemplate struct { // +kubebuilder:object:root=true -// VSphereMachineTemplateList contains a list of VSphereMachineTemplate +// VSphereMachineTemplateList contains a list of VSphereMachineTemplate. type VSphereMachineTemplateList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusteridentities.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusteridentities.yaml index cbbcfbcadb..0402098b78 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusteridentities.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusteridentities.yaml @@ -286,7 +286,7 @@ spec: schema: openAPIV3Schema: description: VSphereClusterIdentity defines the account to be used for reconciling - clusters + clusters. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -301,6 +301,8 @@ spec: metadata: type: object spec: + description: VSphereClusterIdentitySpec contains a secret reference and + a group of allowed namespaces. properties: allowedNamespaces: description: AllowedNamespaces is used to identify which namespaces @@ -361,6 +363,7 @@ spec: type: string type: object status: + description: VSphereClusterIdentityStatus contains the status of the VSphereClusterIdentity. properties: conditions: description: Conditions defines current service state of the VSphereCluster. diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml index 0ee84903f3..d7902076dc 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclusters.yaml @@ -587,7 +587,7 @@ spec: name: v1beta1 schema: openAPIV3Schema: - description: VSphereCluster is the Schema for the vsphereclusters API + description: VSphereCluster is the Schema for the vsphereclusters API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -602,7 +602,7 @@ spec: metadata: type: object spec: - description: VSphereClusterSpec defines the desired state of VSphereCluster + description: VSphereClusterSpec defines the desired state of VSphereCluster. properties: clusterModules: description: ClusterModules hosts information regarding the anti-affinity @@ -726,7 +726,7 @@ spec: type: string type: object status: - description: VSphereClusterStatus defines the observed state of VSphereClusterSpec + description: VSphereClusterStatus defines the observed state of VSphereClusterSpec. properties: conditions: description: Conditions defines current service state of the VSphereCluster. diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml index 46147bd4c4..d5dd50e300 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml @@ -99,7 +99,7 @@ spec: schema: openAPIV3Schema: description: VSphereClusterTemplate is the Schema for the vsphereclustertemplates - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -114,12 +114,14 @@ spec: metadata: type: object spec: - description: VSphereClusterTemplateSpec defines the desired state of VSphereClusterTemplate + description: VSphereClusterTemplateSpec defines the desired state of VSphereClusterTemplate. properties: template: + description: VSphereClusterTemplateResource describes the data for + creating a VSphereCluster from a template. properties: spec: - description: VSphereClusterSpec defines the desired state of VSphereCluster + description: VSphereClusterSpec defines the desired state of VSphereCluster. properties: clusterModules: description: ClusterModules hosts information regarding the diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheredeploymentzones.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheredeploymentzones.yaml index 622154e751..acb644b490 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheredeploymentzones.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheredeploymentzones.yaml @@ -230,7 +230,7 @@ spec: schema: openAPIV3Schema: description: VSphereDeploymentZone is the Schema for the vspheredeploymentzones - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -245,7 +245,7 @@ spec: metadata: type: object spec: - description: VSphereDeploymentZoneSpec defines the desired state of VSphereDeploymentZone + description: VSphereDeploymentZoneSpec defines the desired state of VSphereDeploymentZone. properties: controlPlane: description: ControlPlane determines if this failure domain is suitable @@ -275,6 +275,7 @@ spec: - placementConstraint type: object status: + description: VSphereDeploymentZoneStatus contains the status for a VSphereDeploymentZone. properties: conditions: description: Conditions defines current service state of the VSphereMachine. diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherefailuredomains.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherefailuredomains.yaml index 4a2b2c5394..8fe3cd64eb 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherefailuredomains.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherefailuredomains.yaml @@ -264,7 +264,7 @@ spec: schema: openAPIV3Schema: description: VSphereFailureDomain is the Schema for the vspherefailuredomains - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -279,7 +279,7 @@ spec: metadata: type: object spec: - description: VSphereFailureDomainSpec defines the desired state of VSphereFailureDomain + description: VSphereFailureDomainSpec defines the desired state of VSphereFailureDomain. properties: region: description: Region defines the name and type of a region diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml index 436b9b8cae..f9d2bdfa43 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachines.yaml @@ -837,7 +837,7 @@ spec: name: v1beta1 schema: openAPIV3Schema: - description: VSphereMachine is the Schema for the vspheremachines API + description: VSphereMachine is the Schema for the vspheremachines API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -852,7 +852,7 @@ spec: metadata: type: object spec: - description: VSphereMachineSpec defines the desired state of VSphereMachine + description: VSphereMachineSpec defines the desired state of VSphereMachine. properties: additionalDisksGiB: description: AdditionalDisksGiB holds the sizes of additional disks @@ -1203,7 +1203,7 @@ spec: description: PciDevices is the list of pci devices used by the virtual machine. items: - description: PCIDeviceSpec defines virtual machine's PCI configuration + description: PCIDeviceSpec defines virtual machine's PCI configuration. properties: deviceId: description: DeviceID is the device ID of a virtual machine's @@ -1279,7 +1279,7 @@ spec: - template type: object status: - description: VSphereMachineStatus defines the observed state of VSphereMachine + description: VSphereMachineStatus defines the observed state of VSphereMachine. properties: addresses: description: Addresses contains the VSphere instance associated addresses. diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml index e41b655d4e..7f0624fc22 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml @@ -691,7 +691,7 @@ spec: schema: openAPIV3Schema: description: VSphereMachineTemplate is the Schema for the vspheremachinetemplates - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -706,11 +706,11 @@ spec: metadata: type: object spec: - description: VSphereMachineTemplateSpec defines the desired state of VSphereMachineTemplate + description: VSphereMachineTemplateSpec defines the desired state of VSphereMachineTemplate. properties: template: description: VSphereMachineTemplateResource describes the data needed - to create a VSphereMachine from a template + to create a VSphereMachine from a template. properties: metadata: description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' @@ -1112,7 +1112,7 @@ spec: the virtual machine. items: description: PCIDeviceSpec defines virtual machine's PCI - configuration + configuration. properties: deviceId: description: DeviceID is the device ID of a virtual diff --git a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherevms.yaml b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherevms.yaml index 20e8c50c38..bd51b5a9da 100644 --- a/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherevms.yaml +++ b/config/default/crd/bases/infrastructure.cluster.x-k8s.io_vspherevms.yaml @@ -845,7 +845,7 @@ spec: - name: v1beta1 schema: openAPIV3Schema: - description: VSphereVM is the Schema for the vspherevms API + description: VSphereVM is the Schema for the vspherevms API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -1249,7 +1249,7 @@ spec: description: PciDevices is the list of pci devices used by the virtual machine. items: - description: PCIDeviceSpec defines virtual machine's PCI configuration + description: PCIDeviceSpec defines virtual machine's PCI configuration. properties: deviceId: description: DeviceID is the device ID of a virtual machine's @@ -1321,7 +1321,7 @@ spec: - template type: object status: - description: VSphereVMStatus defines the observed state of VSphereVM + description: VSphereVMStatus defines the observed state of VSphereVM. properties: addresses: description: Addresses is a list of the VM's IP addresses. This field diff --git a/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vsphereclusters.yaml b/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vsphereclusters.yaml index 4955db928a..d8b57c07f8 100644 --- a/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vsphereclusters.yaml +++ b/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vsphereclusters.yaml @@ -19,7 +19,7 @@ spec: - name: v1beta1 schema: openAPIV3Schema: - description: VSphereCluster is the Schema for the VSphereClusters API + description: VSphereCluster is the Schema for the VSphereClusters API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -34,7 +34,7 @@ spec: metadata: type: object spec: - description: VSphereClusterSpec defines the desired state of VSphereCluster + description: VSphereClusterSpec defines the desired state of VSphereCluster. properties: controlPlaneEndpoint: description: APIEndpoint represents a reachable Kubernetes API endpoint. @@ -54,7 +54,7 @@ spec: - controlPlaneEndpoint type: object status: - description: VSphereClusterStatus defines the observed state of VSphereClusterSpec + description: VSphereClusterStatus defines the observed state of VSphereClusterSpec. properties: conditions: description: Conditions defines current service state of the VSphereCluster. diff --git a/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml b/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml index 388c122d7c..0ed3101f0c 100644 --- a/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml +++ b/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vsphereclustertemplates.yaml @@ -20,7 +20,7 @@ spec: schema: openAPIV3Schema: description: VSphereClusterTemplate is the Schema for the vsphereclustertemplates - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -35,12 +35,13 @@ spec: metadata: type: object spec: - description: VSphereClusterTemplateSpec defines the desired state of VSphereClusterTemplate + description: VSphereClusterTemplateSpec defines the desired state of VSphereClusterTemplate. properties: template: + description: VSphereClusterTemplateResource defines the template structure. properties: spec: - description: VSphereClusterSpec defines the desired state of VSphereCluster + description: VSphereClusterSpec defines the desired state of VSphereCluster. properties: controlPlaneEndpoint: description: APIEndpoint represents a reachable Kubernetes diff --git a/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vspheremachines.yaml b/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vspheremachines.yaml index b0ca3639a6..acc2e5c611 100644 --- a/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vspheremachines.yaml +++ b/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vspheremachines.yaml @@ -47,7 +47,7 @@ spec: metadata: type: object spec: - description: VSphereMachineSpec defines the desired state of VSphereMachine + description: VSphereMachineSpec defines the desired state of VSphereMachine. properties: className: description: ClassName is the name of the class used when specifying @@ -91,7 +91,7 @@ spec: description: Volumes is the set of PVCs to be created and attached to the VSphereMachine items: - description: VSphereMachineVolume defines a PVC attachment + description: VSphereMachineVolume defines a PVC attachment. properties: capacity: additionalProperties: @@ -119,7 +119,7 @@ spec: - imageName type: object status: - description: VSphereMachineStatus defines the observed state of VSphereMachine + description: VSphereMachineStatus defines the observed state of VSphereMachine. properties: addresses: description: Addresses contains the instance associated addresses. diff --git a/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml b/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml index 6d25df659a..746107b352 100644 --- a/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml +++ b/config/supervisor/crd/vmware.infrastructure.cluster.x-k8s.io_vspheremachinetemplates.yaml @@ -20,7 +20,7 @@ spec: schema: openAPIV3Schema: description: VSphereMachineTemplate is the Schema for the vspheremachinetemplates - API + API. properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -35,11 +35,11 @@ spec: metadata: type: object spec: - description: VSphereMachineTemplateSpec defines the desired state of VSphereMachineTemplate + description: VSphereMachineTemplateSpec defines the desired state of VSphereMachineTemplate. properties: template: description: VSphereMachineTemplateResource describes the data needed - to create a VSphereMachine from a template + to create a VSphereMachine from a template. properties: spec: description: Spec is the specification of the desired behavior @@ -89,7 +89,7 @@ spec: description: Volumes is the set of PVCs to be created and attached to the VSphereMachine items: - description: VSphereMachineVolume defines a PVC attachment + description: VSphereMachineVolume defines a PVC attachment. properties: capacity: additionalProperties: diff --git a/controllers/clustermodule_reconciler.go b/controllers/clustermodule_reconciler.go index 8978586c44..e1f8d49773 100644 --- a/controllers/clustermodule_reconciler.go +++ b/controllers/clustermodule_reconciler.go @@ -48,12 +48,14 @@ import ( // +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=vsphereclusters,verbs=get;list;watch;patch // +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=vspheremachinetemplates,verbs=get;list;watch +// Reconciler reconciles changes for ClusterModules. type Reconciler struct { Client client.Client ClusterModuleService clustermodule.Service } +// NewReconciler creates a Cluster Module Reconciler with a Client and ClusterModuleService. func NewReconciler(controllerManagerCtx *capvcontext.ControllerManagerContext) Reconciler { return Reconciler{ Client: controllerManagerCtx.Client, @@ -206,6 +208,7 @@ func (r Reconciler) toAffinityInput(ctx context.Context, obj client.Object) []re } } +// PopulateWatchesOnController adds watches to the ClusterModule reconciler. func (r Reconciler) PopulateWatchesOnController(mgr manager.Manager, controller controller.Controller) error { if err := controller.Watch( source.Kind(mgr.GetCache(), &controlplanev1.KubeadmControlPlane{}), diff --git a/controllers/serviceaccount_controller.go b/controllers/serviceaccount_controller.go index 144cf7a44a..590d9fdcfd 100644 --- a/controllers/serviceaccount_controller.go +++ b/controllers/serviceaccount_controller.go @@ -131,6 +131,7 @@ func clusterToSupervisorInfrastructureMapFunc(ctx context.Context, c client.Clie return clusterutilv1.ClusterToInfrastructureMapFunc(ctx, gvk, c, &vmwarev1.VSphereCluster{}) } +// ServiceAccountReconciler reconciles changes to ProviderServiceAccounts. type ServiceAccountReconciler struct { Client client.Client Recorder record.Recorder @@ -222,6 +223,7 @@ func (r *ServiceAccountReconciler) Reconcile(ctx context.Context, req reconcile. }) } +// ReconcileDelete handles delete events for ProviderServiceAccounts. func (r *ServiceAccountReconciler) ReconcileDelete(ctx context.Context, clusterCtx *vmwarecontext.ClusterContext) (reconcile.Result, error) { log := ctrl.LoggerFrom(ctx) log.V(4).Info("Reconciling deleting Provider ServiceAccounts") @@ -242,6 +244,7 @@ func (r *ServiceAccountReconciler) ReconcileDelete(ctx context.Context, clusterC return reconcile.Result{}, nil } +// ReconcileNormal handles create and update events for ProviderServiceAccounts. func (r *ServiceAccountReconciler) ReconcileNormal(ctx context.Context, guestClusterCtx *vmwarecontext.GuestClusterContext) (_ reconcile.Result, reterr error) { log := ctrl.LoggerFrom(ctx) log.V(4).Info("Reconciling ProviderServiceAccount") diff --git a/controllers/servicediscovery_controller.go b/controllers/servicediscovery_controller.go index 4091cd6434..9dee3ef9c4 100644 --- a/controllers/servicediscovery_controller.go +++ b/controllers/servicediscovery_controller.go @@ -56,7 +56,8 @@ import ( ) const ( - clusterNotReadyRequeueTime = time.Minute * 2 + clusterNotReadyRequeueTime = time.Minute * 2 + // ServiceDiscoveryControllerName is the name of the service discovery controller. ServiceDiscoveryControllerName = "servicediscovery-controller" supervisorLoadBalancerSvcNamespace = "kube-system" @@ -330,6 +331,7 @@ func (r *serviceDiscoveryReconciler) getSupervisorAPIServerAddress(ctx context.C return supervisorHost, nil } +// NewSupervisorHeadlessService returns a new Supervisor headless service. func NewSupervisorHeadlessService(port, targetPort int) *corev1.Service { return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ @@ -349,6 +351,7 @@ func NewSupervisorHeadlessService(port, targetPort int) *corev1.Service { } } +// NewSupervisorHeadlessServiceEndpoints returns Kubernetes Endpoints for the supervisor apiserver address. func NewSupervisorHeadlessServiceEndpoints(targetHost string, targetPort int) *corev1.Endpoints { var endpointAddr corev1.EndpointAddress if ip := net.ParseIP(targetHost); ip != nil { @@ -376,6 +379,7 @@ func NewSupervisorHeadlessServiceEndpoints(targetHost string, targetPort int) *c } } +// GetSupervisorAPIServerVIP finds the load balancer IP of the Supervisor APIServer. func GetSupervisorAPIServerVIP(client client.Client) (string, error) { svc := &corev1.Service{} svcKey := types.NamespacedName{Name: vmwarev1.SupervisorLoadBalancerSvcName, Namespace: vmwarev1.SupervisorLoadBalancerSvcNamespace} @@ -392,6 +396,7 @@ func GetSupervisorAPIServerVIP(client client.Client) (string, error) { return "", errors.Errorf("no VIP found in the supervisor loadbalancer svc %s", svcKey) } +// GetSupervisorAPIServerFIP finds the floating ip of the Supervisor APIServer. func GetSupervisorAPIServerFIP(client client.Client) (string, error) { urlString, err := getSupervisorAPIServerURLWithFIP(client) if err != nil { diff --git a/controllers/vmware/vspherecluster_reconciler.go b/controllers/vmware/vspherecluster_reconciler.go index 29e7f36fd1..542ca4ebe4 100644 --- a/controllers/vmware/vspherecluster_reconciler.go +++ b/controllers/vmware/vspherecluster_reconciler.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package vmware contains the VSphereCluster reconciler. package vmware import ( @@ -48,6 +49,7 @@ const ( apiEndpointPort = 6443 ) +// ClusterReconciler reconciles VSphereClusters. type ClusterReconciler struct { Client client.Client Recorder record.Recorder @@ -344,6 +346,7 @@ func (r *ClusterReconciler) reconcileAPIEndpoints(ctx context.Context, clusterCt return nil } +// VSphereMachineToCluster adds reconcile requests for a Cluster when one of its control plane machines has an event. func (r *ClusterReconciler) VSphereMachineToCluster(ctx context.Context, o client.Object) []reconcile.Request { log := ctrl.LoggerFrom(ctx) diff --git a/controllers/vspherecluster_reconciler.go b/controllers/vspherecluster_reconciler.go index 34329ef614..9c57531bdc 100644 --- a/controllers/vspherecluster_reconciler.go +++ b/controllers/vspherecluster_reconciler.go @@ -15,6 +15,8 @@ limitations under the License. */ //nolint:nestif + +// Package controllers contains controllers for CAPV objects. package controllers import ( @@ -460,7 +462,8 @@ func (r *clusterReconciler) reconcileVSphereClusterWhenAPIServerIsOnline(ctx con // Block until the target API server is online. log.Info("Start polling API server for online check") - wait.PollUntilContextCancel(ctx, time.Second*1, true, func(context.Context) (bool, error) { return r.isAPIServerOnline(ctx, clusterCtx), nil }) //nolint:errcheck + // Ignore the error as the passed function never returns one. + _ = wait.PollUntilContextCancel(ctx, time.Second*1, true, func(context.Context) (bool, error) { return r.isAPIServerOnline(ctx, clusterCtx), nil }) log.Info("Stop polling API server for online check") log.Info("Triggering GenericEvent", "reason", "api-server-online") eventChannel := r.ControllerManagerContext.GetGenericEventChannelFor(clusterCtx.VSphereCluster.GetObjectKind().GroupVersionKind()) @@ -472,7 +475,8 @@ func (r *clusterReconciler) reconcileVSphereClusterWhenAPIServerIsOnline(ctx con // remove the key from the map that prevents multiple goroutines from // polling the API server to see if it is online. log.Info("Start polling for control plane initialized") - wait.PollUntilContextCancel(ctx, time.Second*1, true, func(context.Context) (bool, error) { return r.isControlPlaneInitialized(ctx, clusterCtx), nil }) //nolint:errcheck + // Ignore the error as the passed function never returns one. + _ = wait.PollUntilContextCancel(ctx, time.Second*1, true, func(context.Context) (bool, error) { return r.isControlPlaneInitialized(ctx, clusterCtx), nil }) log.Info("Stop polling for control plane initialized") apiServerTriggersMu.Lock() delete(apiServerTriggers, clusterCtx.Cluster.UID) diff --git a/controllers/vsphereclusteridentity_controller.go b/controllers/vsphereclusteridentity_controller.go index 573b4e5d8d..82379bb6d0 100644 --- a/controllers/vsphereclusteridentity_controller.go +++ b/controllers/vsphereclusteridentity_controller.go @@ -54,6 +54,7 @@ var ( // +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=vsphereclusteridentities/status,verbs=get;update;patch // +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;patch;update;delete +// AddVsphereClusterIdentityControllerToManager adds a VSphereClusterIdentity controller to the controller manager. func AddVsphereClusterIdentityControllerToManager(ctx context.Context, controllerManagerCtx *capvcontext.ControllerManagerContext, mgr manager.Manager, options controller.Options) error { var ( controllerNameShort = fmt.Sprintf("%s-controller", strings.ToLower(identityControlledTypeName)) diff --git a/controllers/vspheremachine_controller.go b/controllers/vspheremachine_controller.go index c58330b0ed..26ffb1394c 100644 --- a/controllers/vspheremachine_controller.go +++ b/controllers/vspheremachine_controller.go @@ -78,7 +78,6 @@ const hostInfoErrStr = "host info cannot be used as a label value" // AddMachineControllerToManager adds the machine controller to the provided // manager. - func AddMachineControllerToManager(ctx context.Context, controllerManagerContext *capvcontext.ControllerManagerContext, mgr manager.Manager, controlledType client.Object, options controller.Options) error { supervisorBased, err := util.IsSupervisorType(controlledType) if err != nil { diff --git a/feature/feature.go b/feature/feature.go index 00a03f9074..981694a306 100644 --- a/feature/feature.go +++ b/feature/feature.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package feature handles feature gates. package feature import ( diff --git a/main.go b/main.go index d581f9daa8..dc9b5999d6 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package main is the main package for CAPV. package main import ( diff --git a/packaging/flavorgen/cloudprovider/csi.go b/packaging/flavorgen/cloudprovider/csi.go index 0d317f6188..d9c8167949 100644 --- a/packaging/flavorgen/cloudprovider/csi.go +++ b/packaging/flavorgen/cloudprovider/csi.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package cloudprovider contains tools to generate CSI and CPI manifests. package cloudprovider import ( diff --git a/packaging/flavorgen/cmd/root.go b/packaging/flavorgen/cmd/root.go index 01f9c8b849..c1b244d408 100644 --- a/packaging/flavorgen/cmd/root.go +++ b/packaging/flavorgen/cmd/root.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package cmd executes flavorgen commands. package cmd import ( diff --git a/packaging/flavorgen/flavors/crs/cpi.go b/packaging/flavorgen/flavors/crs/cpi.go index 2932487bb2..6f6fb41fec 100644 --- a/packaging/flavorgen/flavors/crs/cpi.go +++ b/packaging/flavorgen/flavors/crs/cpi.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package crs contains tools to create a ClusterResourceSet for the CPI. package crs import ( diff --git a/packaging/flavorgen/flavors/crs/types/cloudprovider_types.go b/packaging/flavorgen/flavors/crs/types/cloudprovider_types.go index e541ad27c1..6bd5f66afa 100644 --- a/packaging/flavorgen/flavors/crs/types/cloudprovider_types.go +++ b/packaging/flavorgen/flavors/crs/types/cloudprovider_types.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// cloudprovider_types contains API types for the vSphere cloud provider. +// Package types contains API types for the vSphere cloud provider. // The configuration may be unmarshalled from an INI-style configuration using // the "gopkg.in/gcfg.v1" package. // diff --git a/packaging/flavorgen/flavors/env/envsubts_consts.go b/packaging/flavorgen/flavors/env/envsubts_consts.go index 8e670200ac..70a1d734f4 100644 --- a/packaging/flavorgen/flavors/env/envsubts_consts.go +++ b/packaging/flavorgen/flavors/env/envsubts_consts.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package env contains variable names used with envsubst. package env const ( @@ -45,9 +46,10 @@ const ( VSphereTemplateVar = "${VSPHERE_TEMPLATE}" WorkerMachineCountVar = "${WORKER_MACHINE_COUNT}" ControlPlaneEndpointVar = "${CONTROL_PLANE_ENDPOINT_IP}" - // Set the default to an empty string to let kube-vip autodetect the interface. - VipNetworkInterfaceVar = "${VIP_NETWORK_INTERFACE:=\"\"}" - VSphereUsername = "${VSPHERE_USERNAME}" - VSpherePassword = "${VSPHERE_PASSWORD}" /* #nosec */ + // VipNetworkInterfaceVar defaults to an empty string to let kube-vip autodetect the interface. + VipNetworkInterfaceVar = "${VIP_NETWORK_INTERFACE:=\"\"}" + VSphereUsername = "${VSPHERE_USERNAME}" + // VSpherePassword is the password for the VSphere Server. + VSpherePassword = "${VSPHERE_PASSWORD}" //nolint:gosec // Password is not hardcoded here. ClusterResourceSetNameSuffix = "-crs-0" ) diff --git a/packaging/flavorgen/flavors/flavors.go b/packaging/flavorgen/flavors/flavors.go index dbed2c2777..6ee4faa3de 100644 --- a/packaging/flavorgen/flavors/flavors.go +++ b/packaging/flavorgen/flavors/flavors.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package flavors contains tools to generate CAPV templates. package flavors import ( @@ -27,6 +28,7 @@ import ( const ( // Supported workload cluster flavors. + VIP = "vip" ExternalLoadBalancer = "external-loadbalancer" Ignition = "ignition" diff --git a/packaging/flavorgen/flavors/util/helpers.go b/packaging/flavorgen/flavors/util/helpers.go index 3f3c71b45c..ba8243a312 100644 --- a/packaging/flavorgen/flavors/util/helpers.go +++ b/packaging/flavorgen/flavors/util/helpers.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package util contains common tools for flavorgen. package util import ( diff --git a/packaging/flavorgen/main.go b/packaging/flavorgen/main.go index 69c4179e39..e6def85730 100644 --- a/packaging/flavorgen/main.go +++ b/packaging/flavorgen/main.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package main is the main package for flavorgen. package main import ( diff --git a/pkg/clustermodule/error.go b/pkg/clustermodule/error.go index d4b39fb003..f2586436a3 100644 --- a/pkg/clustermodule/error.go +++ b/pkg/clustermodule/error.go @@ -40,6 +40,7 @@ func NewIncompatibleOwnerError(name string) IncompatibleOwnerError { return IncompatibleOwnerError{resource: name} } +// IsIncompatibleOwnerError checks if the passed error is an IncompatibleOwnerError. func IsIncompatibleOwnerError(err error) bool { return strings.HasSuffix(err.Error(), errString) } diff --git a/pkg/clustermodule/fake/service.go b/pkg/clustermodule/fake/service.go index 3a81b992ff..2bdc569dfe 100644 --- a/pkg/clustermodule/fake/service.go +++ b/pkg/clustermodule/fake/service.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package fake implements a fake ClusterModuleService for testing. package fake import ( diff --git a/pkg/clustermodule/interfaces.go b/pkg/clustermodule/interfaces.go index bf4d77650e..6ef70ce1cc 100644 --- a/pkg/clustermodule/interfaces.go +++ b/pkg/clustermodule/interfaces.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package clustermodule contains tools for handling ClusterModules. package clustermodule import ( @@ -22,6 +23,7 @@ import ( capvcontext "sigs.k8s.io/cluster-api-provider-vsphere/pkg/context" ) +// Service is a ClusterModule service. type Service interface { Create(ctx context.Context, clusterCtx *capvcontext.ClusterContext, wrapper Wrapper) (string, error) diff --git a/pkg/clustermodule/service.go b/pkg/clustermodule/service.go index f5091b7b35..af77c089a9 100644 --- a/pkg/clustermodule/service.go +++ b/pkg/clustermodule/service.go @@ -38,6 +38,7 @@ type service struct { Client client.Client } +// NewService returns a new Cluster Module service. func NewService(controllerManagerCtx *capvcontext.ControllerManagerContext, client client.Client) Service { return &service{ ControllerManagerContext: controllerManagerCtx, diff --git a/pkg/clustermodule/types.go b/pkg/clustermodule/types.go index b44a662431..b9095a0880 100644 --- a/pkg/clustermodule/types.go +++ b/pkg/clustermodule/types.go @@ -36,6 +36,7 @@ type Wrapper interface { IsControlPlane() bool } +// NewWrapper returns the correct wrapper for the passed in object. func NewWrapper(obj client.Object) Wrapper { if obj.GetObjectKind().GroupVersionKind().Kind == "KubeadmControlPlane" { kcp, _ := obj.(*controlplanev1.KubeadmControlPlane) diff --git a/pkg/clustermodule/util.go b/pkg/clustermodule/util.go index 3b947a4bab..a64b9632c5 100644 --- a/pkg/clustermodule/util.go +++ b/pkg/clustermodule/util.go @@ -49,6 +49,7 @@ func Compare(oldMods, newMods []infrav1.ClusterModule) bool { return true } +// IsClusterCompatible checks if the VCenterVersion is compatibly with CAPV. Only version 7 and over are supported. func IsClusterCompatible(ctx *context.ClusterContext) bool { version := ctx.VSphereCluster.Status.VCenterVersion if version == "" { diff --git a/pkg/config/config.go b/pkg/config/config.go deleted file mode 100644 index 2c281ecae9..0000000000 --- a/pkg/config/config.go +++ /dev/null @@ -1,25 +0,0 @@ -/* -Copyright 2019 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 config - -import ( - "time" -) - -// DefaultRequeue is the default time for how long to wait when -// requeueing a CAPI operation. -var DefaultRequeue = 20 * time.Second diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index b3135c61c8..412c96b4db 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package constants contains constants used in CAPV. package constants import ( @@ -54,10 +55,12 @@ const ( // DefaultEnableKeepAlive is true by default. DefaultEnableKeepAlive = true - // KeepaliveDuration unit minutes. + // DefaultKeepAliveDuration unit minutes. DefaultKeepAliveDuration = time.Minute * 5 + // NodeLabelPrefix is the prefix for node labels. NodeLabelPrefix = "node.cluster.x-k8s.io" + // ESXiHostInfoLabel is the label for esxi host info. ESXiHostInfoLabel = NodeLabelPrefix + "/esxi-host" ) diff --git a/pkg/context/fake/constants.go b/pkg/context/fake/constants.go index 653711e205..42c67ab9b4 100644 --- a/pkg/context/fake/constants.go +++ b/pkg/context/fake/constants.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package fake contains fake context objects for testing. package fake const ( diff --git a/pkg/context/interfaces.go b/pkg/context/interfaces.go index bea702b10c..efe002ef2c 100644 --- a/pkg/context/interfaces.go +++ b/pkg/context/interfaces.go @@ -24,6 +24,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) +// MachineContext is the context used in VSphereMachine reconciliation. type MachineContext interface { String() string Patch() error @@ -35,6 +36,7 @@ type MachineContext interface { SetBaseMachineContext(base *BaseMachineContext) } +// VSphereMachine is a common interface used for VSphereMachines across VMOperator and non-VMOperator modes. type VSphereMachine interface { client.Object conditions.Setter diff --git a/pkg/context/machine_context.go b/pkg/context/machine_context.go index 92cf34d9fb..370af6e92c 100644 --- a/pkg/context/machine_context.go +++ b/pkg/context/machine_context.go @@ -27,6 +27,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" ) +// BaseMachineContext contains information about a CAPI Machine for VSphereMachine reconciliation. type BaseMachineContext struct { *ControllerContext Logger logr.Logger @@ -35,10 +36,12 @@ type BaseMachineContext struct { PatchHelper *patch.Helper } +// GetCluster returns the cluster for the BaseMachineContext. func (c *BaseMachineContext) GetCluster() *clusterv1.Cluster { return c.Cluster } +// GetMachine returns the Machine for the BaseMachineContext. func (c *BaseMachineContext) GetMachine() *clusterv1.Machine { return c.Machine } @@ -65,14 +68,17 @@ func (c *VIMMachineContext) Patch() error { return c.PatchHelper.Patch(c, c.VSphereMachine) } +// GetVSphereMachine sets the VSphereMachine for the VIMMachineContext. func (c *VIMMachineContext) GetVSphereMachine() VSphereMachine { return c.VSphereMachine } +// GetObjectMeta returns the ObjectMeta for the VSphereMachine in the VIMMachineContext. func (c *VIMMachineContext) GetObjectMeta() metav1.ObjectMeta { return c.VSphereMachine.ObjectMeta } +// SetBaseMachineContext sets the BaseMachineContext for the VIMMachineContext. func (c *VIMMachineContext) SetBaseMachineContext(base *BaseMachineContext) { c.BaseMachineContext = base } diff --git a/pkg/context/vm_context.go b/pkg/context/vm_context.go index 4ffbfc4851..6cf34856a8 100644 --- a/pkg/context/vm_context.go +++ b/pkg/context/vm_context.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package context defines context objects for controllers. package context import ( diff --git a/pkg/context/vmware/cluster_context.go b/pkg/context/vmware/cluster_context.go index 1d23e5293d..9fed67d04f 100644 --- a/pkg/context/vmware/cluster_context.go +++ b/pkg/context/vmware/cluster_context.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package vmware contains fake contexts used for testing. package vmware import ( diff --git a/pkg/context/vmware/machine_context.go b/pkg/context/vmware/machine_context.go index 648e406c37..694ad07dc5 100644 --- a/pkg/context/vmware/machine_context.go +++ b/pkg/context/vmware/machine_context.go @@ -48,14 +48,17 @@ func (c *SupervisorMachineContext) Patch() error { return c.PatchHelper.Patch(c, c.VSphereMachine) } +// GetVSphereMachine returns the VSphereMachine from the SupervisorMachineContext. func (c *SupervisorMachineContext) GetVSphereMachine() context.VSphereMachine { return c.VSphereMachine } +// GetObjectMeta returns the metadata for the VSphereMachine from the SupervisorMachineContext. func (c *SupervisorMachineContext) GetObjectMeta() metav1.ObjectMeta { return c.VSphereMachine.ObjectMeta } +// GetClusterContext returns the Cluster and VSphereCluster from the SupervisorMachineContext. func (c *SupervisorMachineContext) GetClusterContext() *ClusterContext { return &ClusterContext{ Cluster: c.Cluster, @@ -63,6 +66,7 @@ func (c *SupervisorMachineContext) GetClusterContext() *ClusterContext { } } +// SetBaseMachineContext sets the BaseMachineContext for the SupervisorMachineContext. func (c *SupervisorMachineContext) SetBaseMachineContext(base *context.BaseMachineContext) { c.BaseMachineContext = base } diff --git a/pkg/context/vspheredeploymentzone_context.go b/pkg/context/vspheredeploymentzone_context.go index c93ffe6e5a..c1a62e51d3 100644 --- a/pkg/context/vspheredeploymentzone_context.go +++ b/pkg/context/vspheredeploymentzone_context.go @@ -27,6 +27,7 @@ import ( "sigs.k8s.io/cluster-api-provider-vsphere/pkg/session" ) +// VSphereDeploymentZoneContext contains information for the VSphereDeploymentZone reconciliation. type VSphereDeploymentZoneContext struct { *ControllerContext VSphereDeploymentZone *infrav1.VSphereDeploymentZone @@ -36,6 +37,7 @@ type VSphereDeploymentZoneContext struct { AuthSession *session.Session } +// Patch patches the VSphereDeploymentZone. func (c *VSphereDeploymentZoneContext) Patch() error { conditions.SetSummary(c.VSphereDeploymentZone, conditions.WithConditions( @@ -47,14 +49,17 @@ func (c *VSphereDeploymentZoneContext) Patch() error { return c.PatchHelper.Patch(c, c.VSphereDeploymentZone) } +// String returns a string with the GroupVersionKind and name of the VSphereDeploymentZone. func (c *VSphereDeploymentZoneContext) String() string { return fmt.Sprintf("%s %s", c.VSphereDeploymentZone.GroupVersionKind(), c.VSphereDeploymentZone.Name) } +// GetSession returns the session for the VSphereDeploymentZoneContext. func (c *VSphereDeploymentZoneContext) GetSession() *session.Session { return c.AuthSession } +// GetVsphereFailureDomain returns the VSphereFailureDomain for the VSphereDeploymentZoneContext. func (c *VSphereDeploymentZoneContext) GetVsphereFailureDomain() infrav1.VSphereFailureDomain { return *c.VSphereFailureDomain } diff --git a/pkg/identity/identity.go b/pkg/identity/identity.go index b4a09d04d7..712151f8c2 100644 --- a/pkg/identity/identity.go +++ b/pkg/identity/identity.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package identity contains tools for managing secrets used to access the VCenter API. package identity import ( @@ -31,15 +32,19 @@ import ( ) const ( + // UsernameKey is the key used for the username. UsernameKey = "username" + // PasswordKey is the key used for the password. PasswordKey = "password" ) +// Credentials are the user credentials used with the VSphere API. type Credentials struct { Username string Password string } +// GetCredentials returns the VCenter credentials for the VSphereCluster. func GetCredentials(ctx context.Context, c client.Client, cluster *infrav1.VSphereCluster, controllerNamespace string) (*Credentials, error) { if err := validateInputs(c, cluster); err != nil { return nil, err @@ -130,6 +135,7 @@ func IsSecretIdentity(cluster *infrav1.VSphereCluster) bool { return cluster.Spec.IdentityRef.Kind == infrav1.SecretKind } +// IsOwnedByIdentityOrCluster discovers if a secret is owned by a VSphereCluster or VSphereClusterIdentity. func IsOwnedByIdentityOrCluster(ownerReferences []metav1.OwnerReference) bool { if len(ownerReferences) > 0 { for _, ownerReference := range ownerReferences { diff --git a/pkg/manager/constants.go b/pkg/manager/constants.go index 58456d387a..69d5c55b97 100644 --- a/pkg/manager/constants.go +++ b/pkg/manager/constants.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package manager contains tools to create the CAPV controller manager. package manager import "time" @@ -32,6 +33,7 @@ const ( // DefaultPodName is the default value for the eponymous manager option. DefaultPodName = defaultPrefix + "controller-manager" + // DefaultPodNamespace is the default value for the manager namespace. DefaultPodNamespace = defaultPrefix + "system" // DefaultLeaderElectionID is the default value for the eponymous manager option. diff --git a/pkg/manager/manager.go b/pkg/manager/manager.go index 0a674a4185..cf5ea1f695 100644 --- a/pkg/manager/manager.go +++ b/pkg/manager/manager.go @@ -120,6 +120,7 @@ func (m *manager) GetContext() *capvcontext.ControllerManagerContext { return m.controllerCtx } +// UpdateCredentials reads and updates credentials from the credentials file. func UpdateCredentials(opts *Options) { opts.readAndSetCredentials() } diff --git a/pkg/manager/network.go b/pkg/manager/network.go index 9e1dd4edaf..b7f826889b 100644 --- a/pkg/manager/network.go +++ b/pkg/manager/network.go @@ -27,8 +27,11 @@ import ( ) const ( - NSXNetworkProvider = "NSX" - VDSNetworkProvider = "vsphere-network" + // NSXNetworkProvider identifies the NSX network provider. + NSXNetworkProvider = "NSX" + // VDSNetworkProvider identifies the VDS network provider. + VDSNetworkProvider = "vsphere-network" + // DummyLBNetworkProvider identifies the Dummy network provider. DummyLBNetworkProvider = "DummyLBNetworkProvider" ) diff --git a/pkg/manager/options_test.go b/pkg/manager/options_test.go index 4d1d9cc6f2..8aa619b3c0 100644 --- a/pkg/manager/options_test.go +++ b/pkg/manager/options_test.go @@ -60,7 +60,10 @@ password: '%s' if err != nil { t.Fatal(err) } - t.Cleanup(func() { os.Remove(tmpFile.Name()) }) + t.Cleanup(func() { + // we don't want to error if this fails so ignore the error. + _ = os.Remove(tmpFile.Name()) + }) if _, err := tmpFile.WriteString(content); err != nil { t.Fatal(err) diff --git a/pkg/record/recorder.go b/pkg/record/recorder.go index cf11679efe..1131ae9c1d 100644 --- a/pkg/record/recorder.go +++ b/pkg/record/recorder.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package record contains tools for recording Kubernetes events. package record import ( diff --git a/pkg/services/fake/vmservice.go b/pkg/services/fake/vmservice.go index 175d7bd55c..584aae7ee5 100644 --- a/pkg/services/fake/vmservice.go +++ b/pkg/services/fake/vmservice.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package fake implements a fake VMService for testing. package fake import ( diff --git a/pkg/services/govmomi/cluster/rule.go b/pkg/services/govmomi/cluster/rule.go index a00cfdb11b..2f5e47797a 100644 --- a/pkg/services/govmomi/cluster/rule.go +++ b/pkg/services/govmomi/cluster/rule.go @@ -24,6 +24,7 @@ import ( "k8s.io/utils/pointer" ) +// Rule is a role for host affinity. type Rule interface { Disabled() bool @@ -49,6 +50,7 @@ func negate(input bool) bool { return !input } +// VerifyAffinityRule checks whether an affinity rule exists for a given hostGroup and vmGroup. func VerifyAffinityRule(ctx context.Context, computeClusterCtx computeClusterContext, clusterName, hostGroupName, vmGroupName string) (Rule, error) { rules, err := listRules(ctx, computeClusterCtx, clusterName) if err != nil { diff --git a/pkg/services/govmomi/cluster/service.go b/pkg/services/govmomi/cluster/service.go index d436bdd515..5424e724de 100644 --- a/pkg/services/govmomi/cluster/service.go +++ b/pkg/services/govmomi/cluster/service.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package cluster contains tools for managing ComputeClusters. package cluster import ( @@ -32,6 +33,7 @@ type computeClusterContext interface { GetSession() *session.Session } +// ListHostsFromGroup returns references to hosts for a given hostGroup. func ListHostsFromGroup(ctx context.Context, ccr *object.ClusterComputeResource, hostGroup string) ([]object.Reference, error) { clusterConfigInfoEx, err := ccr.Configuration(ctx) if err != nil { diff --git a/pkg/services/govmomi/cluster/vmgroup.go b/pkg/services/govmomi/cluster/vmgroup.go index da56a8c46f..46695e9b01 100644 --- a/pkg/services/govmomi/cluster/vmgroup.go +++ b/pkg/services/govmomi/cluster/vmgroup.go @@ -24,6 +24,7 @@ import ( "github.com/vmware/govmomi/vim25/types" ) +// FindVMGroup returns the VSphereVMGroup object. // TODO(zhanggbj): add (ctx context.Context) in function signature after refactoring context for pkg/services/govmomi/service.go. func FindVMGroup(computeClusterCtx computeClusterContext, clusterName, vmGroupName string) (*VMGroup, error) { ccr, err := computeClusterCtx.GetSession().Finder.ClusterComputeResource(computeClusterCtx, clusterName) diff --git a/pkg/services/govmomi/clustermodules/provider.go b/pkg/services/govmomi/clustermodules/provider.go index 5cf46f0619..b2213c4c4c 100644 --- a/pkg/services/govmomi/clustermodules/provider.go +++ b/pkg/services/govmomi/clustermodules/provider.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package clustermodules contains tools for handling Cluster Modules. package clustermodules import ( @@ -45,12 +46,14 @@ type provider struct { manager *cluster.Manager } +// NewProvider returns a new Cluster Module provider. func NewProvider(restClient *rest.Client) Provider { return &provider{ manager: cluster.NewManager(restClient), } } +// CreateModule creates a new Cluster Module and returns its ID. func (cm *provider) CreateModule(ctx context.Context, clusterRef types.ManagedObjectReference) (string, error) { log.Info("Creating cluster module", "cluster", clusterRef) @@ -63,6 +66,7 @@ func (cm *provider) CreateModule(ctx context.Context, clusterRef types.ManagedOb return moduleID, nil } +// DeleteModule deletes a Cluster Module by ID. func (cm *provider) DeleteModule(ctx context.Context, moduleID string) error { log.Info("Deleting cluster module", "moduleID", moduleID) @@ -75,6 +79,7 @@ func (cm *provider) DeleteModule(ctx context.Context, moduleID string) error { return nil } +// DoesModuleExist checks whether a module with a given name exists with the passed clusterRef and moduleID. func (cm *provider) DoesModuleExist(ctx context.Context, moduleID string, clusterRef types.ManagedObjectReference) (bool, error) { log.V(4).Info("Checking if cluster module exists", "moduleID", moduleID, "clusterRef", clusterRef) @@ -97,6 +102,7 @@ func (cm *provider) DoesModuleExist(ctx context.Context, moduleID string, cluste return false, nil } +// IsMoRefModuleMember checks whether the passed managed object reference is in the ClusterModule. func (cm *provider) IsMoRefModuleMember(ctx context.Context, moduleID string, moRef types.ManagedObjectReference) (bool, error) { moduleMembers, err := cm.manager.ListModuleMembers(ctx, moduleID) if err != nil { @@ -112,6 +118,7 @@ func (cm *provider) IsMoRefModuleMember(ctx context.Context, moduleID string, mo return false, nil } +// AddMoRefToModule adds the object to the ClusterModule if it is not already a member. func (cm *provider) AddMoRefToModule(ctx context.Context, moduleID string, moRef types.ManagedObjectReference) error { isMember, err := cm.IsMoRefModuleMember(ctx, moduleID, moRef) if err != nil { @@ -131,6 +138,7 @@ func (cm *provider) AddMoRefToModule(ctx context.Context, moduleID string, moRef return nil } +// RemoveMoRefFromModule removes the object from the ClusterModule. func (cm *provider) RemoveMoRefFromModule(ctx context.Context, moduleID string, moRef types.ManagedObjectReference) error { log.Info("Removing moRef from cluster module", "moduleID", moduleID, "moRef", moRef) diff --git a/pkg/services/govmomi/constants.go b/pkg/services/govmomi/constants.go index c690e64945..952e79e4c9 100644 --- a/pkg/services/govmomi/constants.go +++ b/pkg/services/govmomi/constants.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package govmomi contains tools for interacting with vSphere APIs. package govmomi const ( diff --git a/pkg/services/govmomi/extra/config.go b/pkg/services/govmomi/extra/config.go index 48ea293ad5..ef7de141fa 100644 --- a/pkg/services/govmomi/extra/config.go +++ b/pkg/services/govmomi/extra/config.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package extra contains config with a VM's guestInfo RPC interface. package extra import ( diff --git a/pkg/services/govmomi/find/object.go b/pkg/services/govmomi/find/object.go index aea16e3ba3..c2cfb4a447 100644 --- a/pkg/services/govmomi/find/object.go +++ b/pkg/services/govmomi/find/object.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package find is used to find VCenter objects based for failure domain handling. package find import ( @@ -29,6 +30,7 @@ import ( // ManagedRefFinder is the method to find the reference of the type specified in the Failure Domain. type ManagedRefFinder func(context.Context) ([]object.Reference, error) +// ObjectFunc returns a ManagedRefFinder for the failureDomainType. func ObjectFunc(failureDomainType infrav1.FailureDomainType, topology infrav1.Topology, finder *find.Finder) ManagedRefFinder { var managedRefFunc ManagedRefFinder diff --git a/pkg/services/govmomi/ipam/error.go b/pkg/services/govmomi/ipam/error.go index fac8d814c2..c2c031af40 100644 --- a/pkg/services/govmomi/ipam/error.go +++ b/pkg/services/govmomi/ipam/error.go @@ -20,4 +20,5 @@ import ( "github.com/pkg/errors" ) +// ErrWaitingForIPAddr is used when all IPAddressClaims have not been bound. var ErrWaitingForIPAddr = errors.New("waiting for IP address claims to be bound") diff --git a/pkg/services/govmomi/ipam/status.go b/pkg/services/govmomi/ipam/status.go index b7f59b36db..a7f6400685 100644 --- a/pkg/services/govmomi/ipam/status.go +++ b/pkg/services/govmomi/ipam/status.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package ipam contains tools for to deal with CAPI IPAddress and related types. package ipam import ( @@ -44,6 +45,7 @@ type ipamDeviceConfig struct { IPAMConfigGateway6 string } +// BuildState checks if IPAddressClaims are satisfied and returns a map of NetworkDeviceSpec. func BuildState(ctx context.VMContext, networkStatus []infrav1.NetworkStatus) (map[string]infrav1.NetworkDeviceSpec, error) { state := map[string]infrav1.NetworkDeviceSpec{} diff --git a/pkg/services/govmomi/metadata/metadata.go b/pkg/services/govmomi/metadata/metadata.go index 1499c3011a..ae5b512f98 100644 --- a/pkg/services/govmomi/metadata/metadata.go +++ b/pkg/services/govmomi/metadata/metadata.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package metadata contains tools to manage metadata tags on VCenter objects. package metadata import ( @@ -73,6 +74,7 @@ func getCategoryObject(name string, failureDomainType infrav1.FailureDomainType) } } +// CreateTag creates a new tag with the given with the given Name, and CategoryID. func CreateTag(ctx context.Context, metadataCtx metadataContext, name, categoryID string) error { logger := ctrl.LoggerFrom(ctx, "tag", name, "category", categoryID) manager := metadataCtx.GetSession().TagManager diff --git a/pkg/services/govmomi/net/net.go b/pkg/services/govmomi/net/net.go index 62c0ec01aa..37ca09871b 100644 --- a/pkg/services/govmomi/net/net.go +++ b/pkg/services/govmomi/net/net.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package net contains tools for handling VM networks. package net import ( diff --git a/pkg/services/govmomi/pci/device.go b/pkg/services/govmomi/pci/device.go index 3079135f0f..f97edeb402 100644 --- a/pkg/services/govmomi/pci/device.go +++ b/pkg/services/govmomi/pci/device.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package pci contains tools for PCI devices. package pci import ( @@ -26,6 +27,7 @@ import ( infrav1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/v1beta1" ) +// CalculateDevicesToBeAdded calculates the PCI devices which should be added to the VM. func CalculateDevicesToBeAdded(ctx context.Context, vm *object.VirtualMachine, deviceSpecs []infrav1.PCIDeviceSpec) ([]infrav1.PCIDeviceSpec, error) { // store the number of expected devices for each deviceID + vendorID combo deviceVendorIDComboMap := map[string]int{} @@ -56,6 +58,7 @@ func CalculateDevicesToBeAdded(ctx context.Context, vm *object.VirtualMachine, d return specsToBeAdded, nil } +// ConstructDeviceSpecs transforms a list of PCIDeviceSpec into a list of BaseVirutalDevices used by govmomi. func ConstructDeviceSpecs(pciDeviceSpecs []infrav1.PCIDeviceSpec) []types.BaseVirtualDevice { pciDevices := []types.BaseVirtualDevice{} deviceKey := int32(-200) diff --git a/pkg/services/govmomi/template/template.go b/pkg/services/govmomi/template/template.go index d53f2a3624..6b6834a5cb 100644 --- a/pkg/services/govmomi/template/template.go +++ b/pkg/services/govmomi/template/template.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package template has tools for finding VM templates. package template import ( diff --git a/pkg/services/govmomi/vcenter/clone.go b/pkg/services/govmomi/vcenter/clone.go index 68f29c363d..42f5192214 100644 --- a/pkg/services/govmomi/vcenter/clone.go +++ b/pkg/services/govmomi/vcenter/clone.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package vcenter has tools for cloning virtual machines in vcenter. package vcenter import ( diff --git a/pkg/services/network/constants.go b/pkg/services/network/constants.go index 5d4378a88e..1a754c464c 100644 --- a/pkg/services/network/constants.go +++ b/pkg/services/network/constants.go @@ -14,15 +14,18 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package network contains code for configuring network services. package network const ( + // NSXTTypeNetwork is the name of the NSX-T network type. NSXTTypeNetwork = "nsx-t" - // NSXTVNetSelectorKey - // This constant is also defined in VM Operator. + // NSXTVNetSelectorKey is also defined in VM Operator. NSXTVNetSelectorKey = "ncp.vmware.com/virtual-network-name" - CAPVDefaultNetworkLabel = "capv.vmware.com/is-default-network" + // CAPVDefaultNetworkLabel is a label used to identify the default network. + CAPVDefaultNetworkLabel = "capv.vmware.com/is-default-network" + // NetOpNetworkNameAnnotation is the key used in an annotation to define the NetOp network. The expected value is the network name. NetOpNetworkNameAnnotation = "netoperator.vmware.com/network-name" // SystemNamespace is the namespace where supervisor control plane VMs reside. diff --git a/pkg/services/network/netop_provider.go b/pkg/services/network/netop_provider.go index 4c471dcfff..6d19b47658 100644 --- a/pkg/services/network/netop_provider.go +++ b/pkg/services/network/netop_provider.go @@ -36,16 +36,19 @@ type netopNetworkProvider struct { client client.Client } +// NetOpNetworkProvider returns a NetOp (VDS) Network Provider. func NetOpNetworkProvider(client client.Client) services.NetworkProvider { return &netopNetworkProvider{ client: client, } } +// HasLoadBalancer is always true for the NetOp Network Provider. func (np *netopNetworkProvider) HasLoadBalancer() bool { return true } +// ProvisionClusterNetwork marks the ClusterNetworkReadyCondition true. func (np *netopNetworkProvider) ProvisionClusterNetwork(_ context.Context, clusterCtx *vmware.ClusterContext) error { conditions.MarkTrue(clusterCtx.VSphereCluster, vmwarev1.ClusterNetworkReadyCondition) return nil @@ -88,6 +91,7 @@ func (np *netopNetworkProvider) getClusterNetwork(ctx context.Context, clusterCt return np.getDefaultClusterNetwork(ctx, clusterCtx) } +// GetClusterNetworkName returns the name of the network for the passed cluster. func (np *netopNetworkProvider) GetClusterNetworkName(ctx context.Context, clusterCtx *vmware.ClusterContext) (string, error) { network, err := np.getClusterNetwork(ctx, clusterCtx) if err != nil { @@ -97,6 +101,7 @@ func (np *netopNetworkProvider) GetClusterNetworkName(ctx context.Context, clust return network.Name, nil } +// GetVMServiceAnnotations returns the name of the network in a map[string]string to allow usage in annotations. func (np *netopNetworkProvider) GetVMServiceAnnotations(ctx context.Context, clusterCtx *vmware.ClusterContext) (map[string]string, error) { networkName, err := np.GetClusterNetworkName(ctx, clusterCtx) if err != nil { @@ -106,6 +111,7 @@ func (np *netopNetworkProvider) GetVMServiceAnnotations(ctx context.Context, clu return map[string]string{NetOpNetworkNameAnnotation: networkName}, nil } +// ConfigureVirtualMachine configures the NetworkInterfaces on a VM Operator virtual machine. func (np *netopNetworkProvider) ConfigureVirtualMachine(ctx context.Context, clusterCtx *vmware.ClusterContext, vm *vmoprv1.VirtualMachine) error { network, err := np.getClusterNetwork(ctx, clusterCtx) if err != nil { diff --git a/pkg/services/vimmachine.go b/pkg/services/vimmachine.go index 98359bb24d..7b0426afd6 100644 --- a/pkg/services/vimmachine.go +++ b/pkg/services/vimmachine.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package services contains tools for handling VSphere services. package services import ( @@ -39,8 +40,10 @@ import ( infrautilv1 "sigs.k8s.io/cluster-api-provider-vsphere/pkg/util" ) +// VimMachineService reconciles VSphere VMs. type VimMachineService struct{} +// FetchVSphereMachine returns a new MachineContext containing the vsphereMachine. func (v *VimMachineService) FetchVSphereMachine(c client.Client, name types.NamespacedName) (capvcontext.MachineContext, error) { vsphereMachine := &infrav1.VSphereMachine{} err := c.Get(context.Background(), name, vsphereMachine) @@ -48,6 +51,7 @@ func (v *VimMachineService) FetchVSphereMachine(c client.Client, name types.Name return &capvcontext.VIMMachineContext{VSphereMachine: vsphereMachine}, err } +// FetchVSphereCluster adds the VSphereCluster associated with the passed cluster to the machineContext. func (v *VimMachineService) FetchVSphereCluster(c client.Client, cluster *clusterv1.Cluster, machineContext capvcontext.MachineContext) (capvcontext.MachineContext, error) { vimMachineCtx, ok := machineContext.(*capvcontext.VIMMachineContext) if !ok { @@ -64,6 +68,7 @@ func (v *VimMachineService) FetchVSphereCluster(c client.Client, cluster *cluste return vimMachineCtx, err } +// ReconcileDelete reconciles delete events for the VSphere VM. func (v *VimMachineService) ReconcileDelete(machineCtx capvcontext.MachineContext) error { vimMachineCtx, ok := machineCtx.(*capvcontext.VIMMachineContext) if !ok { @@ -90,6 +95,7 @@ func (v *VimMachineService) ReconcileDelete(machineCtx capvcontext.MachineContex return nil } +// SyncFailureReason returns true if the VSphere Machine has failed. func (v *VimMachineService) SyncFailureReason(machineCtx capvcontext.MachineContext) (bool, error) { vimMachineCtx, ok := machineCtx.(*capvcontext.VIMMachineContext) if !ok { @@ -109,6 +115,7 @@ func (v *VimMachineService) SyncFailureReason(machineCtx capvcontext.MachineCont return vimMachineCtx.VSphereMachine.Status.FailureReason != nil || vimMachineCtx.VSphereMachine.Status.FailureMessage != nil, err } +// ReconcileNormal reconciles create and update events for the VSphere VM. func (v *VimMachineService) ReconcileNormal(machineCtx capvcontext.MachineContext) (bool, error) { vimMachineCtx, ok := machineCtx.(*capvcontext.VIMMachineContext) if !ok { @@ -157,6 +164,7 @@ func (v *VimMachineService) ReconcileNormal(machineCtx capvcontext.MachineContex return false, nil } +// GetHostInfo returns the hostname or IP address of the infrastructure host for the VSphere VM. func (v *VimMachineService) GetHostInfo(c capvcontext.MachineContext) (string, error) { vimMachineCtx, ok := c.(*capvcontext.VIMMachineContext) if !ok { diff --git a/pkg/services/vmoperator/constants.go b/pkg/services/vmoperator/constants.go index 0a405bdd5d..011082a06c 100644 --- a/pkg/services/vmoperator/constants.go +++ b/pkg/services/vmoperator/constants.go @@ -14,14 +14,20 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package vmoperator contains reconcilers and related functions for VM Operator based VSphereMachines. package vmoperator const ( kubeTopologyZoneLabelKey = "topology.kubernetes.io/zone" + // ControlPlaneVMClusterModuleGroupName is the name used for the control plane Cluster Module. ControlPlaneVMClusterModuleGroupName = "control-plane-group" - ClusterModuleNameAnnotationKey = "vsphere-cluster-module-group" - ProviderTagsAnnotationKey = "vsphere-tag" + // ClusterModuleNameAnnotationKey is key for the Cluster Module annotation. + ClusterModuleNameAnnotationKey = "vsphere-cluster-module-group" + // ProviderTagsAnnotationKey is the key used for the provider tags annotation. + ProviderTagsAnnotationKey = "vsphere-tag" + // ControlPlaneVMVMAntiAffinityTagValue is the value used for ProviderTagsAnnotationKey when the machine is a control plane machine. ControlPlaneVMVMAntiAffinityTagValue = "CtrlVmVmAATag" - WorkerVMVMAntiAffinityTagValue = "WorkerVmVmAATag" + // WorkerVMVMAntiAffinityTagValue is the value used for ProviderTagsAnnotationKey when the machine is a worker machine. + WorkerVMVMAntiAffinityTagValue = "WorkerVmVmAATag" ) diff --git a/pkg/services/vmoperator/vmopmachine.go b/pkg/services/vmoperator/vmopmachine.go index 77ab227562..d4cb214db7 100644 --- a/pkg/services/vmoperator/vmopmachine.go +++ b/pkg/services/vmoperator/vmopmachine.go @@ -41,14 +41,17 @@ import ( vmwareutil "sigs.k8s.io/cluster-api-provider-vsphere/pkg/util/vmware" ) +// VmopMachineService reconciles VM Operator VM. type VmopMachineService struct{} +// FetchVSphereMachine returns a MachineContext with a VSphereMachine for the passed NamespacedName. func (v *VmopMachineService) FetchVSphereMachine(client client.Client, name types.NamespacedName) (capvcontext.MachineContext, error) { vsphereMachine := &vmwarev1.VSphereMachine{} err := client.Get(context.Background(), name, vsphereMachine) return &vmware.SupervisorMachineContext{VSphereMachine: vsphereMachine}, err } +// FetchVSphereCluster adds the VSphereCluster for the cluster to the MachineContext. func (v *VmopMachineService) FetchVSphereCluster(c client.Client, cluster *clusterv1.Cluster, machineContext capvcontext.MachineContext) (capvcontext.MachineContext, error) { ctx, ok := machineContext.(*vmware.SupervisorMachineContext) if !ok { @@ -66,6 +69,7 @@ func (v *VmopMachineService) FetchVSphereCluster(c client.Client, cluster *clust return ctx, err } +// ReconcileDelete reconciles delete events for VM Operator VM. func (v *VmopMachineService) ReconcileDelete(machineCtx capvcontext.MachineContext) error { supervisorMachineCtx, ok := machineCtx.(*vmware.SupervisorMachineContext) if !ok { @@ -114,6 +118,7 @@ func (v *VmopMachineService) ReconcileDelete(machineCtx capvcontext.MachineConte return nil } +// SyncFailureReason returns true if there is a Failure on the VM Operator VM. func (v *VmopMachineService) SyncFailureReason(machineCtx capvcontext.MachineContext) (bool, error) { supervisorMachineCtx, ok := machineCtx.(*vmware.SupervisorMachineContext) if !ok { @@ -123,6 +128,7 @@ func (v *VmopMachineService) SyncFailureReason(machineCtx capvcontext.MachineCon return supervisorMachineCtx.VSphereMachine.Status.FailureReason != nil || supervisorMachineCtx.VSphereMachine.Status.FailureMessage != nil, nil } +// ReconcileNormal reconciles create and update events for VM Operator VMs. func (v *VmopMachineService) ReconcileNormal(machineCtx capvcontext.MachineContext) (bool, error) { supervisorMachineCtx, ok := machineCtx.(*vmware.SupervisorMachineContext) if !ok { @@ -220,6 +226,7 @@ func (v *VmopMachineService) ReconcileNormal(machineCtx capvcontext.MachineConte return false, nil } +// GetHostInfo returns the hostname or IP address of the infrastructure host for the VM Operator VM. func (v VmopMachineService) GetHostInfo(machineCtx capvcontext.MachineContext) (string, error) { supervisorMachineCtx, ok := machineCtx.(*vmware.SupervisorMachineContext) if !ok { diff --git a/pkg/session/error.go b/pkg/session/error.go index 0517f03803..f53fb5b49e 100644 --- a/pkg/session/error.go +++ b/pkg/session/error.go @@ -34,6 +34,7 @@ func (e unidentifiedVCenterVersion) Error() string { return fmt.Sprintf("%s: %s", errString, e.version) } +// IsUnidentifiedVCenterVersion identies an error as an unidentifiedVCenterVersion error. func IsUnidentifiedVCenterVersion(err error) bool { return strings.HasPrefix(err.Error(), errString) } diff --git a/pkg/session/session.go b/pkg/session/session.go index a6fbe110db..6d2f68a06f 100644 --- a/pkg/session/session.go +++ b/pkg/session/session.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package session contains tools to create and retrieve a VCenter session. package session import ( @@ -61,17 +62,20 @@ type Session struct { TagManager *tags.Manager } +// Feature is a set of Features of the session. type Feature struct { EnableKeepAlive bool KeepAliveDuration time.Duration } +// DefaultFeature sets the default values for features. func DefaultFeature() Feature { return Feature{ EnableKeepAlive: constants.DefaultEnableKeepAlive, } } +// Params are the parameters of a VCenter session. type Params struct { server string datacenter string @@ -80,32 +84,38 @@ type Params struct { feature Feature } +// NewParams returns an empty set of parameters with default features. func NewParams() *Params { return &Params{ feature: DefaultFeature(), } } +// WithServer adds a server to parameters. func (p *Params) WithServer(server string) *Params { p.server = server return p } +// WithDatacenter adds a datacenter to parameters. func (p *Params) WithDatacenter(datacenter string) *Params { p.datacenter = datacenter return p } +// WithUserInfo adds userinfo to parameters. func (p *Params) WithUserInfo(username, password string) *Params { p.userinfo = url.UserPassword(username, password) return p } +// WithThumbprint adds a thumbprint to parameters. func (p *Params) WithThumbprint(thumbprint string) *Params { p.thumbprint = thumbprint return p } +// WithFeatures adds features to parameters. func (p *Params) WithFeatures(feature Feature) *Params { p.feature = feature return p @@ -270,6 +280,7 @@ func newManager(ctx context.Context, logger logr.Logger, sessionKey string, clie return tags.NewManager(rc), nil } +// GetVersion returns the VCenterVersion. func (s *Session) GetVersion() (infrav1.VCenterVersion, error) { svcVersion := s.ServiceContent.About.Version version, err := semver.New(svcVersion) diff --git a/pkg/taggable/get.go b/pkg/taggable/get.go index 9f1d23ab63..d5e727f271 100644 --- a/pkg/taggable/get.go +++ b/pkg/taggable/get.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package taggable handles tagging objects in VSphere. package taggable import ( @@ -31,6 +32,7 @@ type taggableContext interface { GetVsphereFailureDomain() infrav1.VSphereFailureDomain } +// GetObjects returns the objects for a given failure domain. func GetObjects(ctx context.Context, taggableCtx taggableContext, fdType infrav1.FailureDomainType) (Objects, error) { finderFunc := find.ObjectFunc(fdType, taggableCtx.GetVsphereFailureDomain().Spec.Topology, taggableCtx.GetSession().Finder) objRefs, err := finderFunc(ctx) diff --git a/pkg/taggable/object.go b/pkg/taggable/object.go index 8bc769948d..08c36110e6 100644 --- a/pkg/taggable/object.go +++ b/pkg/taggable/object.go @@ -23,12 +23,14 @@ import ( "github.com/vmware/govmomi/vapi/tags" ) +// Object is an object which is taggable. type Object interface { HasTag(ctx context.Context, tagName string) (bool, error) AttachTag(ctx context.Context, tagName string) error } +// Objects is a list of Object. type Objects []Object type managedObject struct { diff --git a/pkg/util/constants.go b/pkg/util/constants.go index 82d28270a5..0ff1384ee5 100644 --- a/pkg/util/constants.go +++ b/pkg/util/constants.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package util contains utils. package util const metadataFormat = ` diff --git a/pkg/util/errors.go b/pkg/util/errors.go index ea7deb4b1e..b4adf20641 100644 --- a/pkg/util/errors.go +++ b/pkg/util/errors.go @@ -21,6 +21,7 @@ import ( "strings" ) +// IsNotFoundError identifies a not found error from a HTTP 404 status code. func IsNotFoundError(err error) bool { return strings.HasSuffix(err.Error(), http.StatusText(http.StatusNotFound)) } diff --git a/pkg/util/fetch_object.go b/pkg/util/fetch_object.go index 3d26720822..4b90ecfff8 100644 --- a/pkg/util/fetch_object.go +++ b/pkg/util/fetch_object.go @@ -27,12 +27,14 @@ import ( ctrlclient "sigs.k8s.io/controller-runtime/pkg/client" ) +// FetchObjectInput contains data to fetch objects. type FetchObjectInput struct { context.Context //nolint:containedctx ctrlclient.Client Object ctrlclient.Object } +// FetchControlPlaneOwnerObject returns the ControlPlane owner for a Machine. func FetchControlPlaneOwnerObject(input FetchObjectInput) (ctrlclient.Object, error) { gvk := controlplanev1.GroupVersion kcp := &controlplanev1.KubeadmControlPlane{} @@ -42,6 +44,7 @@ func FetchControlPlaneOwnerObject(input FetchObjectInput) (ctrlclient.Object, er return kcp, nil } +// FetchMachineDeploymentOwnerObject returns the MachineDeployment owner for a Machine. func FetchMachineDeploymentOwnerObject(input FetchObjectInput) (ctrlclient.Object, error) { gvk := clusterv1.GroupVersion diff --git a/pkg/util/machines.go b/pkg/util/machines.go index 562c3b164b..f8b2d2d5f5 100644 --- a/pkg/util/machines.go +++ b/pkg/util/machines.go @@ -193,6 +193,7 @@ func GetMachineMetadata(hostname string, vsphereVM infrav1.VSphereVM, ipamState return buf.Bytes(), nil } +// GetOwnerVSphereMachine returns the VSphereMachine owner for the passed object. func GetOwnerVSphereMachine(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*infrav1.VSphereMachine, error) { for _, ref := range obj.OwnerReferences { gv, err := schema.ParseGroupVersion(ref.APIVersion) diff --git a/pkg/util/networkutil.go b/pkg/util/networkutil.go index dae51daceb..b8508a5b8c 100644 --- a/pkg/util/networkutil.go +++ b/pkg/util/networkutil.go @@ -27,21 +27,29 @@ import ( ) const ( - NCPSNATKey = "ncp/snat_ip" - NCPVersionKey = "version" - NCPNamespace = "vmware-system-nsx" + // NCPSNATKey is the key used for the NCPSNAT annotation. + NCPSNATKey = "ncp/snat_ip" + // NCPVersionKey is the key used for version information in the NCP configmap. + NCPVersionKey = "version" + // NCPNamespace is the namespace of the NCP configmap. + NCPNamespace = "vmware-system-nsx" + // NCPVersionConfigMap is a name of the NCP config map. NCPVersionConfigMap = "nsx-ncp-version-config" - // 3.0.1 is where NCP starts to support "whitelist_source_ranges" specification in VNET and enforce FW rules on GC T1. + // NCPVersionSupportFW 3.0.1 is where NCP starts to support "whitelist_source_ranges" specification in VNET and enforce FW rules on GC T1. NCPVersionSupportFW = "3.0.1" - // 3.1.0 is where NCP stopped to support "whitelist_source_ranges" specification in VNET. + // NCPVersionSupportFWEnded 3.1.0 is where NCP stopped to support "whitelist_source_ranges" specification in VNET. NCPVersionSupportFWEnded = "3.1.0" + // EmptyAnnotationErrorMsg is an error message returned when no annotations are found. EmptyAnnotationErrorMsg = "annotation not found" - EmptyNCPSNATKeyMsg = NCPSNATKey + " key not found" + // EmptyNCPSNATKeyMsg is an error message returned when the annotation can not be found. + EmptyNCPSNATKeyMsg = NCPSNATKey + " key not found" ) var ( - NCPVersionSupportFWSemver = semver.MustParse(NCPVersionSupportFW) + // NCPVersionSupportFWSemver is the SemVer representation of the minimum NCPVersion for enforcing FW rules. + NCPVersionSupportFWSemver = semver.MustParse(NCPVersionSupportFW) + // NCPVersionSupportFWEndedSemver is the SemVer representation of the maximum NCPVersion for enforcing FW rules. NCPVersionSupportFWEndedSemver = semver.MustParse(NCPVersionSupportFWEnded) ) diff --git a/pkg/util/supervisor.go b/pkg/util/supervisor.go index 717d0c314f..71ceda66ad 100644 --- a/pkg/util/supervisor.go +++ b/pkg/util/supervisor.go @@ -30,6 +30,7 @@ import ( vmwarev1 "sigs.k8s.io/cluster-api-provider-vsphere/apis/vmware/v1beta1" ) +// IsSupervisorType identifies whether the passed object is using the supervisor API. func IsSupervisorType(input interface{}) (bool, error) { switch input.(type) { case *infrav1.VSphereCluster, *infrav1.VSphereMachine: diff --git a/pkg/util/vmware/util.go b/pkg/util/vmware/util.go index 3d634b3516..6130e4cdf4 100644 --- a/pkg/util/vmware/util.go +++ b/pkg/util/vmware/util.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package vmware contains tools for handling Cluster API objects. package vmware import ( @@ -22,7 +23,7 @@ import ( clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" ) -// GetMachineDeploymentName returns the MachineDeployment name for a Cluster. +// GetMachineDeploymentNameForCluster returns the MachineDeployment name for a Cluster. // This is also the name used by VSphereMachineTemplate and KubeadmConfigTemplate. func GetMachineDeploymentNameForCluster(cluster *clusterv1.Cluster) string { return fmt.Sprintf("%s-workers-0", cluster.Name) diff --git a/test/e2e/common.go b/test/e2e/common.go index 8c5fa29ad5..c73d0452bc 100644 --- a/test/e2e/common.go +++ b/test/e2e/common.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package e2e contains end to end test code and utils. package e2e import ( diff --git a/test/helpers/envtest.go b/test/helpers/envtest.go index a65c4617bf..de0f9ba917 100644 --- a/test/helpers/envtest.go +++ b/test/helpers/envtest.go @@ -15,6 +15,8 @@ limitations under the License. */ //nolint:wrapcheck + +// Package helpers contains helpers for creating a test environment. package helpers import ( diff --git a/test/helpers/vcsim/simulator.go b/test/helpers/vcsim/simulator.go index a382412546..5ed8826330 100644 --- a/test/helpers/vcsim/simulator.go +++ b/test/helpers/vcsim/simulator.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package vcsim contains tools for running a VCenter simulator. package vcsim import ( diff --git a/test/helpers/vmware/unit_test_context.go b/test/helpers/vmware/unit_test_context.go index dbddba42b6..d3b0ff0217 100644 --- a/test/helpers/vmware/unit_test_context.go +++ b/test/helpers/vmware/unit_test_context.go @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ +// Package vmware contains context objects for testing. package vmware import ( diff --git a/test/helpers/webhook.go b/test/helpers/webhook.go index 0d105913e8..9bf5743e4c 100644 --- a/test/helpers/webhook.go +++ b/test/helpers/webhook.go @@ -116,7 +116,9 @@ func (t *TestEnvironment) WaitForWebhooks() { klog.V(2).Infof("Webhook port is not ready, will retry in %v: %s", timeout, err) continue } - conn.Close() + if err := conn.Close(); err != nil { + klog.V(2).Info("Webhook port could not be closed. Continuing with tests...") + } klog.V(2).Info("Webhook port is now open. Continuing with tests...") return }