Browse Source

Add SA json creds as env var

Lucas Severo Alves 4 years ago
parent
commit
b8c9c3c7d4
3 changed files with 7 additions and 6 deletions
  1. 1 0
      .github/workflows/ci.yml
  2. 1 1
      e2e/suite/gcp/gcp.go
  3. 5 5
      e2e/suite/gcp/util.go

+ 1 - 0
.github/workflows/ci.yml

@@ -19,6 +19,7 @@ env:
   # a step 'if env.GHCR_USERNAME' != ""', so we copy these to succinctly test whether
   # credentials have been provided before trying to run steps that need them.
   GHCR_USERNAME: ${{ secrets.GHCR_USERNAME }}
+  GCP_SM_SA_JSON: ${{ secrets.GCP_SM_SA_JSON}}
 
 jobs:
   detect-noop:

+ 1 - 1
e2e/suite/gcp/gcp.go

@@ -74,7 +74,7 @@ var _ = Describe("[gcp] ", func() {
 	})
 
 	It("should sync secrets", func() {
-		By("creating a AWS SM Secret")
+		By("creating a GCP SM Secret")
 		secretKey1 := fmt.Sprintf("%s-%s", f.Namespace.Name, "one")
 		secretValue := "great-value-test"
 		targetSecret := "target-secret"

+ 5 - 5
e2e/suite/gcp/util.go

@@ -16,12 +16,12 @@ import (
 	"context"
 	"fmt"
 
-	gcpsm "github.com/external-secrets/external-secrets/pkg/provider/gcp/secretmanager"
+	secretmanager "cloud.google.com/go/secretmanager/apiv1"
 	"golang.org/x/oauth2/google"
 	"google.golang.org/api/option"
-
-	secretmanager "cloud.google.com/go/secretmanager/apiv1"
 	secretmanagerpb "google.golang.org/genproto/googleapis/cloud/secretmanager/v1"
+
+	gcpsm "github.com/external-secrets/external-secrets/pkg/provider/gcp/secretmanager"
 )
 
 // CreateAWSSecretsManagerSecret creates a sm secret with the given value.
@@ -30,7 +30,7 @@ func CreateGCPSecretsManagerSecret(projectID, secretName, secretValue string, cr
 
 	config, err := google.JWTConfigFromJSON(credentials, gcpsm.CloudPlatformRole)
 	if err != nil {
-		return fmt.Errorf("Unable to procces JSON credentials: %w", err)
+		return fmt.Errorf("unable to procces JSON credentials: %w", err)
 	}
 	ts := config.TokenSource(ctx)
 
@@ -67,7 +67,7 @@ func CreateGCPSecretsManagerSecret(projectID, secretName, secretValue string, cr
 	// Call the API.
 	_, err = client.AddSecretVersion(ctx, addSecretVersionReq)
 	if err != nil {
-		return fmt.Errorf("failed to add secret version: %v", err)
+		return fmt.Errorf("failed to add secret version: %w", err)
 	}
 
 	return err