-
Notifications
You must be signed in to change notification settings - Fork 176
[WIP] Hardening the interpolation of parameters containing special characters #587
base: master
Are you sure you want to change the base?
Conversation
internal/packager/init.go
Outdated
@@ -148,7 +148,8 @@ func initFromComposeFile(name string, composeFile string) error { | |||
} | |||
} | |||
} | |||
vars, err := compose.ExtractVariables(composeRaw, compose.ExtrapolationPattern) | |||
vars, err := compose.ExtractVariables(composeRaw, compose.ComposeExtrapolationPattern) | |||
fmt.Println(vars) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups
…. and -) not allowed by the original compose file format more robust. Docker App is now using 2 different regexps when parsing a .dockerapp file and processing a compose file to generate a .dockerapp Signed-off-by: Jean-Christophe Sirot <[email protected]>
164e4d0
to
72b27fc
Compare
Codecov Report
@@ Coverage Diff @@
## master #587 +/- ##
=========================================
+ Coverage 70.74% 72.55% +1.8%
=========================================
Files 55 54 -1
Lines 3247 2827 -420
=========================================
- Hits 2297 2051 -246
+ Misses 649 511 -138
+ Partials 301 265 -36
Continue to review full report at Codecov.
|
substitution = "[_a-z][._a-z0-9]*(?::?[-?][^}]*)?" | ||
delimiter = "\\$" | ||
substitution = "[_a-z][._a-z0-9-]*" | ||
composeSubstitution = "[_a-z][._a-z0-9]*(?::?[-?][^}]*)?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoud we add the .
here? The cli doesn't have it, I'm not sure we really need it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a true question. I added the .
to make this test pass
app/internal/packager/init_test.go
Line 47 in 8d52f6d
func TestInitFromComposeFileWithFlattenedParams(t *testing.T) { |
But I'm not sure if the tested usecase is legit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test is bogus since env variables can only be alphanumeric and _
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dots are necessary for the indentation levels in the parameters yaml
file.
As in:
app/internal/packager/init_test.go
Lines 75 to 78 in 8d52f6d
const expectedParameters = `ports: | |
service1: 9001 | |
service2: 9002 | |
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but here we are talking about variable substitution that the cli does, it can substitute an environment variable inside a compose file (using ${VARIABLE:-default_value}
notation. And an environment variable can only have [a-zA-Z_]+
. No dots.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test here is verifying the conversion of the valid compose file into a dockerapp file. But the compose file syntax does not support the dot notation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So one could say that it’s not a valid compose file :)
- What I did
Fixes #574
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)
TBD