Skip to content

Commit

Permalink
Merge pull request #1 from ixydo/variable-depth-path
Browse files Browse the repository at this point in the history
Variable depth path
  • Loading branch information
jinnko authored Apr 6, 2018
2 parents 77c61e0 + c491f2f commit 32f6da2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ release: gh-release clean dist
govendor sync
github-release release \
--security-token $$GH_LOGIN \
--user segmentio \
--user ixydo \
--repo chamber \
--tag $(VERSION) \
--name $(VERSION)

github-release upload \
--security-token $$GH_LOGIN \
--user segmentio \
--user ixydo \
--repo chamber \
--tag $(VERSION) \
--name chamber-$(VERSION)-darwin-amd64 \
--file dist/chamber-$(VERSION)-darwin-amd64

github-release upload \
--security-token $$GH_LOGIN \
--user segmentio \
--user ixydo \
--repo chamber \
--tag $(VERSION) \
--name chamber-$(VERSION)-linux-amd64 \
Expand Down
11 changes: 5 additions & 6 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ func list(cmd *cobra.Command, args []string) error {

func key(s string) string {
_, noPaths := os.LookupEnv("CHAMBER_NO_PATHS")
if !noPaths {
tokens := strings.Split(s, "/")
secretKey := tokens[2]
return secretKey
sep := "/"
if noPaths {
sep = "."
}

tokens := strings.Split(s, ".")
secretKey := tokens[1]
tokens := strings.Split(s, sep)
secretKey := tokens[len(tokens)-1]
return secretKey
}
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// Regex's used to validate service and key names
var (
validKeyFormat = regexp.MustCompile(`^[A-Za-z0-9-_]+$`)
validServiceFormat = regexp.MustCompile(`^[A-Za-z0-9-_]+$`)
validServiceFormat = regexp.MustCompile(`^[A-Za-z0-9-_\/.]+$`)

numRetries int
chamberVersion string
Expand Down Expand Up @@ -51,7 +51,7 @@ func Execute(vers string) {

func validateService(service string) error {
if !validServiceFormat.MatchString(service) {
return fmt.Errorf("Failed to validate service name '%s'. Only alphanumeric, dashes, and underscores are allowed for service names", service)
return fmt.Errorf("Failed to validate service name '%s'. Only alphanumeric, dashes, forwardslases, fullstops and underscores are allowed for service names", service)
}
return nil
}
Expand Down
7 changes: 4 additions & 3 deletions store/ssmstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const (

// validPathKeyFormat is the format that is expected for key names inside parameter store
// when using paths
var validPathKeyFormat = regexp.MustCompile(`^\/[A-Za-z0-9-_]+\/[A-Za-z0-9-_]+$`)
var validPathKeyFormat = regexp.MustCompile(`^\/[A-Za-z0-9-_/]+$`)

// validKeyFormat is the format that is expected for key names inside parameter store when
// not using paths
var validKeyFormat = regexp.MustCompile(`^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$`)
var validKeyFormat = regexp.MustCompile(`^[A-Za-z0-9-_.]+$`)

// ensure SSMStore confirms to Store interface
var _ Store = &SSMStore{}
Expand Down Expand Up @@ -501,7 +501,8 @@ func basePath(key string) string {
if len(pathParts) == 1 {
return pathParts[0]
}
return "/" + pathParts[1]
end := len(pathParts) - 1
return strings.Join(pathParts[0:end], "/")
}

func parameterMetaToSecretMeta(p *ssm.ParameterMetadata) SecretMetadata {
Expand Down

0 comments on commit 32f6da2

Please sign in to comment.