Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@0a35821d5c230e903fcfe077583637dea1b27b47 # tag=v9.0.0
with:
version: v2.1.0
version: v2.7.0
working-directory: ${{matrix.working-directory}}
- name: Lint API
run: make lint-api
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,38 @@ linters:
path: .*(api|types|test)\/.*\/.*conversion.*\.go$
# This rule warns when initialism, variable or package naming conventions are not followed.
text: "var-naming: don't use underscores in Go names"
- linters:
- revive
path: 'exp/utils/*'
text: 'var-naming: avoid meaningless package names'
- linters:
- revive
path: 'cmd/clusterawsadm/cmd/ami/common'
text: 'var-naming: avoid meaningless package names'
- linters:
- revive
path: 'cmd/clusterawsadm/cmd/util'
text: 'var-naming: avoid meaningless package names'
- linters:
- revive
path: 'pkg/utils'
text: 'var-naming: avoid meaningless package names'
- linters:
- revive
path: 'pkg/cloud/services/common/'
text: 'var-naming: avoid meaningless package names'
- linters:
- revive
path: 'test/e2e/shared/'
text: 'var-naming: avoid meaningless package names'
- linters:
- revive
text: 'avoid package names that conflict with Go standard library package names'
path: 'pkg/internal/bytes/'
- linters:
- revive
text: 'avoid package names that conflict with Go standard library package names'
path: 'pkg/hash/'
- linters:
- unparam
text: always receives
Expand Down Expand Up @@ -330,6 +362,9 @@ linters:
- linters:
- staticcheck
text: 'SA1019: "sigs.k8s.io/cluster-api/(.*)" is deprecated: This package is deprecated and is going to be removed when support for v1beta1 will be dropped.'
- linters:
- staticcheck
text: "s.scope.ControlPlaneLoadBalancer is deprecated"
Comment on lines +365 to +367
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should remove this ignore and address the actual method change to the new one in a later pr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create an issue, if there's not one? 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paths:
- third_party$
- builtin$
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type AWSResourceReference struct {

// ARN of resource.
// +optional
//
// Deprecated: This field has no function and is going to be removed in the next release.
ARN *string `json:"arn,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ spec:
arn:
description: |-
ARN of resource.

Deprecated: This field has no function and is going to be removed in the next release.
type: string
filters:
Expand Down Expand Up @@ -344,6 +345,7 @@ spec:
arn:
description: |-
ARN of resource.

Deprecated: This field has no function and is going to be removed in the next release.
type: string
filters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ spec:
arn:
description: |-
ARN of resource.

Deprecated: This field has no function and is going to be removed in the next release.
type: string
filters:
Expand Down Expand Up @@ -360,6 +361,7 @@ spec:
arn:
description: |-
ARN of resource.

Deprecated: This field has no function and is going to be removed in the next release.
type: string
filters:
Expand Down
2 changes: 1 addition & 1 deletion hack/tools/.custom-gcl.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: v2.1.0
version: v2.7.0
name: golangci-lint-kube-api-linter
destination: ./bin
plugins:
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/converters/eks.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ func NodegroupUpdateconfigToSDK(updateConfig *expinfrav1.UpdateConfig) (*ekstype

converted := &ekstypes.NodegroupUpdateConfig{}
if updateConfig.MaxUnavailable != nil {
//nolint:gosec,G115 // Added golint exception as there is a kubebuilder validation configured
//nolint:G115 // Added golint exception as there is a kubebuilder validation configured
converted.MaxUnavailable = aws.Int32(int32(*updateConfig.MaxUnavailable))
}
if updateConfig.MaxUnavailablePercentage != nil {
//nolint:gosec,G115 // Added golint exception as there is a kubebuilder validation configured
//nolint:G115 // Added golint exception as there is a kubebuilder validation configured
converted.MaxUnavailablePercentage = aws.Int32(int32(*updateConfig.MaxUnavailablePercentage))
}

Expand Down
1 change: 1 addition & 0 deletions pkg/cloud/scope/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func (s *ClusterScope) ControlPlaneLoadBalancers() []*infrav1.AWSLoadBalancerSpe
}

// ControlPlaneLoadBalancerScheme returns the Classic ELB scheme (public or internal facing).
//
// Deprecated: This method is going to be removed in a future release. Use LoadBalancer.Scheme.
func (s *ClusterScope) ControlPlaneLoadBalancerScheme() infrav1.ELBScheme {
if s.ControlPlaneLoadBalancer() != nil && s.ControlPlaneLoadBalancer().Scheme != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/cloud/scope/elb.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ type ELBScope interface {
VPC() *infrav1.VPCSpec

// ControlPlaneLoadBalancer returns the AWSLoadBalancerSpec
//
// Deprecated: Use ControlPlaneLoadBalancers()
ControlPlaneLoadBalancer() *infrav1.AWSLoadBalancerSpec

// ControlPlaneLoadBalancerScheme returns the Classic ELB scheme (public or internal facing)
//
// Deprecated: This method is going to be removed in a future release. Use LoadBalancer.Scheme.
ControlPlaneLoadBalancerScheme() infrav1.ELBScheme

Expand Down
1 change: 1 addition & 0 deletions pkg/cloud/scope/sg.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type SGScope interface {
Bastion() *infrav1.Bastion

// ControlPlaneLoadBalancer returns the load balancer settings that are requested.
//
// Deprecated: Use ControlPlaneLoadBalancers()
ControlPlaneLoadBalancer() *infrav1.AWSLoadBalancerSpec

Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/services/ec2/dedicatedhosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (s *Service) convertToHostInfo(host types.Host) *infrav1.DedicatedHostInfo
instanceCount = math.MaxInt32
}
// bounds check ensures instanceCount <= math.MaxInt32, preventing integer overflow
usedCapacity := int32(instanceCount) //nolint:gosec
usedCapacity := int32(instanceCount)
hostInfo.AvailableCapacity = hostInfo.TotalCapacity - usedCapacity

// Convert tags
Expand Down
2 changes: 1 addition & 1 deletion pkg/cloud/services/ec2/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ func (s *Service) runInstance(role string, i *infrav1.Instance) (*infrav1.Instan
for index, id := range i.NetworkInterfaces {
netInterfaces = append(netInterfaces, types.InstanceNetworkInterfaceSpecification{
NetworkInterfaceId: aws.String(id),
DeviceIndex: aws.Int32(int32(index)), //nolint:gosec // disable G115
DeviceIndex: aws.Int32(int32(index)),
})
}
netInterfaces[0].AssociatePublicIpAddress = i.PublicIPOnLaunch
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/shared/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ func ensureTestImageUploaded(ctx context.Context, e2eCtx *E2EContext) error {
return err
}

cmd := exec.Command("docker", "inspect", "--format='{{index .Id}}'", "gcr.io/k8s-staging-cluster-api/capa-manager:e2e")
cmd := exec.CommandContext(ctx, "docker", "inspect", "--format='{{index .Id}}'", "gcr.io/k8s-staging-cluster-api/capa-manager:e2e")
var stdOut bytes.Buffer
cmd.Stdout = &stdOut
err := cmd.Run()
Expand All @@ -775,7 +775,7 @@ func ensureTestImageUploaded(ctx context.Context, e2eCtx *E2EContext) error {
imageSha := strings.ReplaceAll(strings.TrimSuffix(stdOut.String(), "\n"), "'", "")

ecrImageName := repoName + ":e2e"
cmd = exec.Command("docker", "tag", imageSha, ecrImageName) //nolint:gosec
cmd = exec.CommandContext(ctx, "docker", "tag", imageSha, ecrImageName) //nolint:gosec
err = cmd.Run()
if err != nil {
return err
Expand All @@ -794,13 +794,13 @@ func ensureTestImageUploaded(ctx context.Context, e2eCtx *E2EContext) error {
return errors.New("failed to decode ECR authentication token")
}

cmd = exec.Command("docker", "login", "--username", strList[0], "--password", strList[1], "public.ecr.aws") //nolint:gosec
cmd = exec.CommandContext(ctx, "docker", "login", "--username", strList[0], "--password", strList[1], "public.ecr.aws") //nolint:gosec
err = cmd.Run()
if err != nil {
return err
}

cmd = exec.Command("docker", "push", ecrImageName)
cmd = exec.CommandContext(ctx, "docker", "push", ecrImageName)
err = cmd.Run()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/shared/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func Node1BeforeSuite(e2eCtx *E2EContext) []byte {
templateDir := path.Join(e2eCtx.Settings.ArtifactFolder, "templates")
newTemplatePath := templateDir + "/" + ciTemplateForUpgradeName

err = exec.Command("cp", ciTemplateForUpgradePath, newTemplatePath).Run() //nolint:gosec
err = exec.CommandContext(context.TODO(), "cp", ciTemplateForUpgradePath, newTemplatePath).Run() //nolint:gosec
Expect(err).NotTo(HaveOccurred())

clusterctlCITemplateForUpgrade := clusterctl.Files{
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/envtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ func (t *TestEnvironment) WaitForWebhooks() {
timeout := 1 * time.Second
for {
time.Sleep(1 * time.Second)
conn, err := net.DialTimeout("tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(port)), timeout)
dialer := &net.Dialer{Timeout: timeout}
conn, err := dialer.DialContext(context.Background(), "tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(port)))
if err != nil {
klog.V(2).Infof("Webhook port is not ready, will retry in %v: %s", timeout, err)
continue
Expand Down
3 changes: 2 additions & 1 deletion test/helpers/kubernetesversions/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package kubernetesversions

import (
"bytes"
"context"
_ "embed"
"errors"
"fmt"
Expand Down Expand Up @@ -128,7 +129,7 @@ func GenerateCIArtifactsInjectedTemplateForDebian(input GenerateCIArtifactsInjec
if err := os.WriteFile(path.Join(overlayDir, "platform-kustomization.yaml"), input.PlatformKustomization, 0o600); err != nil {
return "", err
}
cmd := exec.Command("kustomize", "build", overlayDir) //nolint:gosec // We don't care about command injection here.
cmd := exec.CommandContext(context.TODO(), "kustomize", "build", overlayDir) //nolint:gosec // We don't care about command injection here.
data, err := cmd.CombinedOutput()
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion versions.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ CERT_MANAGER_VERSION := v1.17.2
CAPI_VERSION := v1.11.1
KPROMO_VERSION := v4.0.5
YQ_VERSION := v4.25.2
GOLANGCI_LINT_VERSION := v2.1.0
GOLANGCI_LINT_VERSION := v2.7.0
RELEASE_NOTES_VERSION := v0.16.5
GORELEASER_VERSION := v1.24.0