From 623d9c3e133086819439b83b9f5add90e35c966d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Krupa=20=28paulfantom=29?= Date: Tue, 15 Feb 2022 13:31:04 +0100 Subject: [PATCH 1/3] .github: fail CI if code is badly formatted --- .github/workflows/cli.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index 2a95c7b9..a5a08493 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -28,11 +28,13 @@ jobs: working-directory: cli run: | make go-fmt + git diff --exit-code - name: Vet working-directory: cli run: | make go-vet + git diff --exit-code # TODO(paulfantom): figure-out why golangci-lint action crashes #- name: Lint From 60de8b006c99ad5f57ee0bb7e679c2d032dd9655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Krupa=20=28paulfantom=29?= Date: Tue, 15 Feb 2022 13:31:34 +0100 Subject: [PATCH 2/3] cli: make target should format code in place --- cli/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/Makefile b/cli/Makefile index bb173e21..61f8233e 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -29,7 +29,7 @@ go-vet: go vet ./... go-fmt: - gofmt -d . + gofmt -s -w . go-lint: golangci-lint run @@ -43,4 +43,4 @@ uninstall-tobs: delete-kind: kind delete cluster --name tobs -all: build start-kind e2e-tests external-db-tests go-vet go-fmt go-lint \ No newline at end of file +all: build start-kind e2e-tests external-db-tests go-vet go-fmt go-lint From 50fd39bfefa9081c4228571af58af8b89f0de7fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Krupa=20=28paulfantom=29?= Date: Tue, 15 Feb 2022 13:31:48 +0100 Subject: [PATCH 3/3] cli: run go-fmt to format code --- cli/cmd/grafana/port_forward.go | 2 +- cli/cmd/timescaledb/port_forward.go | 2 +- cli/cmd/timescaledb/superuser/change_password.go | 8 ++++---- cli/pkg/helm/client_impl.go | 2 +- cli/pkg/k8s/client.go | 2 +- cli/pkg/otel/otel-utilities.go | 2 +- cli/pkg/pgconn/connection_test.go | 4 ++-- cli/tests/tobs-cli-tests/portforward_test.go | 1 - 8 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cli/cmd/grafana/port_forward.go b/cli/cmd/grafana/port_forward.go index faf3f364..099f4bc6 100644 --- a/cli/cmd/grafana/port_forward.go +++ b/cli/cmd/grafana/port_forward.go @@ -50,4 +50,4 @@ func PortForwardGrafana(listenPort int) error { } return nil -} \ No newline at end of file +} diff --git a/cli/cmd/timescaledb/port_forward.go b/cli/cmd/timescaledb/port_forward.go index d7db2e4a..60f8ec91 100644 --- a/cli/cmd/timescaledb/port_forward.go +++ b/cli/cmd/timescaledb/port_forward.go @@ -51,4 +51,4 @@ func PortForwardTimescaleDB(listenPort int) error { } return nil -} \ No newline at end of file +} diff --git a/cli/cmd/timescaledb/superuser/change_password.go b/cli/cmd/timescaledb/superuser/change_password.go index ab2548b5..2d5c7a83 100644 --- a/cli/cmd/timescaledb/superuser/change_password.go +++ b/cli/cmd/timescaledb/superuser/change_password.go @@ -65,7 +65,7 @@ func updateDBPwdSecrets(k8sClient k8s.Client, secretKey, user, password string) } if tsdb { - secretName := root.HelmReleaseName+"-credentials" + secretName := root.HelmReleaseName + "-credentials" tsdbSecret, err := k8sClient.KubeGetSecret(root.Namespace, secretName) if err != nil { return fmt.Errorf("could not get secret with name %s: %w", secretName, err) @@ -79,7 +79,7 @@ func updateDBPwdSecrets(k8sClient k8s.Client, secretKey, user, password string) } // Update Grafana DB creds - grafanaSecretName := root.HelmReleaseName+"-grafana-db" + grafanaSecretName := root.HelmReleaseName + "-grafana-db" grafanaSecret, err := k8sClient.KubeGetSecret(root.Namespace, grafanaSecretName) if err != nil { return fmt.Errorf("could not get secret with name %s: %w", grafanaSecretName, err) @@ -95,7 +95,7 @@ func updateDBPwdSecrets(k8sClient k8s.Client, secretKey, user, password string) } // Update Promscale connection details - promscaleSecretName, err := pgconn.GetPromscaleSecretName(root.HelmReleaseName, root.Namespace) + promscaleSecretName, err := pgconn.GetPromscaleSecretName(root.HelmReleaseName, root.Namespace) if err != nil { return err } @@ -110,7 +110,7 @@ func updateDBPwdSecrets(k8sClient k8s.Client, secretKey, user, password string) return fmt.Errorf("failed to parse db-uri %v", err) } dbDetails.ConnConfig.Password = password - updatedDBURI, err := pgconn.UpdatePasswordInDBURI(string(bytepass), password) + updatedDBURI, err := pgconn.UpdatePasswordInDBURI(string(bytepass), password) if err != nil { return fmt.Errorf("failed to update password in db-uri %v", err) } diff --git a/cli/pkg/helm/client_impl.go b/cli/pkg/helm/client_impl.go index 5e1bad1c..37d8d0d4 100644 --- a/cli/pkg/helm/client_impl.go +++ b/cli/pkg/helm/client_impl.go @@ -589,4 +589,4 @@ func (c *clientImpl) listDeployedReleases(namespace string) ([]*release.Release, listClient := action.NewList(c.actionConfig) listClient.StateMask = action.ListDeployed | action.ListFailed | action.ListPendingInstall | action.ListPendingUpgrade return listClient.Run() -} \ No newline at end of file +} diff --git a/cli/pkg/k8s/client.go b/cli/pkg/k8s/client.go index 00a3682d..0fafa11a 100644 --- a/cli/pkg/k8s/client.go +++ b/cli/pkg/k8s/client.go @@ -73,4 +73,4 @@ type Client interface { // Apply manifests ApplyManifests(map[string]string) error -} \ No newline at end of file +} diff --git a/cli/pkg/otel/otel-utilities.go b/cli/pkg/otel/otel-utilities.go index d2914a3b..6c34ac27 100644 --- a/cli/pkg/otel/otel-utilities.go +++ b/cli/pkg/otel/otel-utilities.go @@ -143,7 +143,7 @@ func (c *OtelCol) ValidateCertManager() error { // namespace this needs to be ignored as otel-operator helm-chart upgrades them // Mote: Resource with name 'opentelemetry-operator-selfsigned-issuer` isn't part of // any namespace so adding a check. - if resource.Namespace != "opentelemetry-operator-system" { + if resource.Namespace != "opentelemetry-operator-system" { if resource.Name != "opentelemetry-operator-selfsigned-issuer" { onlyCertMResources = append(onlyCertMResources, resource) } diff --git a/cli/pkg/pgconn/connection_test.go b/cli/pkg/pgconn/connection_test.go index eafa05a0..c7dcf561 100644 --- a/cli/pkg/pgconn/connection_test.go +++ b/cli/pkg/pgconn/connection_test.go @@ -30,8 +30,8 @@ func TestConstructURI(t *testing.T) { want: "postgres://bob%20has%20spaces%20in%20his%20username:%7B%40nd%20$p3ci%40L%20ch%40R$%201n%20h1$%20p%40$$w0rd%21%5E%27@localhost:5432/bob_has_a_database", }, { - user: "$b0b!", - password: "$p3ci@L-ch@R$_1n\nh1$ p@$$w0rd!^'", + user: "$b0b!", + password: "$p3ci@L-ch@R$_1n\nh1$ p@$$w0rd!^'", host: "my.host.com", port: 9999, dbname: "this-is a valid db nAm3 if double quoted", diff --git a/cli/tests/tobs-cli-tests/portforward_test.go b/cli/tests/tobs-cli-tests/portforward_test.go index a78e29bd..897f4940 100644 --- a/cli/tests/tobs-cli-tests/portforward_test.go +++ b/cli/tests/tobs-cli-tests/portforward_test.go @@ -32,7 +32,6 @@ func testpf(t testing.TB, timescale, grafana, prometheus, promscale, promlens st // kubectl get pods -A test_utils.ShowAllPods(t) - t.Logf("Running '%v'", "tobs "+strings.Join(cmds, " ")) portforward := exec.Command(PATH_TO_TOBS, cmds...)