Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

[feature] Added a stdout sink and an env source #40

Merged
merged 4 commits into from
Feb 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/rotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func init() {
var rotateCmd = &cobra.Command{
Use: "rotate",
Short: "Rotate secrets",
Long: `rotate parses a config file, rotates the secret at
Long: `rotate parses a config file, rotates the secret at
the source, and writes the new secret to each sink`,
SilenceErrors: true, // If we don't silence here, cobra will print them. But we want to do that in cmd/root.go
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
26 changes: 9 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,25 @@ module github.com/chanzuckerberg/rotator
go 1.13

require (
github.com/aws/aws-sdk-go v1.25.14
github.com/caio/go-tdigest v2.3.0+incompatible // indirect
github.com/chanzuckerberg/go-misc v0.0.0-20191016143922-52a18771c2dc
github.com/fatih/color v1.7.0
github.com/getsentry/sentry-go v0.3.0
github.com/golang/protobuf v1.3.2 // indirect
github.com/aws/aws-sdk-go v1.28.9
github.com/chanzuckerberg/go-misc v0.0.0-20191125152854-38391fa92cd1
github.com/fatih/color v1.9.0
github.com/getsentry/sentry-go v0.5.0
github.com/google/uuid v1.1.1
github.com/hashicorp/go-multierror v1.0.0
github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5 // indirect
github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/leesper/go_rng v0.0.0-20190531154944-a612b043e353 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/mattn/go-isatty v0.0.10 // indirect
github.com/pkg/errors v0.8.1
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/pkg/errors v0.9.1
github.com/segmentio/go-prompt v1.2.1-0.20161017233205-f0d19b6901ad // build fails otherwise
github.com/shuheiktgw/go-travis v0.2.4
github.com/sirupsen/logrus v1.4.2
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56 // indirect
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 // indirect
golang.org/x/tools v0.0.0-20191212203136-8facea2ecf42 // indirect
gonum.org/v1/gonum v0.0.0-20190802084026-e9a50d643359 // indirect
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d // indirect
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.4
gopkg.in/yaml.v2 v2.2.8
)
144 changes: 75 additions & 69 deletions go.sum

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ func unmarshalSinks(sinksIface interface{}) (sink.Sinks, error) {
client := cziAws.New(sess).WithSecretsManager(sess.Config)

sinks = append(sinks, &sink.AwsSecretsManagerSink{BaseSink: sink.BaseSink{KeyToName: keyToName}, Client: client})
case sink.KindStdout:
sinks = append(sinks, &sink.StdoutSink{BaseSink: sink.BaseSink{KeyToName: keyToName}})
default:
return nil, sink.ErrUnknownKind
}
Expand Down Expand Up @@ -280,6 +282,12 @@ func (secret Secret) MarshalYAML() (interface{}, error) {
"external_id": awsIamSrc.ExternalID,
"max_age": awsIamSrc.MaxAge.String(),
}
case source.KindEnv:
envSource := secret.Source.(*source.Env)
secretFields["source"] = map[string]string{
"kind": string(source.KindEnv),
"name": envSource.Name,
}
default:
return nil, errors.New("Unrecognized source")
}
Expand Down
1 change: 1 addition & 0 deletions pkg/sink/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
KindTravisCi Kind = "TravisCI"
KindAwsParamStore Kind = "AWSParameterStore"
KindAwsSecretsManager Kind = "AWSSecretsManager"
KindStdout Kind = "Stdout"
ErrUnknownKind Error = "UnknownSink"
)

Expand Down
29 changes: 29 additions & 0 deletions pkg/sink/stdout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package sink

import (
"context"
"fmt"
)

// A StdoutSink
type StdoutSink struct {
BaseSink `yaml:",inline"`
}

func NewStdoutSink() *StdoutSink {
return &StdoutSink{}
}

func (sink *StdoutSink) WithKeyToName(m map[string]string) *StdoutSink {
sink.BaseSink = BaseSink{KeyToName: m}
return sink
}

func (sink *StdoutSink) Write(ctx context.Context, name string, val string) error {
fmt.Printf("sink:stdout: \n name: %s, val: %#v\n", name, val)
return nil
}

func (sink *StdoutSink) Kind() Kind {
return KindStdout
}
10 changes: 10 additions & 0 deletions test_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 1
secrets:
- name: test
source:
kind: env
name: TEST_ENV
sinks:
- kind: Stdout
key_to_name:
TEST_ENV: test_env
93 changes: 93 additions & 0 deletions vendor/github.com/aws/aws-sdk-go/aws/arn/arn.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/aws/aws-sdk-go/aws/awsutil/path_value.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/github.com/aws/aws-sdk-go/aws/client/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions vendor/github.com/aws/aws-sdk-go/aws/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading