Skip to content

Commit

Permalink
Merge pull request #2383 from killianmuldoon/pr-remove-lint-ignore
Browse files Browse the repository at this point in the history
🌱 Remove lint ignore for comments and unhandled errors
  • Loading branch information
k8s-ci-robot authored Sep 25, 2023
2 parents 830aa85 + 653d6e9 commit 6287964
Show file tree
Hide file tree
Showing 106 changed files with 367 additions and 190 deletions.
34 changes: 12 additions & 22 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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$
2 changes: 2 additions & 0 deletions apis/v1alpha3/vsphereclusteridentity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
)

const (
// SecretIdentitySetFinalizer is the finalizer for VSphereCluster credentials secrets .
SecretIdentitySetFinalizer = "vspherecluster/infrastructure.cluster.x-k8s.io"
)

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions apis/v1alpha4/vspherecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions apis/v1alpha4/vsphereclusteridentity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
)

const (
// SecretIdentitySetFinalizer is the finalizer for VSphereCluster credentials secrets .
SecretIdentitySetFinalizer = "vspherecluster/infrastructure.cluster.x-k8s.io"
)

Expand Down Expand Up @@ -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.
Expand Down
17 changes: 8 additions & 9 deletions apis/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint:godot
package v1beta1

import (
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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"
)

Expand Down
12 changes: 7 additions & 5 deletions apis/v1beta1/vspherecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint:godot
package v1beta1

import (
Expand All @@ -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"`
Expand Down Expand Up @@ -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"`
Expand All @@ -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"`
Expand All @@ -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"`
Expand Down
21 changes: 16 additions & 5 deletions apis/v1beta1/vsphereclusteridentity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint:godot
package v1beta1

import (
Expand All @@ -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
Expand All @@ -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"`
Expand All @@ -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
Expand All @@ -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
}
Expand All @@ -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"`
Expand All @@ -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"`
Expand Down
6 changes: 3 additions & 3 deletions apis/v1beta1/vsphereclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand All @@ -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"`
Expand All @@ -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"`
}
Loading

0 comments on commit 6287964

Please sign in to comment.