diff --git a/environment/helper.go b/environment/helper.go index 694f6ae..d5d49d5 100644 --- a/environment/helper.go +++ b/environment/helper.go @@ -1,16 +1,12 @@ package environment import ( - "context" "fmt" "io/ioutil" "os" - secretmanager "cloud.google.com/go/secretmanager/apiv1" - secretmanagerpb "google.golang.org/genproto/googleapis/cloud/secretmanager/v1" "gopkg.in/yaml.v3" - "github.com/rabee-inc/go-pkg/bytesutil" "github.com/rabee-inc/go-pkg/deploy" ) @@ -47,29 +43,3 @@ func Load(envFilePath string) { } } } - -func LoadSecret(projectID string, params []*LoadSecretParam) { - ctx := context.Background() - cSecretManager, err := secretmanager.NewClient(ctx) - if err != nil { - panic(err) - } - for _, param := range params { - if param.Version == "" { - param.Version = "latest" - } - name := fmt.Sprintf("projects/%s/secrets/%s/versions/%s", projectID, param.Key, param.Version) - request := &secretmanagerpb.AccessSecretVersionRequest{ - Name: name, - } - result, err := cSecretManager.AccessSecretVersion(ctx, request) - if err != nil { - panic(err) - } - v := bytesutil.ToStr(result.Payload.GetData()) - err = os.Setenv(param.Key, v) - if err != nil { - panic(err) - } - } -} diff --git a/environment/model.go b/environment/model.go index 5d01449..7027ac7 100644 --- a/environment/model.go +++ b/environment/model.go @@ -13,8 +13,3 @@ type Variable struct { Staging map[string]string `yaml:"staging"` Production map[string]string `yaml:"production"` } - -type LoadSecretParam struct { - Key string - Version string -} diff --git a/go.mod b/go.mod index 6456bd7..d6c9855 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,6 @@ require ( cloud.google.com/go/cloudtasks v1.3.0 cloud.google.com/go/firestore v1.6.1 cloud.google.com/go/pubsub v1.19.0 - cloud.google.com/go/secretmanager v1.3.0 cloud.google.com/go/storage v1.21.0 firebase.google.com/go v3.13.0+incompatible github.com/davecgh/go-spew v1.1.1 diff --git a/go.sum b/go.sum index a45309a..e2d494a 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,6 @@ cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIA cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= cloud.google.com/go/pubsub v1.19.0 h1:WZy66ga6/tqmZiwv1jwKVgqV8FuEuAmPR5CEJHNVCZk= cloud.google.com/go/pubsub v1.19.0/go.mod h1:/O9kmSe9bb9KRnIAWkzmqhPjHo6LtzGOBYd/kr06XSs= -cloud.google.com/go/secretmanager v1.3.0 h1:43rHc04zmpiQeqtNKpO5la4bwF5aDhHACZqxQk6D/4c= -cloud.google.com/go/secretmanager v1.3.0/go.mod h1:+oLTkouyiYiabAQNugCeTS3PAArGiMJuBqvJnJsyH+U= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=