Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A number is a valid service name #1855

Merged
merged 1 commit into from
Aug 20, 2015

Conversation

mnowster
Copy link

While we technically allow a service name to be a number, it was causing the code
to blow up with a TypeError, as reported #1845.

This is due to it expecting a string or a buffer. So I took the approach to ensure all
service names get converted to strings.

Signed-off-by: Mazz Mosley mazz@houseofmnowster.com

@dnephin
Copy link

dnephin commented Aug 12, 2015

I was thinking the problem is that yaml treats a number as an integer, instead of a string. So the developer should probably write:

'2': 
    ...

I'm not sure about casting these to strings. Maybe we could just warn the developer of the type and have them fix the yaml?

@mnowster
Copy link
Author

@dnephin Yeh I was in two minds about it myself, partly because I didn't want to force the user to do extra work for something that feels like it should work but then conflicted of casting everything to a string 🎱

Thinking about it some more and talking it over with @aanand, I think you're right and this is a good suggestion, thanks. Importantly with your approach we can always change our minds later, if we go with cast all to strings, we can't as easily change track.

@mnowster mnowster changed the title A number is a valid service name WIP: A number is a valid service name Aug 13, 2015
@mnowster mnowster force-pushed the number-is-a-valid-service-name branch from b15675e to e0906a2 Compare August 13, 2015 15:31
In order to validate a service name that has been specified as an
integer we need to run that as a pre-process validation step
*before* we pass the config to be validated against the schema.

It is not possible to validate it *in* the schema, it causes a
type error. Even though a number is a valid service name, it
must be a cast as a string within the yaml to avoid type error.

Taken this opportunity to move the code design in a direction
towards:

1. pre-process
2. validate
3. construct

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
@mnowster mnowster force-pushed the number-is-a-valid-service-name branch from e0906a2 to 67995ab Compare August 13, 2015 15:32
@mnowster mnowster changed the title WIP: A number is a valid service name A number is a valid service name Aug 13, 2015
@aanand
Copy link

aanand commented Aug 20, 2015

LGTM

aanand added a commit that referenced this pull request Aug 20, 2015
@aanand aanand merged commit a806d9e into docker:master Aug 20, 2015
@mnowster mnowster deleted the number-is-a-valid-service-name branch August 31, 2015 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants