Skip to content

Commit 4cc36da

Browse files
authored
Merge pull request #4384 from monteiro-renato/patch-2
🐛 : (go/v4) fixes based on golangci-lint run -v
2 parents ab96f9a + 867ccdd commit 4cc36da

File tree

31 files changed

+88
-88
lines changed

31 files changed

+88
-88
lines changed

docs/book/src/cronjob-tutorial/testdata/project/internal/webhook/v1/cronjob_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ This marker is responsible for generating a validation webhook manifest.
162162
// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods,
163163
// as this struct is used only for temporary operations and does not need to be deeply copied.
164164
type CronJobCustomValidator struct {
165-
//TODO(user): Add more fields as needed for validation
165+
// TODO(user): Add more fields as needed for validation
166166
}
167167

168168
var _ webhook.CustomValidator = &CronJobCustomValidator{}

docs/book/src/cronjob-tutorial/testdata/project/test/e2e/e2e_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ var _ = Describe("Manager", Ordered, func() {
9393
cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace)
9494
controllerLogs, err := utils.Run(cmd)
9595
if err == nil {
96-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Controller logs:\n %s", controllerLogs))
96+
_, _ = fmt.Fprintf(GinkgoWriter, "Controller logs:\n %s", controllerLogs)
9797
} else {
98-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Controller logs: %s", err))
98+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get Controller logs: %s", err)
9999
}
100100

101101
By("Fetching Kubernetes events")
102102
cmd = exec.Command("kubectl", "get", "events", "-n", namespace, "--sort-by=.lastTimestamp")
103103
eventsOutput, err := utils.Run(cmd)
104104
if err == nil {
105-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Kubernetes events:\n%s", eventsOutput))
105+
_, _ = fmt.Fprintf(GinkgoWriter, "Kubernetes events:\n%s", eventsOutput)
106106
} else {
107-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Kubernetes events: %s", err))
107+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get Kubernetes events: %s", err)
108108
}
109109

110110
By("Fetching curl-metrics logs")
111111
cmd = exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace)
112112
metricsOutput, err := utils.Run(cmd)
113113
if err == nil {
114-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Metrics logs:\n %s", metricsOutput))
114+
_, _ = fmt.Fprintf(GinkgoWriter, "Metrics logs:\n %s", metricsOutput)
115115
} else {
116-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get curl-metrics logs: %s", err))
116+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get curl-metrics logs: %s", err)
117117
}
118118

