Skip to content

Commit

Permalink
support GO_FORMAT strings
Browse files Browse the repository at this point in the history
  • Loading branch information
lindt committed Aug 14, 2016
1 parent 53907e0 commit a0c2d99
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compose_format/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def order(item):
return sorted([ComposeFormat.reorder(item, strict=strict) for item in data])
if len(str(data)) >= 1 and str(data)[0].isdigit():
return '\'{0}\''.format(data)
if str(data).startswith('{'):
return '\'{0}\''.format(data)
return data

@staticmethod
Expand Down
19 changes: 19 additions & 0 deletions features/format.feature
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,22 @@ Feature: Format
bbb: unknown
ccc: unknown
"""

Scenario: Objects with Go Format Strings
Given a file named "compose.yml" with:
"""
foo:
image: bar
logging:
options:
tag: "{{.Name}}"
"""
When I run `bin/compose_format --non_strict compose.yml`
Then it should pass with exactly:
"""
foo:
image: bar
logging:
options:
tag: '{{.Name}}'
"""

0 comments on commit a0c2d99

Please sign in to comment.