Skip to content

Commit f1b7cdb

Browse files
committed
Capitalize variable names
1 parent c501dea commit f1b7cdb

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ var (
1111
}
1212

1313
templates = map[string]string{
14-
"plaintext": `export {{.Name}}="{{.Data}}"`,
15-
"json": `export {{.Name}}_{{.ContentKey}}="{{.ContentValue}}"`,
14+
"plaintext": `export {{ .Name | ToUpper }}="{{ .Data }}"`,
15+
"json": `export {{ .Name | ToUpper }}_{{ .ContentKey | ToUpper }}="{{ .ContentValue }}"`,
1616
}
1717

1818
parsers = map[string]ContentParser{

runner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func TestHappyPath(t *testing.T) {
7979
}
8080

8181
expected := `
82-
export mysecret="s3cr3t"`
82+
export MYSECRET="s3cr3t"`
8383

8484
assert.Equal(t, expected, string(content))
8585
}

writer.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"io"
6+
"strings"
67
"text/template"
78
)
89

@@ -15,7 +16,12 @@ type Writer struct {
1516

1617
// NewWriter creates a new writer
1718
func NewWriter(wr io.Writer, tmpl string) (*Writer, error) {
18-
t, err := template.New("").Parse(fmt.Sprintf(tmplLoop, tmpl))
19+
20+
funcMap := template.FuncMap{
21+
"ToUpper": strings.ToUpper,
22+
}
23+
24+
t, err := template.New("").Funcs(funcMap).Parse(fmt.Sprintf(tmplLoop, tmpl))
1925
if err != nil {
2026
return nil, err
2127
}

writer_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func TestWriteToStdin(t *testing.T) {
3030
_ = w.Write(s...)
3131

3232
expected := `
33-
export mysecret_user="root"
34-
export mysecret_password="s3cr3t"`
33+
export MYSECRET_USER="root"
34+
export MYSECRET_PASSWORD="s3cr3t"`
3535

3636
assert.Equal(t, expected, buf.String())
3737
}
@@ -68,8 +68,8 @@ func TestWriteToFile(t *testing.T) {
6868
}
6969

7070
expected := `
71-
export mysecret_user="root"
72-
export mysecret_password="s3cr3t"`
71+
export MYSECRET_USER="root"
72+
export MYSECRET_PASSWORD="s3cr3t"`
7373

7474
assert.Equal(t, expected, string(content))
7575
}

0 commit comments

Comments
 (0)