Commit 14ce26fc authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

style(lint): fix/disable lint issues

parent 75c4d306
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import (
)

func Test_getenv_when_var_unset(t *testing.T) {
	os.Unsetenv("TESTVAR")
	os.Unsetenv("TESTVAR") // nolint:errcheck,gosec
	// os.Setenv("TESTVAR", "test")
	val := EnvStr("TESTVAR").Or("default")
	if val != "default" {
@@ -32,7 +32,7 @@ func Test_getenv_when_var_unset(t *testing.T) {
}

func Test_getenv_when_var_empty(t *testing.T) {
	os.Setenv("TESTVAR", "")
	os.Setenv("TESTVAR", "") // nolint:errcheck,gosec
	val := EnvStr("TESTVAR").Or("default")
	if val != "default" {
		t.Fatalf("Assert error\nExpected:\n%s\nGot:\n%s", "default", val)
@@ -40,7 +40,7 @@ func Test_getenv_when_var_empty(t *testing.T) {
}

func Test_getenv_when_var_gitlab_unset(t *testing.T) {
	os.Setenv("TESTVAR", "$TESTVAR")
	os.Setenv("TESTVAR", "$TESTVAR") // nolint:errcheck,gosec
	val := EnvStr("TESTVAR").Or("default")
	if val != "default" {
		t.Fatalf("Assert error\nExpected:\n%s\nGot:\n%s", "default", val)
@@ -48,7 +48,7 @@ func Test_getenv_when_var_gitlab_unset(t *testing.T) {
}

func Test_getenv_when_var_set(t *testing.T) {
	os.Setenv("TESTVAR", "testval")
	os.Setenv("TESTVAR", "testval") // nolint:errcheck,gosec
	val := EnvStr("TESTVAR").Or("default")
	if val != "testval" {
		t.Fatalf("Assert error\nExpected:\n%s\nGot:\n%s", "testval", val)
+12 −12
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ func doLogin() (*Authentication, error) {
			}
		} else if resp.StatusCode != http.StatusOK {
			// http error: decode error body and throw error
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var errResp ErrorResponse
			// nolint
			json.NewDecoder(resp.Body).Decode(&errResp)
@@ -211,7 +211,7 @@ func doLogin() (*Authentication, error) {
			}
		} else {
			// OK: decode response
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var loginResp LoginResponse
			if err := json.NewDecoder(resp.Body).Decode(&loginResp); err != nil {
				// JSON unmarshall error: propagate
@@ -280,7 +280,7 @@ func doGetKvEngineVersion(secretPath string) (int, error) {
			}
		} else if resp.StatusCode != http.StatusOK {
			// http error: decode error body and throw error
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var errResp ErrorResponse
			// nolint
			json.NewDecoder(resp.Body).Decode(&errResp)
@@ -292,7 +292,7 @@ func doGetKvEngineVersion(secretPath string) (int, error) {
			}
		} else {
			// OK: decode response
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var getUiMountsResp GetSecretResponse
			if err := json.NewDecoder(resp.Body).Decode(&getUiMountsResp); err != nil {
				// JSON unmarshall error: propagate
@@ -369,7 +369,7 @@ func doGetSecret(secretPath string) (map[string]interface{}, error) {
			}
		} else if resp.StatusCode != http.StatusOK {
			// http error: decode error body and throw error
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var errResp ErrorResponse
			// nolint
			json.NewDecoder(resp.Body).Decode(&errResp)
@@ -381,7 +381,7 @@ func doGetSecret(secretPath string) (map[string]interface{}, error) {
			}
		} else {
			// OK: decode response
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var secret GetSecretResponse
			if err := json.NewDecoder(resp.Body).Decode(&secret); err != nil {
				// JSON unmarshall error: propagate
@@ -493,7 +493,7 @@ func doUpdateSecret(secretPath string, body string) (map[string]interface{}, err
			}
		} else if resp.StatusCode != http.StatusOK {
			// http error: decode error body and throw error
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var errResp ErrorResponse
			// nolint
			json.NewDecoder(resp.Body).Decode(&errResp)
@@ -505,7 +505,7 @@ func doUpdateSecret(secretPath string, body string) (map[string]interface{}, err
			}
		} else {
			// OK: decode response
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var secret UpdateSecretResponse
			if err := json.NewDecoder(resp.Body).Decode(&secret); err != nil {
				// JSON unmarshall error: propagate
@@ -572,7 +572,7 @@ func doDeleteSecret(secretPath string) error {
			}
		} else if resp.StatusCode != http.StatusNoContent {
			// http error: decode error body and throw error
			defer resp.Body.Close()
			defer resp.Body.Close() // nolint:errcheck
			var errResp ErrorResponse
			// nolint
			json.NewDecoder(resp.Body).Decode(&errResp)
@@ -616,17 +616,17 @@ func getObj(obj map[string]interface{}, keyPath string) (string, error) {
				sub = asMap[keys[index]]
				// check not null
				if sub == nil {
					return "", fmt.Errorf("No such object: '%s'", strings.Join(keys[0:index+1], "."))
					return "", fmt.Errorf("no such object: '%s'", strings.Join(keys[0:index+1], "."))
				}
			} else {
				return "", fmt.Errorf("Object at '%s' is not a map", strings.Join(keys[0:index+1], "."))
				return "", fmt.Errorf("object at '%s' is not a map", strings.Join(keys[0:index+1], "."))
			}
		}
	}
	// return sub as raw string or JSON
	if asStr, ok := sub.(string); !ok {
		if jsonStr, err := json.Marshal(sub); err != nil {
			return "", fmt.Errorf("Failed marshalling object '%s' due to %v", keyPath, err)
			return "", fmt.Errorf("failed marshalling object '%s' due to %v", keyPath, err)
		} else {
			return string(jsonStr), nil
		}
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import (
	"log"
	"net/http"

	. "vault-secrets-provider/cmd/vault_service/internal"
	. "vault-secrets-provider/cmd/vault_service/internal" // nolint:staticcheck
)

func main() {