-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c30c085
commit 5392c0d
Showing
37 changed files
with
2,093 additions
and
792 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package arm | ||
|
||
import ( | ||
"bytes" | ||
"sato/src/cf" | ||
tftemplate "text/template" | ||
|
||
"github.com/rs/zerolog/log" | ||
) | ||
|
||
// parseData writes out to data.tf | ||
func parseData(result map[string]interface{}, funcMap tftemplate.FuncMap, destination string) error { | ||
if result["data"] == nil { | ||
return nil | ||
} | ||
|
||
data := result["data"] | ||
|
||
var output bytes.Buffer | ||
tmpl, err := tftemplate.New("test").Funcs(funcMap).Parse(string(dataFile)) | ||
if err != nil { | ||
return err | ||
} | ||
err = tmpl.Execute(&output, m{ | ||
"data": data, | ||
}) | ||
|
||
if err != nil { | ||
log.Print(err) | ||
return err | ||
} | ||
|
||
err = cf.Write(output.String(), destination, "data") | ||
if err != nil { | ||
log.Print(err) | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package arm | ||
|
||
import ( | ||
"testing" | ||
"text/template" | ||
) | ||
|
||
func Test_parseData(t *testing.T) { | ||
t.Parallel() | ||
|
||
type args struct { | ||
result map[string]interface{} | ||
funcMap template.FuncMap | ||
destination string | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
}{ | ||
// {}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
if err := parseData(tt.args.result, tt.args.funcMap, tt.args.destination); (err != nil) != tt.wantErr { | ||
t.Errorf("parseData() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.