Add support for GCP Secret Manager

This commit is contained in:
2025-09-08 10:40:25 +02:00
parent 8e2706784b
commit e4e4bf9be4
6 changed files with 281 additions and 14 deletions

35
google_test.go Normal file
View File

@@ -0,0 +1,35 @@
package secret
import (
"os"
"testing"
)
func TestGCPSecretManager(t *testing.T) {
if os.Getenv("GOOGLE_CLOUD_CREDENTIALS") == "" && os.Getenv("GOOGLE_CLOUD_CREDENTIALS_JSON") == "" {
t.Skip("GOOGLE_CLOUD_CREDENTIALS_JSON not set, which should contain the credentials for testing")
return
}
projectID := os.Getenv("GOOGLE_CLOUD_PROJECT_ID")
if projectID == "" {
t.Skip("GOOGLE_CLOUD_PROJECT_ID not set, which should contain the GCP project ID for testing")
return
}
p, err := GCPSecretManager(projectID)
if err != nil {
t.Fatal(err)
return
}
v, err := p.GetSecret("integration_test")
if err != nil {
t.Error(err)
return
}
if string(v) != "This is a secret!" {
t.Errorf("unexpected value %q", v)
}
}