Skip to content

Commit a992b1d

Browse files
committed
fix linting, deprecations, remove capierrors
1 parent 3150693 commit a992b1d

File tree

79 files changed

+319
-771
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+319
-771
lines changed

api/v1beta1/awsmachine_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

2222
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
23-
"sigs.k8s.io/cluster-api/errors"
2423
)
2524

2625
const (
@@ -231,7 +230,7 @@ type AWSMachineStatus struct {
231230
// can be added as events to the Machine object and/or logged in the
232231
// controller's output.
233232
// +optional
234-
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
233+
FailureReason *string `json:"failureReason,omitempty"`
235234

236235
// FailureMessage will be set in the event that there is a terminal problem
237236
// reconciling the Machine and will contain a more verbose string suitable

api/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta2/awscluster_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ func TestAWSClusterValidateCreate(t *testing.T) {
663663
}
664664
for _, tt := range tests {
665665
t.Run(tt.name, func(t *testing.T) {
666-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.BootstrapFormatIgnition, true)()
666+
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.BootstrapFormatIgnition, true)
667667

668668
cluster := tt.cluster.DeepCopy()
669669
cluster.ObjectMeta = metav1.ObjectMeta{

api/v1beta2/awsmachine_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121

2222
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
23-
"sigs.k8s.io/cluster-api/errors"
2423
)
2524

2625
const (
@@ -352,7 +351,7 @@ type AWSMachineStatus struct {
352351
// can be added as events to the Machine object and/or logged in the
353352
// controller's output.
354353
// +optional
355-
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
354+
FailureReason *string `json:"failureReason,omitempty"`
356355

357356
// FailureMessage will be set in the event that there is a terminal problem
358357
// reconciling the Machine and will contain a more verbose string suitable

api/v1beta2/awsmachine_webhook_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ func TestAWSMachineCreate(t *testing.T) {
439439
}
440440
for _, tt := range tests {
441441
t.Run(tt.name, func(t *testing.T) {
442-
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.BootstrapFormatIgnition, true)()
442+
defer utilfeature.SetFeatureGateDuringTest(t, feature.Gates, feature.BootstrapFormatIgnition, true)
443443

444444
machine := tt.machine.DeepCopy()
445445
machine.ObjectMeta = metav1.ObjectMeta{

api/v1beta2/zz_generated.deepcopy.go

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bootstrap/eks/controllers/eksconfig_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func (r *EKSConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
294294
b := ctrl.NewControllerManagedBy(mgr).
295295
For(&eksbootstrapv1.EKSConfig{}).
296296
WithOptions(option).
297-
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(logger.FromContext(ctx).GetLogger(), r.WatchFilterValue)).
297+
WithEventFilter(predicates.ResourceNotPausedAndHasFilterLabel(mgr.GetScheme(), logger.FromContext(ctx).GetLogger(), r.WatchFilterValue)).
298298
Watches(
299299
&clusterv1.Machine{},
300300
handler.EnqueueRequestsFromMapFunc(r.MachineToBootstrapMapFunc),
@@ -315,7 +315,7 @@ func (r *EKSConfigReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Man
315315
err = c.Watch(
316316
source.Kind[client.Object](mgr.GetCache(), &clusterv1.Cluster{},
317317
handler.EnqueueRequestsFromMapFunc((r.ClusterToEKSConfigs)),
318-
predicates.ClusterUnpausedAndInfrastructureReady(logger.FromContext(ctx).GetLogger())),
318+
predicates.ClusterPausedTransitionsOrInfrastructureReady(mgr.GetScheme(), logger.FromContext(ctx).GetLogger())),
319319
)
320320
if err != nil {
321321
return errors.Wrap(err, "failed adding watch for Clusters to controller manager")

cmd/clusterawsadm/cmd/ami/ami.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package ami
1919

2020
import (
2121
"github.com/spf13/cobra"
22+
"k8s.io/kubectl/pkg/util/templates"
2223

2324
cm "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/ami/common"
2425
ls "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/ami/list"
25-
"sigs.k8s.io/cluster-api/cmd/clusterctl/cmd"
2626
)
2727

2828
// RootCmd is the root of the `ami command`.
@@ -31,7 +31,7 @@ func RootCmd() *cobra.Command {
3131
Use: "ami [command]",
3232
Short: "AMI commands",
3333
Args: cobra.NoArgs,
34-
Long: cmd.LongDesc(`
34+
Long: templates.LongDesc(`
3535
All AMI related actions such as:
3636
# Copy AMIs based on Kubernetes version, OS etc from an AWS account where AMIs are stored
3737
to the current AWS account (use case: air-gapped deployments)

cmd/clusterawsadm/cmd/ami/common/copy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import (
2121
"os"
2222

2323
"github.com/spf13/cobra"
24+
"k8s.io/kubectl/pkg/util/templates"
2425

2526
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/ami"
2627
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/flags"
2728
cmdout "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/printers"
28-
"sigs.k8s.io/cluster-api/cmd/clusterctl/cmd"
2929
logf "sigs.k8s.io/cluster-api/cmd/clusterctl/log"
3030
)
3131

@@ -34,11 +34,11 @@ func CopyAMICmd() *cobra.Command {
3434
newCmd := &cobra.Command{
3535
Use: "copy",
3636
Short: "Copy AMIs from an AWS account to the AWS account which credentials are provided",
37-
Long: cmd.LongDesc(`
37+
Long: templates.LongDesc(`
3838
Copy AMIs based on Kubernetes version, OS, region from an AWS account where AMIs are stored
3939
to the current AWS account (use case: air-gapped deployments)
4040
`),
41-
Example: cmd.Examples(`
41+
Example: templates.Examples(`
4242
# Copy AMI from the default AWS account where AMIs are stored.
4343
# Available os options: centos-7, ubuntu-24.04, ubuntu-22.04, amazon-2, flatcar-stable
4444
clusterawsadm ami copy --kubernetes-version=v1.30.1 --os=ubuntu-22.04 --region=us-west-2

cmd/clusterawsadm/cmd/ami/common/encryptedcopy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121
"os"
2222

2323
"github.com/spf13/cobra"
24+
"k8s.io/kubectl/pkg/util/templates"
2425
ctrl "sigs.k8s.io/controller-runtime"
2526

2627
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/ami"
2728
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/flags"
2829
cmdout "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/printers"
29-
"sigs.k8s.io/cluster-api/cmd/clusterctl/cmd"
3030
)
3131

3232
var (
@@ -38,12 +38,12 @@ func EncryptedCopyAMICmd() *cobra.Command {
3838
newCmd := &cobra.Command{
3939
Use: "encrypted-copy",
4040
Short: "Encrypt and copy AMI snapshot, then create an AMI with that snapshot",
41-
Long: cmd.LongDesc(`
41+
Long: templates.LongDesc(`
4242
Find the AMI based on Kubernetes version, OS, region in the AWS account where AMIs are stored.
4343
Encrypt and copy the snapshot of the AMI to the current AWS account.
4444
Create an AMI with that snapshot.
4545
`),
46-
Example: cmd.Examples(`
46+
Example: templates.Examples(`
4747
# Create an encrypted AMI:
4848
# Available os options: centos-7, ubuntu-24.04, ubuntu-22.04, amazon-2, flatcar-stable
4949
clusterawsadm ami encrypted-copy --kubernetes-version=v1.18.12 --os=ubuntu-20.04 --region=us-west-2

cmd/clusterawsadm/cmd/ami/list/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ import (
2222
"os"
2323

2424
"github.com/spf13/cobra"
25+
"k8s.io/kubectl/pkg/util/templates"
2526

2627
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/ami"
2728
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/flags"
2829
cmdout "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/printers"
29-
"sigs.k8s.io/cluster-api/cmd/clusterctl/cmd"
3030
)
3131

3232
var (
@@ -41,15 +41,15 @@ func ListAMICmd() *cobra.Command {
4141
newCmd := &cobra.Command{
4242
Use: "list",
4343
Short: "List AMIs from the default AWS account where AMIs are stored",
44-
Long: cmd.LongDesc(`
44+
Long: templates.LongDesc(`
4545
List AMIs based on Kubernetes version, OS, region. If no arguments are provided,
4646
it will print all AMIs in all regions, OS types for the supported Kubernetes versions.
4747
Supported Kubernetes versions start from the latest stable version and goes 2 release back:
4848
if the latest stable release is v1.20.4- v1.19.x and v1.18.x are supported.
4949
Note: First release of each version will be skipped, e.g., v1.21.0
5050
To list AMIs of unsupported Kubernetes versions, --kubernetes-version flag needs to be provided.
5151
`),
52-
Example: cmd.Examples(`
52+
Example: templates.Examples(`
5353
# List AMIs from the default AWS account where AMIs are stored.
5454
# Available os options: centos-7, ubuntu-24.04, ubuntu-22.04, amazon-2, flatcar-stable
5555
clusterawsadm ami list --kubernetes-version=v1.18.12 --os=ubuntu-20.04 --region=us-west-2

cmd/clusterawsadm/cmd/bootstrap/bootstrap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ package bootstrap
2020

2121
import (
2222
"github.com/spf13/cobra"
23+
"k8s.io/kubectl/pkg/util/templates"
2324

2425
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/bootstrap/credentials"
2526
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/bootstrap/iam"
26-
"sigs.k8s.io/cluster-api/cmd/clusterctl/cmd"
2727
)
2828

2929
// RootCmd is the root of the `alpha bootstrap command`.
@@ -32,7 +32,7 @@ func RootCmd() *cobra.Command {
3232
Use: "bootstrap [command]",
3333
Short: "bootstrap commands",
3434
Args: cobra.NoArgs,
35-
Long: cmd.LongDesc(`
35+
Long: templates.LongDesc(`
3636
In order to use Kubernetes Cluster API Provider AWS, an AWS account needs to
3737
be prepared with AWS Identity and Access Management (IAM) roles to be used by
3838
clusters as well as provide Kubernetes Cluster API Provider AWS with credentials

cmd/clusterawsadm/cmd/bootstrap/credentials/credentials.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import (
2323
"os"
2424

2525
"github.com/spf13/cobra"
26+
"k8s.io/kubectl/pkg/util/templates"
2627

2728
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/flags"
2829
creds "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/credentials"
29-
"sigs.k8s.io/cluster-api/cmd/clusterctl/cmd"
3030
)
3131

3232
const (
@@ -86,10 +86,10 @@ func RootCmd() *cobra.Command {
8686
newCmd := &cobra.Command{
8787
Use: "credentials",
8888
Short: `Encode credentials to use with Kubernetes Cluster API Provider AWS`,
89-
Long: cmd.LongDesc(`
89+
Long: templates.LongDesc(`
9090
Encode credentials to use with Kubernetes Cluster API Provider AWS.
9191
` + CredentialHelp + EncodingHelp),
92-
Example: cmd.Examples(examples),
92+
Example: templates.Examples(examples),
9393
RunE: func(cmd *cobra.Command, args []string) error {
9494
return cmd.Help()
9595
},
@@ -113,10 +113,10 @@ func generateAWSDefaultProfileWithChain() *cobra.Command {
113113
newCmd := &cobra.Command{
114114
Use: "encode-as-profile",
115115
Short: "Generate an AWS profile from the current environment",
116-
Long: cmd.LongDesc(`
116+
Long: templates.LongDesc(`
117117
Generate an AWS profile from the current environment for the ephemeral bootstrap cluster.
118118
` + CredentialHelp + EncodingHelp),
119-
Example: cmd.Examples(examples),
119+
Example: templates.Examples(examples),
120120
RunE: func(c *cobra.Command, args []string) error {
121121
flags.CredentialWarning(c)
122122

cmd/clusterawsadm/cmd/bootstrap/iam/cloudformation.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ import (
2323
"github.com/aws/aws-sdk-go/aws/session"
2424
cfn "github.com/aws/aws-sdk-go/service/cloudformation"
2525
"github.com/spf13/cobra"
26+
"k8s.io/kubectl/pkg/util/templates"
2627

2728
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cloudformation/bootstrap"
2829
cloudformation "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cloudformation/service"
2930
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/bootstrap/credentials"
3031
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cmd/flags"
31-
"sigs.k8s.io/cluster-api/cmd/clusterctl/cmd"
3232
)
3333

3434
func printCloudFormationTemplateCmd() *cobra.Command {
3535
newCmd := &cobra.Command{
3636
Use: "print-cloudformation-template",
3737
Short: "Print cloudformation template",
38-
Long: cmd.LongDesc(`
38+
Long: templates.LongDesc(`
3939
Generate and print out a CloudFormation template that can be used to
4040
provision AWS Identity and Access Management (IAM) policies and roles for use
4141
with Kubernetes Cluster API Provider AWS.
4242
`),
43-
Example: cmd.Examples(`
43+
Example: templates.Examples(`
4444
# Print out the default CloudFormation template.
4545
clusterawsadm bootstrap iam print-cloudformation-template
4646
@@ -75,12 +75,12 @@ func createCloudFormationStackCmd() *cobra.Command {
7575
Aliases: []string{"update-cloudformation-stack"},
7676
Short: "Create or update an AWS CloudFormation stack",
7777
Args: cobra.NoArgs,
78-
Long: cmd.LongDesc(`
78+
Long: templates.LongDesc(`
7979
Create or update an AWS CloudFormation stack for bootstrapping Kubernetes Cluster
8080
API and Kubernetes AWS Identity and Access Management (IAM) permissions. To use this
8181
command, there must be AWS credentials loaded in this environment.
8282
` + credentials.CredentialHelp),
83-
Example: cmd.Examples(`
83+
Example: templates.Examples(`
8484
# Create or update IAM roles and policies for Kubernetes using a AWS CloudFormation stack.
8585
clusterawsadm bootstrap iam create-cloudformation-stack
8686
@@ -128,7 +128,7 @@ func deleteCloudFormationStackCmd() *cobra.Command {
128128
Use: "delete-cloudformation-stack",
129129
Short: "Delete an AWS CloudFormation stack",
130130
Args: cobra.NoArgs,
131-
Long: cmd.LongDesc(`
131+
Long: templates.LongDesc(`
132132
Delete the AWS CloudFormation stack that created AWS Identity and Access
133133
Management (IAM) resources for use with Kubernetes Cluster API Provider
134134
AWS.

cmd/clusterawsadm/cmd/bootstrap/iam/config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@ import (
2020
"fmt"
2121

2222
"github.com/spf13/cobra"
23+
"k8s.io/kubectl/pkg/util/templates"
2324
"sigs.k8s.io/yaml"
2425

2526
bootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/api/bootstrap/v1beta1"
2627
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/cloudformation/bootstrap"
2728
"sigs.k8s.io/cluster-api-provider-aws/v2/cmd/clusterawsadm/configreader"
28-
"sigs.k8s.io/cluster-api/cmd/clusterctl/cmd"
2929
)
3030

3131
func printConfigCmd() *cobra.Command {
3232
newCmd := &cobra.Command{
3333
Use: "print-config",
3434
Short: "Print configuration",
35-
Long: cmd.LongDesc("Print configuration"),
36-
Example: cmd.Examples(`
35+
Long: templates.LongDesc("Print configuration"),
36+
Example: templates.Examples(`
3737
# Print the default configuration.
3838
clusterawsadm bootstrap iam print-config
3939
@@ -83,7 +83,7 @@ func getBootstrapTemplate(cmd *cobra.Command) (*bootstrap.Template, error) {
8383
}
8484

8585
func addConfigFlag(c *cobra.Command) {
86-
c.Flags().String("config", "", cmd.LongDesc(`
86+
c.Flags().String("config", "", templates.LongDesc(`
8787
clusterawsadm will load a bootstrap configuration from this file. The path may be
8888
absolute or relative; relative paths start at the current working directory.
8989

0 commit comments

Comments
 (0)