Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⭐️ Expose memory vault. #750

Merged
merged 1 commit into from
Jan 9, 2023
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
1 change: 1 addition & 0 deletions motor/vault/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var vaultMarshalNameMap = map[VaultType]string{
VaultType_AWSSecretsManager: "aws-secrets-manager",
VaultType_AWSParameterStore: "aws-parameter-store",
VaultType_GCPBerglas: "gcp-berglas",
VaultType_Memory: "memory",
}

func (t *VaultType) Value() string {
Expand Down
3 changes: 3 additions & 0 deletions motor/vault/config/vaultconfigstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"go.mondoo.com/cnquery/motor/vault/gcpberglas"
"go.mondoo.com/cnquery/motor/vault/gcpsecretmanager"
"go.mondoo.com/cnquery/motor/vault/hashivault"
"go.mondoo.com/cnquery/motor/vault/inmemory"
"go.mondoo.com/cnquery/motor/vault/keyring"
)

Expand All @@ -29,6 +30,8 @@ func New(vCfg *vault.VaultConfiguration) (vault.Vault, error) {
log.Debug().Str("vault-name", vCfg.Name).Str("vault-type", vCfg.Type.String()).Msg("initialize new vault")
var v vault.Vault
switch vCfg.Type {
case vault.VaultType_Memory:
v = inmemory.New()
case vault.VaultType_HashiCorp:
serverUrl := vCfg.Options["url"]
token := vCfg.Options["token"]
Expand Down
5 changes: 0 additions & 5 deletions motor/vault/inmemory/inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ func (v *inmemoryVault) Set(ctx context.Context, secret *vault.Secret) (*vault.S
return nil, errors.New("secret is empty")
}

if secret.Encoding != vault.SecretEncoding_encoding_undefined && secret.Encoding != vault.SecretEncoding_encoding_proto {
return nil, errors.New("only proto encoding is supported")
}

v.secrets[secret.Key] = secret
return &vault.SecretID{
Key: secret.Key,
Expand All @@ -59,6 +55,5 @@ func (v *inmemoryVault) Get(ctx context.Context, id *vault.SecretID) (*vault.Sec
if !ok {
return nil, vault.NotFoundError
}
s.Encoding = vault.SecretEncoding_encoding_proto
return s, nil
}
41 changes: 22 additions & 19 deletions motor/vault/vault.pb.go

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

1 change: 1 addition & 0 deletions motor/vault/vault.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum VaultType {
AWSSecretsManager = 6;
AWSParameterStore = 7;
GCPBerglas = 8;
Memory = 9;
}

message VaultConfiguration {
Expand Down