Skip to content

Commit

Permalink
Add prepend flag and change function of the prefix flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogorzelski committed Feb 4, 2022
1 parent f2f8f33 commit 282e145
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Binary file added .DS_Store
Binary file not shown.
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
)

func main() {
prefix := flag.String("prefix", "", "Prefix to append to the ENV var names in the output")
prefix := flag.String("prefix", "", "Only fetch metadata items that match this prefix")
prepend := flag.String("prepend", "", "Prepend this string to the ENV var names in the output")
flag.Parse()

var client = &http.Client{
Expand Down Expand Up @@ -47,12 +48,14 @@ func main() {
}

for k, v := range items {
vars[strings.ToUpper(k)] = v
if strings.HasPrefix(k, *prefix) {
vars[strings.ToUpper(k)] = v
}
}

for k, v := range vars {
if *prefix != "" {
fmt.Printf("%s_%s=%s\n", *prefix, k, v)
if *prepend != "" {
fmt.Printf("%s_%s=%s\n", strings.ToUpper(*prepend), k, v)
} else {
fmt.Printf("%s=%s\n", k, v)
}
Expand Down

0 comments on commit 282e145

Please sign in to comment.