Skip to content

Commit

Permalink
Template parameters can have blank Default.
Browse files Browse the repository at this point in the history
  • Loading branch information
pda committed Feb 22, 2018
1 parent 187e3de commit 7c75d26
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 2 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ type ParameterItem struct {
}

type ParsedParameterSpec struct {
Type string `yaml:"Type"`
Description string `yaml:"Description"`
Default string `yaml:"Default"`
Default *string `yaml:"Default",omitempty`
}

type ParsedTemplate struct {
Expand Down Expand Up @@ -109,7 +107,7 @@ func getJsonForInput(input *Input) ([]byte, error) {

specs := make(map[string]ParameterSpec)
for name, parsed := range t.Parameters {
specs[name] = ParameterSpec{Name: name, HasDefault: parsed.Default != ""}
specs[name] = ParameterSpec{Name: name, HasDefault: parsed.Default != nil}
}

if err := validateParameters(input.Parameters, specs); err != nil {
Expand Down
9 changes: 9 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ func TestDeployScenario(t *testing.T) {
}
}

func TestBlankDefault(t *testing.T) {
input := &Input{
TemplateBody: []byte("Parameters:\n Foo:\n Default: \"\"\n"),
AcceptDefaults: true,
}
actual := mustGetParameterItems(t, input)
assert.Equal(t, 0, len(actual))
}

func mustGetParameterItems(t *testing.T, input *Input) []ParameterItem {
j, err := getJsonForInput(input)
require.NoError(t, err)
Expand Down

0 comments on commit 7c75d26

Please sign in to comment.