Skip to content

Commit d0494d2

Browse files
committed
Require comments on exported funcs
1 parent 3da52a3 commit d0494d2

34 files changed

+78
-25
lines changed

.golangci.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,37 @@ run:
66
- "zz_generated.*\\.go$"
77
- ".*conversion.*\\.go$"
88
linters:
9+
disable-all: true
910
enable:
11+
- deadcode
12+
- goconst
13+
- gofmt
1014
- golint
15+
- gosec
1116
- govet
12-
- gofmt
13-
- structcheck
14-
- varcheck
15-
- interfacer
16-
- unconvert
1717
- ineffassign
18-
- goconst
19-
# - gocyclo
18+
- interfacer
2019
- maligned
2120
- misspell
2221
- nakedret
2322
- prealloc
24-
- gosec
25-
- deadcode
26-
disable-all: true
23+
- structcheck
24+
- unconvert
25+
- varcheck
2726
# Run with --fast=false for more extensive checks
2827
fast: true
29-
issue:
28+
issues:
29+
exclude-rules:
30+
- path: internal/test/
31+
linters:
32+
- golint
33+
- path: cloudtest\.go
34+
linters:
35+
- golint
36+
- path: api/v1alpha2/types\.go
37+
linters:
38+
- golint
39+
include:
40+
- EXC0002 # include "missing comments" issues from golint
41+
max-issues-per-linter: 0
3042
max-same-issues: 0
31-
max-per-linter: 0

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ CONVERSION_GEN := $(TOOLS_BIN_DIR)/$(CONVERSION_GEN_BIN)-$(CONVERSION_GEN_VER)
5858
ENVSUBST_BIN := envsubst
5959
ENVSUBST := $(TOOLS_BIN_DIR)/$(ENVSUBST_BIN)-drone
6060

61-
GOLANGCI_LINT_VER := v1.27.0
61+
GOLANGCI_LINT_VER := v1.31.0
6262
GOLANGCI_LINT_BIN := golangci-lint
6363
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)
6464

api/v1alpha3/azurecluster_webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
// log is for logging in this package.
2727
var clusterlog = logf.Log.WithName("azurecluster-resource")
2828

