-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dockerfile: implement additional expansions
Signed-off-by: Hank Donnay <[email protected]>
- Loading branch information
Showing
9 changed files
with
314 additions
and
42 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,5 @@ | ||
package dockerfile | ||
|
||
//go:generate -command stringer go run golang.org/x/tools/cmd/stringer | ||
//go:generate stringer -type itemKind | ||
//go:generate stringer -type varExpand -linecomment |
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,3 @@ | ||
error: dockerfile: bad expansion of "error": rogue colon | ||
-- Dockerfile -- | ||
LABEL a ${error::} |
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,15 @@ | ||
-- Dockerfile -- | ||
LABEL a ${unset} | ||
LABEL b ${unset=set} | ||
LABEL c ${unset} | ||
|
||
LABEL null= | ||
LABEL d ${null:=reset} | ||
-- Want -- | ||
{ | ||
"a": "", | ||
"b": "set", | ||
"c": "set", | ||
"d": "reset", | ||
"null": "" | ||
} |
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,3 @@ | ||
error: dockerfile: bad expansion of "unset": should error (error if unset or null) | ||
-- Dockerfile -- | ||
LABEL a ${unset:?should error} |
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,11 @@ | ||
-- Dockerfile -- | ||
ARG a=\" | ||
ARG a=\' | ||
ARG a=\\ | ||
ARG a=\b | ||
LABEL s='single\' quote: \\\b' d="double\" quote: \\\b\e" | ||
-- Want -- | ||
{ | ||
"s": "single' quote: \\\\b", | ||
"d": "double\" quote: \\\b\\e" | ||
} |
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,37 @@ | ||
-- Dockerfile -- | ||
ARG null='' | ||
LABEL dash_a ${unset-default} | ||
LABEL dash_b ${unset:-default} | ||
LABEL dash_c ${null-default} | ||
LABEL dash_d ${null:-default} | ||
LABEL plus_a ${unset+default} | ||
LABEL plus_b ${unset:+default} | ||
LABEL plus_c ${null+default} | ||
LABEL plus_d ${null:+default} | ||
|
||
ARG var=some-pattern. | ||
LABEL prefix ${var#*e} | ||
LABEL greedyprefix ${var##*e} | ||
LABEL suffix ${var%e*.} | ||
LABEL greedysuffix ${var%%e*.} | ||
LABEL singlechar ${var%?} | ||
LABEL greedysinglechar ${var%%?} | ||
LABEL noreplace ${var#\?} | ||
-- Want -- | ||
{ | ||
"dash_a": "default", | ||
"dash_b": "default", | ||
"dash_c": "", | ||
"dash_d": "default", | ||
"plus_a": "", | ||
"plus_b": "", | ||
"plus_c": "default", | ||
"plus_d": "", | ||
"prefix": "-pattern.", | ||
"greedyprefix": "rn.", | ||
"suffix": "some-patt", | ||
"greedysuffix": "som", | ||
"singlechar": "some-pattern", | ||
"greedysinglechar": "some-pattern", | ||
"noreplace": "some-pattern." | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.