-
Notifications
You must be signed in to change notification settings - Fork 573
bake: default variable to null if not defined #2530
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Although I agree that this is a better default, it is a breaking change and if there are users atm who don't define default and rely on it being empty string, this change would break their files either by giving a parse error or sending a different value to buildkit. So I'm not sure if this is worth the risk as currently users can define |
Agreed if we add some validation flavor to variables similar to what terraform does: #491 (comment). I move this one to bake-ga milestone. |
@rrjjvv is there anything we should do here still or should we just close this? |
Funny you should ask... there's a couple reasons why my docs PR is in draft mode. One of them was very related to this. When going through the original docs top-to-bottom trying to match language/style, I noticed the docs about Tonight I was going to write some quick tests to validate the behavior, hoping it works as expected. I'll also take a closer look at this PR and related issues at the same time. Hopefully it all "just works" and resolves this issue as well. I'll let you know what I think/find after I get a chance to digest/revisit. |
TL;DR; I think you can close this, though one of your earlier comments/ideas is still valid and should be explicitly decided. My original (potential) concern was As far as this actual issue...
Currently, specifying a typed variable with no default and no override results in an empty string, regardless of type. While that may be convenient (or expected given current non-typed behavior), I don't think it's logical. A case could be made for either |
I did some of my own tests. It is somewhat weird though.
Ideally I think at least the array types should be null. Additionally, if I add:
Then I get
Looks like type was not set to list at all if |
Similar:
but with defaults
And if I set it to |
Agreed/understood.
I assume that was in the context of possibly changing the array types. Whether it's "too late" is up to you folks... I don't know if you're release schedule is time-based, feature-based, or what. But it should not be difficult or time-consuming to make the changes. I'd be more than happy to. (I just looked at recent release history, and assuming the patterns aren't coincidence, you're likely looking to release 'very soon'. I have some flexibility and can implement changes quicker than I normally would if time is a factor.)
Yup, and why I'm personally consider it a bug (albeit, unreleased). In all cases where typing was provided, the end result was an empty string. That's why you were getting those various errors for the tuple/list, and why that non-sensical ternary "worked". It's not really that the variable itself loses its type, it's that the 'resolution' step is incorrect (the point where the variable is getting assigned to the arg), if that makes sense. While it looks like the opposite on the surface, it's the same thing happening when you have Hope that made sense. It's pretty clear when you see it in the form of tests (and resulting failures). |
We need to cut GA tomorrow, but we can document that for this release users should always define default value if they set |
In the actual docs, i.e. I should add a snippet in my documentation PR? Or something you'll take care of in the release notes? |
In both, but it looks like #3198 might still make it so let's not do that yet. |
fixes #2529
With
null
val supported for variables in #1449, we should default to this type instead of empty string. Might have been an oversight.