29+
// SetupWebhookWithManager sets up and registers the webhook with the manager.
2930
func (c *AzureCluster) SetupWebhookWithManager(mgr ctrl.Manager) error {
3031
return ctrl.NewWebhookManagedBy(mgr).
3132
For(c).

api/v1alpha3/azuremachine_validation.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1alpha3
1919
import (
2020
"encoding/base64"
2121
"fmt"
22+
2223
"github.com/google/uuid"
2324

2425
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute"
@@ -44,7 +45,7 @@ func ValidateSSHKey(sshKey string, fldPath *field.Path) field.ErrorList {
4445
return allErrs
4546
}
4647

47-
// ValidateUserAssignedIdentity validates the user-assigned identities list
48+
// ValidateSystemAssignedIdentity validates the system-assigned identities list.
4849
func ValidateSystemAssignedIdentity(identityType VMIdentity, old, new string, fldPath *field.Path) field.ErrorList {
4950
allErrs := field.ErrorList{}
5051

api/v1alpha3/azuremachine_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
// log is for logging in this package.
2929
var machinelog = logf.Log.WithName("azuremachine-resource")
3030

31-
// SetupWebhookWithManager will setup and register the webhook with the controller mnager
31+
// SetupWebhookWithManager sets up and registers the webhook with the manager.
3232
func (m *AzureMachine) SetupWebhookWithManager(mgr ctrl.Manager) error {
3333
return ctrl.NewWebhookManagedBy(mgr).
3434
For(m).

api/v1alpha3/azuremachinetemplate_webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
// log is for logging in this package.
2525
var _ = logf.Log.WithName("azuremachinetemplate-resource")
2626

27+
// SetupWebhookWithManager sets up and registers the webhook with the manager.
2728
func (r *AzureMachineTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
2829
return ctrl.NewWebhookManagedBy(mgr).
2930
For(r).

api/v1alpha3/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const (
177177
SKUStandard = SKU("Standard")
178178
)
179179

180-
// BackendPool defines a load balancer backend pool
180+
// BackendPool defines a load balancer backend pool.
181181
type BackendPool struct {
182182
Name string `json:"name,omitempty"`
183183
ID string `json:"id,omitempty"`

cloud/converters/rules.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha3"
2323
)
2424

25+
// IngresstoSecurityRule converts a CAPI ingress rule to an Azure network security rule.
2526
func IngresstoSecurityRule(ingress infrav1.IngressRule) network.SecurityRule {
2627
secRule := network.SecurityRule{
2728
Name: to.StringPtr(ingress.Name),
@@ -49,6 +50,7 @@ func IngresstoSecurityRule(ingress infrav1.IngressRule) network.SecurityRule {
4950
return secRule
5051
}
5152

53+
// SecuritytoIngressRule converts an Azure network security rule to a CAPI ingress rule.
5254
func SecuritytoIngressRule(rule network.SecurityRule) infrav1.IngressRule {
5355
ingRule := infrav1.IngressRule{
5456
Name: to.String(rule.Name),

cloud/errors.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ package azure
1818

1919
import (
2020
"errors"
21+
2122
"github.com/Azure/go-autorest/autorest"
2223
)
2324

25+
// ErrNotOwned is returned when a resource can't be deleted because it isn't owned.
2426
var ErrNotOwned = errors.New("resource is not managed and cannot be deleted")
2527

2628
// ResourceNotFound parses the error to check if it's a resource not found error.

cloud/interfaces.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ type ClusterDescriber interface {
7676
AdditionalTags() infrav1.Tags
7777
}
7878

79+
// ClusterScoper combines the ClusterDescriber and NetworkDescriber interfaces.
7980
type ClusterScoper interface {
8081
ClusterDescriber
8182
NetworkDescriber

cloud/scope/machinepool.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package scope
1919
import (
2020
"context"
2121
"encoding/base64"
22+
2223
"github.com/Azure/go-autorest/autorest/to"
2324
"github.com/go-logr/logr"
2425
"github.com/pkg/errors"
@@ -187,6 +188,7 @@ func (m *MachinePoolScope) PatchObject(ctx context.Context) error {
187188
return m.patchHelper.Patch(ctx, m.AzureMachinePool)
188189
}
189190

191+
// AzureMachineTemplate gets the Azure machine template in this scope.
190192
func (m *MachinePoolScope) AzureMachineTemplate(ctx context.Context) (*infrav1.AzureMachineTemplate, error) {
191193
ref := m.MachinePool.Spec.Template.Spec.InfrastructureRef
192194
return getAzureMachineTemplate(ctx, m.client, ref.Name, ref.Namespace)
@@ -225,7 +227,7 @@ func (m *MachinePoolScope) GetBootstrapData(ctx context.Context) (string, error)
225227
return base64.StdEncoding.EncodeToString(value), nil
226228
}
227229

228-
// Pick image from the machine configuration, or use a default one.
230+
// GetVMImage picks an image from the machine configuration, or uses a default one.
229231
func (m *MachinePoolScope) GetVMImage() (*infrav1.Image, error) {
230232
// Use custom Marketplace image, Image ID or a Shared Image Gallery image if provided
231233
if m.AzureMachinePool.Spec.Template.Image != nil {

cloud/scope/managedcontrolplane.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,20 @@ type ManagedControlPlaneScope struct {
9797
PatchTarget runtime.Object
9898
}
9999

100+
// ResourceGroup returns the managed control plane's resource group.
100101
func (s *ManagedControlPlaneScope) ResourceGroup() string {
101102
if s.ControlPlane == nil {
102103
return ""
103104
}
104105
return s.ControlPlane.Spec.ResourceGroup
105106
}
106107

108+
// ClusterName returns the managed control plane's name.
107109
func (s *ManagedControlPlaneScope) ClusterName() string {
108110
return s.Cluster.Name
109111
}
110112

113+
// Location returns the managed control plane's Azure location, or an empty string.
111114
func (s *ManagedControlPlaneScope) Location() string {
112115
if s.ControlPlane == nil {
113116
return ""

cloud/services/managedclusters/managedclusters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type Spec struct {
7474
DNSServiceIP *string
7575
}
7676

77+
// PoolSpec contains agent pool specification details.
7778
type PoolSpec struct {
7879
Name string
7980
SKU string

cloud/services/scalesets/client.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func newPublicIPsClient(subscriptionID string, baseURI string, authorizer autore
8080
return c
8181
}
8282

83-
// Get retrieves information about the model view of a virtual machine scale set.
83+
// ListInstances retrieves information about the model views of a virtual machine scale set.
8484
func (ac *AzureClient) ListInstances(ctx context.Context, resourceGroupName, vmssName string) ([]compute.VirtualMachineScaleSetVM, error) {
8585
itr, err := ac.scalesetvms.ListComplete(ctx, resourceGroupName, vmssName, "", "", "")
8686
if err != nil {
@@ -98,7 +98,7 @@ func (ac *AzureClient) ListInstances(ctx context.Context, resourceGroupName, vms
9898
return instances, nil
9999
}
100100

101-
// Lists all scale sets in a resource group.
101+
// List returns all scale sets in a resource group.
102102
func (ac *AzureClient) List(ctx context.Context, resourceGroupName string) ([]compute.VirtualMachineScaleSet, error) {
103103
itr, err := ac.scalesets.ListComplete(ctx, resourceGroupName)
104104
var instances []compute.VirtualMachineScaleSet
@@ -160,6 +160,7 @@ func (ac *AzureClient) Delete(ctx context.Context, resourceGroupName, vmssName s
160160
return err
161161
}
162162

163+
// GetPublicIPAddress gets the public IP address for the given public IP name.
163164
func (ac *AzureClient) GetPublicIPAddress(ctx context.Context, resourceGroupName, publicIPName string) (network.PublicIPAddress, error) {
164165
return ac.publicIPs.Get(ctx, resourceGroupName, publicIPName, "true")
165166
}

cloud/services/scalesets/service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16+
1617
package scalesets
1718

1819
import (
1920
"context"
21+
2022
"github.com/go-logr/logr"
2123
infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1alpha3"
2224
azure "sigs.k8s.io/cluster-api-provider-azure/cloud"

cloud/services/scalesets/vmss.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func (s *Service) getExisting(ctx context.Context, name string) (*infrav1exp.VMS
4848
return converters.SDKToVMSS(vmss, vmssInstances), nil
4949
}
5050

51+
// Reconcile idempotently gets, creates, and updates a scale set.
5152
func (s *Service) Reconcile(ctx context.Context) error {
5253
vmssSpec := s.Scope.ScaleSetSpec()
5354

@@ -226,6 +227,7 @@ func (s *Service) Reconcile(ctx context.Context) error {
226227
return nil
227228
}
228229

230+
// Delete deletes a scale set.
229231
func (s *Service) Delete(ctx context.Context) error {
230232
vmssSpec := s.Scope.ScaleSetSpec()
231233
s.Scope.V(2).Info("deleting VMSS", "scale set", vmssSpec.Name)

cloud/services/tags/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package tags
1818

1919
import (
2020
"context"
21+
2122
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-10-01/resources"
2223

2324
"github.com/Azure/go-autorest/autorest"
@@ -56,7 +57,7 @@ func (ac *AzureClient) GetAtScope(ctx context.Context, scope string) (resources.
5657
return ac.tags.GetAtScope(ctx, scope)
5758
}
5859

59-
// CreateOrUpdate allows adding or replacing the entire set of tags on the specified resource or subscription.
60+
// CreateOrUpdateAtScope allows adding or replacing the entire set of tags on the specified resource or subscription.
6061
func (ac *AzureClient) CreateOrUpdateAtScope(ctx context.Context, scope string, parameters resources.TagsResource) (resources.TagsResource, error) {
6162
return ac.tags.CreateOrUpdateAtScope(ctx, scope, parameters)
6263
}

config/crd/bases/infrastructure.cluster.x-k8s.io_azureclusters.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ spec:
715715
description: APIServerLB is the Kubernetes API server load balancer.
716716
properties:
717717
backendPool:
718-
description: BackendPool defines a load balancer backend pool
718+
description: BackendPool defines a load balancer backend pool.
719719
properties:
720720
id:
721721
type: string

controllers/azurecluster_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type AzureClusterReconciler struct {
5252
ReconcileTimeout time.Duration
5353
}
5454

55+
// SetupWithManager initializes this controller with a manager.
5556
func (r *AzureClusterReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error {
5657
log := r.Log.WithValues("controller", "AzureCluster")
5758
c, err := ctrl.NewControllerManagedBy(mgr).
@@ -82,6 +83,7 @@ func (r *AzureClusterReconciler) SetupWithManager(mgr ctrl.Manager, options cont
8283
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters;clusters/status,verbs=get;list;watch
8384
// +kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=azuremachinetemplates;azuremachinetemplates/status,verbs=get;list;watch
8485

86+
// Reconcile idempotently gets, creates, and updates a cluster.
8587
func (r *AzureClusterReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr error) {
8688
ctx, cancel := context.WithTimeout(context.Background(), reconciler.DefaultedLoopTimeout(r.ReconcileTimeout))
8789
defer cancel()

controllers/azurejson_machinetemplate_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type AzureJSONTemplateReconciler struct {
4747
ReconcileTimeout time.Duration
4848
}
4949

50-
// SetupWithManager initializes this controller with a manager
50+
// SetupWithManager initializes this controller with a manager.
5151
func (r *AzureJSONTemplateReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error {
5252
return ctrl.NewControllerManagedBy(mgr).
5353
WithOptions(options).

controllers/azuremachine_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type AzureMachineReconciler struct {
5252
ReconcileTimeout time.Duration
5353
}
5454

55+
// SetupWithManager initializes this controller with a manager.
5556
func (r *AzureMachineReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error {
5657
log := r.Log.WithValues("controller", "AzureMachine")
5758
// create mapper to transform incoming AzureClusters into AzureMachine requests
@@ -108,6 +109,7 @@ func (r *AzureMachineReconciler) SetupWithManager(mgr ctrl.Manager, options cont
108109
// +kubebuilder:rbac:groups="",resources=events,verbs=get;list;watch;create;update;patch
109110
// +kubebuilder:rbac:groups="",resources=secrets;,verbs=get;list;watch
110111

112+
// Reconcile idempotently gets, creates, and updates a machine.
111113
func (r *AzureMachineReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr error) {
112114
ctx, cancel := context.WithTimeout(context.Background(), reconciler.DefaultedLoopTimeout(r.ReconcileTimeout))
113115
defer cancel()

exp/api/v1alpha3/azuremachinepool_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
)
2525

2626
type (
27+
// AzureMachineTemplate defines the template for an AzureMachine.
2728
AzureMachineTemplate struct {
2829
// VMSize is the size of the Virtual Machine to build.
2930
// See https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#virtualmachinesizetypes

exp/api/v1alpha3/azuremachinepool_webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
// log is for logging in this package.
3333
var azuremachinepoollog = logf.Log.WithName("azuremachinepool-resource")
3434

35+
// SetupWebhookWithManager sets up and registers the webhook with the manager.
3536
func (amp *AzureMachinePool) SetupWebhookWithManager(mgr ctrl.Manager) error {
3637
return ctrl.NewWebhookManagedBy(mgr).
3738
For(amp).

exp/api/v1alpha3/azuremanagedcontrolplane_webhook.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var azuremanagedcontrolplanelog = logf.Log.WithName("azuremanagedcontrolplane-re
3636

3737
var kubeSemver = regexp.MustCompile(`^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)([-0-9a-zA-Z_\.+]*)?$`)
3838

39+
// SetupWebhookWithManager sets up and registers the webhook with the manager.
3940
func (r *AzureManagedControlPlane) SetupWebhookWithManager(mgr ctrl.Manager) error {
4041
return ctrl.NewWebhookManagedBy(mgr).
4142
For(r).

exp/api/v1alpha3/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
)
2222

2323
type (
24+
// VMSSVM defines a VM in a virtual machine scale set.
2425
VMSSVM struct {
2526
ID string `json:"id,omitempty"`
2627
InstanceID string `json:"instanceID,omitempty"`
@@ -29,6 +30,7 @@ type (
2930
State infrav1.VMState `json:"vmState,omitempty"`
3031
}
3132

33+
// VMSS defines a virtual machine scale set.
3234
VMSS struct {
3335
ID string `json:"id,omitempty"`
3436
Name string `json:"name,omitempty"`

exp/controllers/azuremachinepool_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ type (
6565
}
6666
)
6767

68+
// SetupWithManager initializes this controller with a manager.
6869
func (r *AzureMachinePoolReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error {
6970
log := r.Log.WithValues("controller", "AzureMachinePool")
7071
// create mapper to transform incoming AzureClusters into AzureMachinePool requests
@@ -120,6 +121,7 @@ func (r *AzureMachinePoolReconciler) SetupWithManager(mgr ctrl.Manager, options
120121
// +kubebuilder:rbac:groups="",resources=events,verbs=get;list;watch;create;update;patch
121122
// +kubebuilder:rbac:groups="",resources=secrets;,verbs=get;list;watch
122123

124+
// Reconcile idempotently gets, creates, and updates a machine pool.
123125
func (r *AzureMachinePoolReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr error) {
124126
ctx, cancel := context.WithTimeout(context.Background(), reconciler.DefaultedLoopTimeout(r.ReconcileTimeout))
125127
defer cancel()

exp/controllers/azuremanagedcluster_controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ type AzureManagedClusterReconciler struct {
4949
ReconcileTimeout time.Duration
5050
}
5151

52+
// SetupWithManager initializes this controller with a manager.
5253
func (r *AzureManagedClusterReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error {
5354
log := r.Log.WithValues("controller", "AzureManagedCluster")
5455
azManagedCluster := &infrav1exp.AzureManagedCluster{}
@@ -79,6 +80,7 @@ func (r *AzureManagedClusterReconciler) SetupWithManager(mgr ctrl.Manager, optio
7980
// +kubebuilder:rbac:groups=cluster.x-k8s.io,resources=clusters;clusters/status,verbs=get;list;watch
8081
// +kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;patch;delete
8182

83+
// Reconcile idempotently gets, creates, and updates a managed cluster.
8284
func (r *AzureManagedClusterReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr error) {
8385
ctx, cancel := context.WithTimeout(context.Background(), reconciler.DefaultedLoopTimeout(r.ReconcileTimeout))
8486
defer cancel()

0 commit comments

Comments
 (0)