Skip to content

Commit

Permalink
Revert "Revert "secretmanagerを一時削除""
Browse files Browse the repository at this point in the history
This reverts commit 7d131a6.
  • Loading branch information
aikizoku committed Mar 18, 2022
1 parent 7d131a6 commit 953bdf1
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 38 deletions.
30 changes: 0 additions & 30 deletions environment/helper.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down Expand Up @@ -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)
}
}
}
5 changes: 0 additions & 5 deletions environment/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 953bdf1

Please sign in to comment.