Skip to content

Commit

Permalink
fix normalizing input for initializing multiline resources
Browse files Browse the repository at this point in the history
  • Loading branch information
drlau committed Oct 12, 2020
1 parent 9cc1d28 commit 2f52be0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ func parseResource(s *bufio.Scanner) (*ResourceChange, error) {
}

func parseMapAttribute(s *bufio.Scanner) (*MapAttributeChange, error) {
result, err := NewMapAttributeChangeFromLine(s.Text())
normalized := formatInput(s.Bytes())
result, err := NewMapAttributeChangeFromLine(normalized)
if err != nil {
return nil, err
}
if IsOneLineEmptyMapAttribute(s.Text()) {
if IsOneLineEmptyMapAttribute(normalized) {
return result, nil
}

Expand Down Expand Up @@ -154,11 +155,12 @@ func parseMapAttribute(s *bufio.Scanner) (*MapAttributeChange, error) {
}

func parseArrayAttribute(s *bufio.Scanner) (*ArrayAttributeChange, error) {
result, err := NewArrayAttributeChangeFromLine(s.Text())
normalized := formatInput(s.Bytes())
result, err := NewArrayAttributeChangeFromLine(normalized)
if err != nil {
return nil, err
}
if IsOneLineEmptyArrayAttribute(s.Text()) {
if IsOneLineEmptyArrayAttribute(normalized) {
return result, nil
}
// TODO: all elements of array attributes are the same type
Expand Down Expand Up @@ -200,7 +202,8 @@ func parseArrayAttribute(s *bufio.Scanner) (*ArrayAttributeChange, error) {
}

func parseHeredocAttribute(s *bufio.Scanner) (*HeredocAttributeChange, error) {
result, err := NewHeredocAttributeChangeFromLine(s.Text())
normalized := formatInput(s.Bytes())
result, err := NewHeredocAttributeChangeFromLine(normalized)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2f52be0

Please sign in to comment.