119119
By("Fetching controller manager pod description")
@@ -316,7 +316,7 @@ func serviceAccountToken() (string, error) {
316316

317317
// Parse the JSON output to extract the token
318318
var token tokenRequest
319-
err = json.Unmarshal([]byte(output), &token)
319+
err = json.Unmarshal(output, &token)
320320
g.Expect(err).NotTo(HaveOccurred())
321321

322322
out = token.Status.Token

docs/book/src/cronjob-tutorial/testdata/project/test/utils/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool {
9292
if err != nil {
9393
return false
9494
}
95-
crdList := GetNonEmptyLines(string(output))
95+
crdList := GetNonEmptyLines(output)
9696
for _, crd := range prometheusCRDs {
9797
for _, line := range crdList {
9898
if strings.Contains(line, crd) {
@@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool {
153153
}
154154

155155
// Check if any of the Cert Manager CRDs are present
156-
crdList := GetNonEmptyLines(string(output))
156+
crdList := GetNonEmptyLines(output)
157157
for _, crd := range certManagerCRDs {
158158
for _, line := range crdList {
159159
if strings.Contains(line, crd) {

docs/book/src/getting-started/testdata/project/test/e2e/e2e_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ var _ = Describe("Manager", Ordered, func() {
9393
cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace)
9494
controllerLogs, err := utils.Run(cmd)
9595
if err == nil {
96-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Controller logs:\n %s", controllerLogs))
96+
_, _ = fmt.Fprintf(GinkgoWriter, "Controller logs:\n %s", controllerLogs)
9797
} else {
98-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Controller logs: %s", err))
98+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get Controller logs: %s", err)
9999
}
100100

101101
By("Fetching Kubernetes events")
102102
cmd = exec.Command("kubectl", "get", "events", "-n", namespace, "--sort-by=.lastTimestamp")
103103
eventsOutput, err := utils.Run(cmd)
104104
if err == nil {
105-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Kubernetes events:\n%s", eventsOutput))
105+
_, _ = fmt.Fprintf(GinkgoWriter, "Kubernetes events:\n%s", eventsOutput)
106106
} else {
107-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Kubernetes events: %s", err))
107+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get Kubernetes events: %s", err)
108108
}
109109

110110
By("Fetching curl-metrics logs")
111111
cmd = exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace)
112112
metricsOutput, err := utils.Run(cmd)
113113
if err == nil {
114-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Metrics logs:\n %s", metricsOutput))
114+
_, _ = fmt.Fprintf(GinkgoWriter, "Metrics logs:\n %s", metricsOutput)
115115
} else {
116-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get curl-metrics logs: %s", err))
116+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get curl-metrics logs: %s", err)
117117
}
118118

119119
By("Fetching controller manager pod description")
@@ -278,7 +278,7 @@ func serviceAccountToken() (string, error) {
278278

279279
// Parse the JSON output to extract the token
280280
var token tokenRequest
281-
err = json.Unmarshal([]byte(output), &token)
281+
err = json.Unmarshal(output, &token)
282282
g.Expect(err).NotTo(HaveOccurred())
283283

284284
out = token.Status.Token

docs/book/src/getting-started/testdata/project/test/utils/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool {
9292
if err != nil {
9393
return false
9494
}
95-
crdList := GetNonEmptyLines(string(output))
95+
crdList := GetNonEmptyLines(output)
9696
for _, crd := range prometheusCRDs {
9797
for _, line := range crdList {
9898
if strings.Contains(line, crd) {
@@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool {
153153
}
154154

155155
// Check if any of the Cert Manager CRDs are present
156-
crdList := GetNonEmptyLines(string(output))
156+
crdList := GetNonEmptyLines(output)
157157
for _, crd := range certManagerCRDs {
158158
for _, line := range crdList {
159159
if strings.Contains(line, crd) {

docs/book/src/multiversion-tutorial/testdata/project/internal/webhook/v1/cronjob_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ This marker is responsible for generating a validation webhook manifest.
166166
// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods,
167167
// as this struct is used only for temporary operations and does not need to be deeply copied.
168168
type CronJobCustomValidator struct {
169-
//TODO(user): Add more fields as needed for validation
169+
// TODO(user): Add more fields as needed for validation
170170
}
171171

172172
var _ webhook.CustomValidator = &CronJobCustomValidator{}

docs/book/src/multiversion-tutorial/testdata/project/internal/webhook/v2/cronjob_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func (d *CronJobCustomDefaulter) Default(ctx context.Context, obj runtime.Object
9898
// NOTE: The +kubebuilder:object:generate=false marker prevents controller-gen from generating DeepCopy methods,
9999
// as this struct is used only for temporary operations and does not need to be deeply copied.
100100
type CronJobCustomValidator struct {
101-
//TODO(user): Add more fields as needed for validation
101+
// TODO(user): Add more fields as needed for validation
102102
}
103103

104104
var _ webhook.CustomValidator = &CronJobCustomValidator{}

docs/book/src/multiversion-tutorial/testdata/project/test/e2e/e2e_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ var _ = Describe("Manager", Ordered, func() {
9393
cmd := exec.Command("kubectl", "logs", controllerPodName, "-n", namespace)
9494
controllerLogs, err := utils.Run(cmd)
9595
if err == nil {
96-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Controller logs:\n %s", controllerLogs))
96+
_, _ = fmt.Fprintf(GinkgoWriter, "Controller logs:\n %s", controllerLogs)
9797
} else {
98-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Controller logs: %s", err))
98+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get Controller logs: %s", err)
9999
}
100100

101101
By("Fetching Kubernetes events")
102102
cmd = exec.Command("kubectl", "get", "events", "-n", namespace, "--sort-by=.lastTimestamp")
103103
eventsOutput, err := utils.Run(cmd)
104104
if err == nil {
105-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Kubernetes events:\n%s", eventsOutput))
105+
_, _ = fmt.Fprintf(GinkgoWriter, "Kubernetes events:\n%s", eventsOutput)
106106
} else {
107-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get Kubernetes events: %s", err))
107+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get Kubernetes events: %s", err)
108108
}
109109

110110
By("Fetching curl-metrics logs")
111111
cmd = exec.Command("kubectl", "logs", "curl-metrics", "-n", namespace)
112112
metricsOutput, err := utils.Run(cmd)
113113
if err == nil {
114-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Metrics logs:\n %s", metricsOutput))
114+
_, _ = fmt.Fprintf(GinkgoWriter, "Metrics logs:\n %s", metricsOutput)
115115
} else {
116-
_, _ = fmt.Fprintf(GinkgoWriter, fmt.Sprintf("Failed to get curl-metrics logs: %s", err))
116+
_, _ = fmt.Fprintf(GinkgoWriter, "Failed to get curl-metrics logs: %s", err)
117117
}
118118

119119
By("Fetching controller manager pod description")
@@ -316,7 +316,7 @@ func serviceAccountToken() (string, error) {
316316

317317
// Parse the JSON output to extract the token
318318
var token tokenRequest
319-
err = json.Unmarshal([]byte(output), &token)
319+
err = json.Unmarshal(output, &token)
320320
g.Expect(err).NotTo(HaveOccurred())
321321

322322
out = token.Status.Token

docs/book/src/multiversion-tutorial/testdata/project/test/utils/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func IsPrometheusCRDsInstalled() bool {
9292
if err != nil {
9393
return false
9494
}
95-
crdList := GetNonEmptyLines(string(output))
95+
crdList := GetNonEmptyLines(output)
9696
for _, crd := range prometheusCRDs {
9797
for _, line := range crdList {
9898
if strings.Contains(line, crd) {
@@ -153,7 +153,7 @@ func IsCertManagerCRDsInstalled() bool {
153153
}
154154

155155
// Check if any of the Cert Manager CRDs are present
156-
crdList := GetNonEmptyLines(string(output))
156+
crdList := GetNonEmptyLines(output)
157157
for _, crd := range certManagerCRDs {
158158
for _, line := range crdList {
159159
if strings.Contains(line, crd) {

pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (r *{{ .Resource.Kind }}Reconciler) Reconcile(ctx context.Context, req ctrl
153153
}
154154
155155
// Let's just set the status as Unknown when no status is available
156-
if {{ lower .Resource.Kind }}.Status.Conditions == nil || len({{ lower .Resource.Kind }}.Status.Conditions) == 0 {
156+
if len({{ lower .Resource.Kind }}.Status.Conditions) == 0 {
157157
meta.SetStatusCondition(&{{ lower .Resource.Kind }}.Status.Conditions, metav1.Condition{Type: typeAvailable{{ .Resource.Kind }}, Status: metav1.ConditionUnknown, Reason: "Reconciling", Message: "Starting reconciliation"})
158158
if err = r.Status().Update(ctx, {{ lower .Resource.Kind }}); err != nil {
159159
log.Error(err, "Failed to update {{ .Resource.Kind }} status")

0 commit comments

Comments
 (0)