-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
Don't munge types in Docker registry config values. #21649
Don't munge types in Docker registry config values. #21649
Conversation
b08c71e
to
2b88f41
Compare
extra_image_tags=tuple( | ||
d.get("extra_image_tags", DockerRegistryOptions.extra_image_tags) | ||
), | ||
repository=Parser.to_value_type(d.get("repository"), str, None), |
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.
This was particularly unnecessary, since all that function does when you pass str
as the type is cast...
To clarify, I think using the wrong type is a potential sign of larger error, and we shouldn't be attempting to coerce input types. We can validate them, perhaps, but that is a separate thing, and a pretty arbitrary one. |
@@ -52,13 +51,13 @@ def from_dict(cls, alias: str, d: dict[str, Any]) -> DockerRegistryOptions: | |||
return cls( | |||
alias=alias, | |||
address=d["address"], |
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.
Note that we never validated the type (or presence) of d["address"]
for example. I prefer to be uniformly strict than have some arbitrary semi-validation that follows no rhyme or reason.
We document a schema for the registries dict, including
specifying that certain fields should be bool-valued.
I see no need to coerce those values into bools if they
were actually strings, especially since we don't document
that we do that (AFAICT).
We should require users to adhere to the published schema.
If this "breaks" users, well, they were accidentally relying on
unadvertised leniency, and the fix is extremely easy.
Note that this coercion was very ad hoc. We don't apply it
uniformly across all fields in the docker registry config,
and we certainly don't do this in other dict-valued options
across the repo.
This gets rid of a spurious dependency of the Docker backend
on internal code of the legacy options parser.