Skip to content

Commit

Permalink
[ Feature ] Add support for GCP secrets manager (#535)
Browse files Browse the repository at this point in the history
* Added support for GCP secrets manager
* Published relevant public docs with the instructions on how to use this feature
  • Loading branch information
ZeljkoBenovic authored May 16, 2022
1 parent 41d4d37 commit 2e44243
Show file tree
Hide file tree
Showing 388 changed files with 65,922 additions and 445 deletions.
7 changes: 4 additions & 3 deletions command/secrets/generate/params.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package generate

import (
"errors"
"fmt"
"strings"

Expand All @@ -24,13 +23,15 @@ const (
)

const (
defaultNodeName = "polygon-edge-node"
defaultNodeName = ""
defaultConfigFileName = "./secretsManagerConfig.json"
defaultNamespace = "admin"
)

var (
errUnsupportedType = errors.New("unsupported service manager type")
errUnsupportedType = fmt.Errorf(
"unsupported service manager type; only %s, %s, %s and %s are supported for now",
secrets.Local, secrets.HashicorpVault, secrets.AWSSSM, secrets.GCPSSM)
)

type generateParams struct {
Expand Down
22 changes: 8 additions & 14 deletions command/secrets/generate/secrets_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package generate

import (
"fmt"

"github.com/0xPolygon/polygon-edge/command"
"github.com/spf13/cobra"

Expand All @@ -11,7 +12,7 @@ import (
func GetCommand() *cobra.Command {
secretsGenerateCmd := &cobra.Command{
Use: "generate",
Short: "Initializes the secrets manager configuration in the provided directory. Used for Hashicorp Vault",
Short: "Initializes the secrets manager configuration in the provided directory.",
Run: runCommand,
}

Expand All @@ -26,10 +27,7 @@ func setFlags(cmd *cobra.Command) {
&params.dir,
dirFlag,
defaultConfigFileName,
fmt.Sprintf(
"the directory for the secrets manager configuration file Default: %s",
defaultConfigFileName,
),
"the directory for the secrets manager configuration file",
)

cmd.Flags().StringVar(
Expand All @@ -51,29 +49,25 @@ func setFlags(cmd *cobra.Command) {
typeFlag,
string(secrets.HashicorpVault),
fmt.Sprintf(
"the type of the secrets manager. Default: %s",
"the type of the secrets manager. Available types: %s, %s and %s",
secrets.HashicorpVault,
secrets.AWSSSM,
secrets.GCPSSM,
),
)

cmd.Flags().StringVar(
&params.name,
nameFlag,
defaultNodeName,
fmt.Sprintf(
"the name of the node for on-service record keeping. Default: %s",
defaultNodeName,
),
"the name of the node for on-service record keeping",
)

cmd.Flags().StringVar(
&params.namespace,
namespaceFlag,
defaultNamespace,
fmt.Sprintf(
"the namespace for the service. Default %s",
defaultNamespace,
),
"the namespace for the service",
)

cmd.Flags().StringVar(
Expand Down
7 changes: 7 additions & 0 deletions command/secrets/init/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ func (ip *initParams) initFromConfig() error {
}

secretsManager = AWSSSM
case secrets.GCPSSM:
GCPSSM, err := helper.SetupGCPSSM(ip.secretsConfig)
if err != nil {
return err
}

secretsManager = GCPSSM
default:
return errUnsupportedType
}
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ require (
)

require (
cloud.google.com/go v0.100.2 // indirect
cloud.google.com/go/secretmanager v1.4.0
github.com/armon/go-metrics v0.3.10 // indirect
github.com/aws/aws-sdk-go v1.44.14
github.com/benbjohnson/clock v1.3.0 // indirect
Expand All @@ -53,9 +55,8 @@ require (
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/valyala/fastjson v1.6.3 // indirect
go.uber.org/zap v1.20.0 // indirect
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9 // indirect
golang.org/x/tools v0.1.9 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
lukechampine.com/blake3 v1.1.7 // indirect
)
168 changes: 168 additions & 0 deletions go.sum

Large diffs are not rendered by default.

Loading

0 comments on commit 2e44243

Please sign in to comment.