Skip to content

Commit

Permalink
Merge pull request #4396 from r-vasquez/k8s-lint-fix
Browse files Browse the repository at this point in the history
k8s: fix lint warnings and disabling gomnd
  • Loading branch information
twmb committed Apr 25, 2022
2 parents 79a8fbf + 6d3f741 commit 0dd01fe
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/go/k8s/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ linters:
- gocritic
- gocyclo
- revive
- gomnd
- goprintffuncname
- gosec
- gosimple
Expand Down Expand Up @@ -84,6 +83,7 @@ linters:
# - gochecknoglobals
# - gocognit
# - godot
# - gomnd
# - godox
# - goerr113
# - maligned
Expand Down
2 changes: 1 addition & 1 deletion src/go/k8s/apis/redpanda/v1alpha1/cluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func TestValidateUpdate_NoError(t *testing.T) {
})

t.Run("scale up", func(t *testing.T) {
var scaleUp int32 = *redpandaCluster.Spec.Replicas + 1
scaleUp := *redpandaCluster.Spec.Replicas + 1
updatedScaleUp := redpandaCluster.DeepCopy()
updatedScaleUp.Spec.Replicas = &scaleUp
err := updatedScaleUp.ValidateUpdate(redpandaCluster)
Expand Down
3 changes: 1 addition & 2 deletions src/go/k8s/cmd/configurator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"context"
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path"
Expand Down Expand Up @@ -145,7 +144,7 @@ func main() {

log.Printf("Config: %s", string(cfgBytes))

if err := ioutil.WriteFile(c.configDestination, cfgBytes, 0600); err != nil {
if err := os.WriteFile(c.configDestination, cfgBytes, 0o600); err != nil {
log.Fatalf("%s", fmt.Errorf("unable to write the destination configuration file: %w", err))
}

Expand Down
8 changes: 3 additions & 5 deletions src/go/k8s/pkg/resources/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,9 @@ func (r *StatefulSetResource) getPreStopHook() *corev1.Handler {
curlCommand := r.composeCURLMaintenanceCommand(`-X PUT --silent -o /dev/null -w "%{http_code}"`, nil)
genericMaintenancePath := "/v1/maintenance"
curlGetCommand := r.composeCURLMaintenanceCommand(`--silent`, &genericMaintenancePath)
cmd := strings.Join(
[]string{
fmt.Sprintf(`until [ "${status:-}" = "200" ]; do status=$(%s); sleep 0.5; done`, curlCommand),
fmt.Sprintf(`until [ "${finished:-}" = "true" ]; do finished=$(%s | grep -o '\"finished\":[^,}]*' | grep -o '[^: ]*$'); sleep 0.5; done`, curlGetCommand),
}, " && ")
cmd := fmt.Sprintf(`until [ "${status:-}" = "200" ]; do status=$(%s); sleep 0.5; done`, curlCommand) +
" && " +
fmt.Sprintf(`until [ "${finished:-}" = "true" ]; do finished=$(%s | grep -o '\"finished\":[^,}]*' | grep -o '[^: ]*$'); sleep 0.5; done`, curlGetCommand)

return &corev1.Handler{
Exec: &corev1.ExecAction{
Expand Down
2 changes: 1 addition & 1 deletion src/go/k8s/pkg/resources/statefulset_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ func (r *StatefulSetResource) queryRedpandaStatus(
adminURL.Scheme = "https"
}

req, err := http.NewRequestWithContext(ctx, http.MethodGet, adminURL.String(), nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, adminURL.String(), http.NoBody)
if err != nil {
return err
}
Expand Down

0 comments on commit 0dd01fe

Please sign in to comment.