Skip to content

Commit 1835bfa

Browse files
committed
fix lint error
Signed-off-by: sivchari <[email protected]>
1 parent 7a537f9 commit 1835bfa

File tree

113 files changed

+302
-364
lines changed

Some content is hidden

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

113 files changed

+302
-364
lines changed

bootstrap/kubeadm/internal/cloudinit/controlplane_init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type ControlPlaneInput struct {
6060
// NewInitControlPlane returns the user data string to be used on a controlplane instance.
6161
func NewInitControlPlane(input *ControlPlaneInput) ([]byte, error) {
6262
input.Header = cloudConfigHeader
63-
input.WriteFiles = input.Certificates.AsFiles()
63+
input.WriteFiles = input.AsFiles()
6464
input.WriteFiles = append(input.WriteFiles, input.AdditionalFiles...)
6565
input.SentinelFileCommand = sentinelFileCommand
6666
userData, err := generate("InitControlplane", controlPlaneCloudInit, input)

bootstrap/kubeadm/internal/cloudinit/controlplane_join.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type ControlPlaneJoinInput struct {
5858
// NewJoinControlPlane returns the user data string to be used on a new control plane instance.
5959
func NewJoinControlPlane(input *ControlPlaneJoinInput) ([]byte, error) {
6060
// TODO: Consider validating that the correct certificates exist. It is different for external/stacked etcd
61-
input.WriteFiles = input.Certificates.AsFiles()
61+
input.WriteFiles = input.AsFiles()
6262
input.ControlPlane = true
6363
if err := input.prepare(); err != nil {
6464
return nil, err

bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,7 +2646,7 @@ func addKubeadmConfigToMachine(config *bootstrapv1.KubeadmConfig, machine *clust
26462646
if machine == nil {
26472647
panic("no machine passed to function")
26482648
}
2649-
config.ObjectMeta.OwnerReferences = []metav1.OwnerReference{
2649+
config.OwnerReferences = []metav1.OwnerReference{
26502650
{
26512651
Kind: "Machine",
26522652
APIVersion: clusterv1.GroupVersion.String(),
@@ -2668,7 +2668,7 @@ func addKubeadmConfigToMachinePool(config *bootstrapv1.KubeadmConfig, machinePoo
26682668
if machinePool == nil {
26692669
panic("no machinePool passed to function")
26702670
}
2671-
config.ObjectMeta.OwnerReferences = []metav1.OwnerReference{
2671+
config.OwnerReferences = []metav1.OwnerReference{
26722672
{
26732673
Kind: "MachinePool",
26742674
APIVersion: expv1.GroupVersion.String(),

bootstrap/kubeadm/internal/ignition/ignition.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func NewJoinControlPlane(input *ControlPlaneJoinInput) ([]byte, string, error) {
7979
return nil, "", fmt.Errorf("controlplane join input can't be nil")
8080
}
8181

82-
input.WriteFiles = input.Certificates.AsFiles()
82+
input.WriteFiles = input.AsFiles()
8383
input.WriteFiles = append(input.WriteFiles, input.AdditionalFiles...)
8484
input.KubeadmCommand = fmt.Sprintf(kubeadmCommandTemplate, joinSubcommand, input.KubeadmVerbosity)
8585

@@ -96,7 +96,7 @@ func NewInitControlPlane(input *ControlPlaneInput) ([]byte, string, error) {
9696
return nil, "", fmt.Errorf("controlplane input can't be nil")
9797
}
9898

99-
input.WriteFiles = input.Certificates.AsFiles()
99+
input.WriteFiles = input.AsFiles()
100100
input.WriteFiles = append(input.WriteFiles, input.AdditionalFiles...)
101101
input.KubeadmCommand = fmt.Sprintf(kubeadmCommandTemplate, initSubcommand, input.KubeadmVerbosity)
102102

bootstrap/kubeadm/types/upstreamv1beta4/bootstraptokenstring.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (bts *BootstrapTokenString) UnmarshalJSON(b []byte) error {
5959
}
6060

6161
// Remove unnecessary " characters coming from the JSON parser
62-
token := strings.Replace(string(b), `"`, ``, -1)
62+
token := strings.ReplaceAll(string(b), `"`, ``)
6363
// Convert the string Token to a BootstrapTokenString object
6464
newbts, err := NewBootstrapTokenString(token)
6565
if err != nil {

cmd/clusterctl/client/alpha/machinedeployment.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ func findMachineDeploymentRevision(toRevision int64, allMSs []*clusterv1.Machine
9191
)
9292
for _, ms := range allMSs {
9393
if v, err := revision(ms); err == nil {
94-
if toRevision == 0 {
94+
switch toRevision {
95+
case 0:
9596
if latestRevision < v {
9697
// newest one we've seen so far
9798
previousRevision = latestRevision
@@ -103,7 +104,7 @@ func findMachineDeploymentRevision(toRevision int64, allMSs []*clusterv1.Machine
103104
previousRevision = v
104105
previousMachineSet = ms
105106
}
106-
} else if toRevision == v {
107+
case v:
107108
return ms, nil
108109
}
109110
}

cmd/clusterctl/client/alpha/rollout_resumer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func resumeMachineDeployment(ctx context.Context, proxy cluster.Proxy, name, nam
7272
// resumeKubeadmControlPlane removes paused annotation.
7373
func resumeKubeadmControlPlane(ctx context.Context, proxy cluster.Proxy, name, namespace string) error {
7474
// In the paused annotation we must replace slashes to ~1, see https://datatracker.ietf.org/doc/html/rfc6901#section-3.
75-
pausedAnnotation := strings.Replace(clusterv1.PausedAnnotation, "/", "~1", -1)
75+
pausedAnnotation := strings.ReplaceAll(clusterv1.PausedAnnotation, "/", "~1")
7676
patch := client.RawPatch(types.JSONPatchType, []byte(fmt.Sprintf("[{\"op\": \"remove\", \"path\": \"/metadata/annotations/%s\"}]", pausedAnnotation)))
7777

7878
return patchKubeadmControlPlane(ctx, proxy, name, namespace, patch)

cmd/clusterctl/client/cluster/cert_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func (cm *certManagerClient) shouldUpgrade(desiredVersion string, objs, installO
347347
// the number of objects when version of objects are equal
348348
relevantObjs := []unstructured.Unstructured{}
349349
for _, o := range objs {
350-
if !(o.GetKind() == "Endpoints" || o.GetKind() == "EndpointSlice") {
350+
if o.GetKind() != "Endpoints" && o.GetKind() != "EndpointSlice" {
351351
relevantObjs = append(relevantObjs, o)
352352
}
353353
}

cmd/clusterctl/client/cluster/components_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ func Test_providerComponents_ValidateNoObjectsExist(t *testing.T) {
522522
},
523523
},
524524
}
525-
crd.ObjectMeta.Labels[clusterctlv1.ClusterctlLabel] = ""
525+
crd.Labels[clusterctlv1.ClusterctlLabel] = ""
526526

527527
cr := &unstructured.Unstructured{}
528528
cr.SetAPIVersion("some.group/v1")

cmd/clusterctl/client/cluster/mover_test.go

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,8 @@ var backupRestoreTests = []struct {
726726
}
727727

728728
func fixFilesGVS(file string) string {
729-
s := strings.Replace(file, "$CAPI", clusterv1.GroupVersion.String(), -1)
730-
return strings.Replace(s, "$INFRA", clusterv1.GroupVersionInfrastructure.String(), -1)
729+
s := strings.ReplaceAll(file, "$CAPI", clusterv1.GroupVersion.String())
730+
return strings.ReplaceAll(s, "$INFRA", clusterv1.GroupVersionInfrastructure.String())
731731
}
732732

733733
func Test_objectMover_backupTargetObject(t *testing.T) {
@@ -752,14 +752,10 @@ func Test_objectMover_backupTargetObject(t *testing.T) {
752752
fromProxy: graph.proxy,
753753
}
754754

755-
dir, err := os.MkdirTemp("/tmp", "cluster-api")
756-
if err != nil {
757-
t.Error(err)
758-
}
759-
defer os.RemoveAll(dir)
755+
dir := t.TempDir()
760756

761757
for _, node := range graph.uidToNode {
762-
err = mover.backupTargetObject(ctx, node, dir)
758+
err := mover.backupTargetObject(ctx, node, dir)
763759
if tt.wantErr {
764760
g.Expect(err).To(HaveOccurred())
765761
return
@@ -823,12 +819,7 @@ func Test_objectMover_restoreTargetObject(t *testing.T) {
823819

824820
ctx := context.Background()
825821

826-
// temporary directory
827-
dir, err := os.MkdirTemp("/tmp", "cluster-api")
828-
if err != nil {
829-
g.Expect(err).ToNot(HaveOccurred())
830-
}
831-
defer os.RemoveAll(dir)
822+
dir := t.TempDir()
832823

833824
// Create an objectGraph bound a source cluster with all the CRDs for the types involved in the test.
834825
graph := getObjectGraph()
@@ -952,13 +943,9 @@ func Test_objectMover_toDirectory(t *testing.T) {
952943
fromProxy: graph.proxy,
953944
}
954945

955-
dir, err := os.MkdirTemp("/tmp", "cluster-api")
956-
if err != nil {
957-
t.Error(err)
958-
}
959-
defer os.RemoveAll(dir)
946+
dir := t.TempDir()
960947

961-
err = mover.toDirectory(ctx, graph, dir)
948+
err := mover.toDirectory(ctx, graph, dir)
962949
if tt.wantErr {
963950
g.Expect(err).To(HaveOccurred())
964951
return
@@ -1013,11 +1000,7 @@ func Test_objectMover_filesToObjs(t *testing.T) {
10131000
t.Run(tt.name, func(t *testing.T) {
10141001
g := NewWithT(t)
10151002

1016-
dir, err := os.MkdirTemp("/tmp", "cluster-api")
1017-
if err != nil {
1018-
t.Error(err)
1019-
}
1020-
defer os.RemoveAll(dir)
1003+
dir := t.TempDir()
10211004

10221005
for _, fileName := range tt.files {
10231006
path := filepath.Join(dir, fileName)
@@ -1074,12 +1057,7 @@ func Test_objectMover_fromDirectory(t *testing.T) {
10741057

10751058
ctx := context.Background()
10761059

1077-
// temporary directory
1078-
dir, err := os.MkdirTemp("/tmp", "cluster-api")
1079-
if err != nil {
1080-
g.Expect(err).ToNot(HaveOccurred())
1081-
}
1082-
defer os.RemoveAll(dir)
1060+
dir := t.TempDir()
10831061

10841062
// Create an objectGraph bound a source cluster with all the CRDs for the types involved in the test.
10851063
graph := getObjectGraph()

0 commit comments

Comments
 (0)