- fixing the enviroment variable expansion to permit underscores

This commit is contained in:
Rohith 2016-07-13 15:08:33 +01:00
parent b67a1f0b2e
commit f9e1634386
3 changed files with 10 additions and 2 deletions

View file

@ -26,7 +26,7 @@ import (
const (
Prog = "vault-sidekick"
Version = "v0.1.1"
Version = "v0.1.2"
)
func main() {

View file

@ -26,7 +26,7 @@ import (
)
var (
envRegex = regexp.MustCompile("%[[:alnum:]]+%")
envRegex = regexp.MustCompile("%[[:alnum:]_]+%")
)
// VaultResources is a collection of type resource

View file

@ -36,6 +36,7 @@ func TestSetResources(t *testing.T) {
assert.Nil(t, items.Set("pki:example-dot-com:common_name=blah.example.com,renew=true"))
assert.Nil(t, items.Set("secret:secrets/%ENV%/me:file=filename.test,fmt=yaml"))
assert.NotNil(t, items.Set("secret:"))
assert.NotNil(t, items.Set("secret:test:file=filename.test,fmt="))
assert.NotNil(t, items.Set("secret::file=filename.test,fmt=yaml"))
@ -75,6 +76,13 @@ func TestSetEnvironmentResource(t *testing.T) {
"THING": "yes",
},
},
{
ResourceText: "secret:secrets/%KUBERNETES_NAMESPACE%/me:file=filename.test,fmt=yaml",
ExpectedPath: "secrets/dev/me",
Vars: map[string]string{
"KUBERNETES_NAMESPACE": "dev",
},
},
}
for i, c := range tests {