Skip to content

Commit

Permalink
Addition of a NULL Backend to provide a simple way of disabling backend
Browse files Browse the repository at this point in the history
lookups
  • Loading branch information
maartenvanderhoef committed Sep 27, 2018
1 parent bbd6729 commit d2451a0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ To configure chamber to use the S3 backend, set `CHAMBER_SECRET_BACKEND` to `S3`

This feature is experimental, and not currently meant for production work.

## Null Backend (experimental)

If it's preferred to not use any backend at all, set `CHAMBER_SECRET_BACKEND` to `NULL`. Doing so will forward existing ENV variables as if Chamber is not in between.

This feature is experimental, and not currently meant for production work.


## Releasing

To cut a new release, just push a tag named `v<semver>` where `<semver>` is a
Expand Down
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ const (
)

const (
NullBackend = "NULL"
SSMBackend = "SSM"
S3Backend = "S3"

BackendEnvVar = "CHAMBER_SECRET_BACKEND"
)

var Backends = []string{SSMBackend, S3Backend}
var Backends = []string{SSMBackend, S3Backend, NullBackend}

// RootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Expand Down Expand Up @@ -90,6 +91,8 @@ func getSecretStore() (store.Store, error) {
var s store.Store
var err error
switch backend {
case NullBackend:
s = store.NewNullStore()
case S3Backend:
s, err = store.NewS3Store(numRetries)
case SSMBackend:
Expand Down
37 changes: 37 additions & 0 deletions store/nullstore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package store

import (
"errors"
)

var _ Store = &NullStore{}

type NullStore struct{}

func NewNullStore() *NullStore {
return &NullStore{}
}

func (s *NullStore) Write(id SecretId, value string) error {
return errors.New("Write is not implemented for Null Store")
}

func (s *NullStore) Read(id SecretId, version int) (Secret, error) {
return Secret{}, errors.New("Not implemented for Null Store")
}

func (s *NullStore) List(service string, includeValues bool) ([]Secret, error) {
return []Secret{}, nil
}

func (s *NullStore) ListRaw(service string) ([]RawSecret, error) {
return []RawSecret{}, nil
}

func (s *NullStore) History(id SecretId) ([]ChangeEvent, error) {
return []ChangeEvent{}, nil
}

func (s *NullStore) Delete(id SecretId) error {
return errors.New("Not implemented for Null Store")
}

0 comments on commit d2451a0

Please sign in to comment.