-
Notifications
You must be signed in to change notification settings - Fork 191
restart: no gets interpreted as restart: false #67
Conversation
e1a58e2
to
c5de80c
Compare
if v.Restart == "false" { | ||
v.Restart = "no" | ||
} | ||
} |
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 don't think this is the direction we want to go. We've decided against it in docker-compose
(at least for now).
Re-writing boolean values to string values is not really intuitive. Could we instead warn the user that they have the wrong type?
I think this will just fix itself when #34 is completed. The jsonschema will raise a validation error if this field is a boolean
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.
@dnephin I don't totally follow. The issue is this... If the user does the below
image:
restart: no
The yaml parser turns restart: no
into restart: false
. We need to then manually change restart: false
back to restart: no
.
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.
No, the yaml parser isn't wrong, the user is wrong.
If you go that route, you end up translating a bunch of things that aren't no
into "no"
.
Using a boolean in a string field should result in an error. The user should write restart: 'no'
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 user is always right 😄 So seriously you don't want this? This matches the behaviour of docker-compose
today. restart: no
works in docker-compose without restart: 'no'
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.
We're changing it to a warning in the next release (1.5.0) now that we're properly validating the config. It'll become an error in the release after that.
I'm not sure how it works, since we shouldn't be doing any conversion of bool to string.
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.
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'm not sure how it works, but I agree we should revisit after validation is in
a207409
to
c041413
Compare
ConfigLookup: &NullLookup{}, | ||
}) | ||
|
||
config, err := Merge(p, []byte(` |
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.
Ah you need to update that I think, to mergeProject
.
The yaml parser seems to turn `restart: no` into `restart: false` and false is not a valid restart policy. This patch manually fixes up the value to be `no` if it is read as `false`. Signed-off-by: Darren Shepherd <darren@rancher.com>
c041413
to
a6c419f
Compare
@vdemeester Fix compilation errors with |
So, we are ok to merge this as is and we'll get back on it when validation hits, right ? (thus we follow |
@vdemeester I believe that is the agreement. I've created an issue to track this: #72 |
I think the reason this doesn't fail validation in compose 1.4.2 is because the check I'm not against merging this, but it will become dead code as soon as #34 is implemented |
Not against either 😉 |
restart: no gets interpreted as restart: false
documentation still suggest unquoted version: https://docs.docker.com/compose/compose-file/compose-file-v2/#restart and that results failure on 1.9.0:
|
@glensc hum this PR is quite old though, we have schema validation now, that should be the same as docker-compose, I would guess it's doing the same with libcompose 👼 |
The yaml parser seems to turn
restart: no
intorestart: false
andfalse is not a valid restart policy. This patch manually fixes up the
value to be
no
if it is read asfalse
.This is based off of #66 because in that PR I added
merge_test.go
and didn't want to duplicate it and then have to deal with merge conflicts/rebasing.