File tree Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Expand file tree Collapse file tree 4 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 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 {
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
33import  (
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 
1718func  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	}
Original file line number Diff line number Diff 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}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments