-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Docker: Ignore ARGs without default values #4723
Conversation
In #4598 we added support for ARG FROM. However, this assumed that a default value is always specified, when it isn't the code would crash. This is not that common, however: Due to how we parse Dockerfiles, this actually also happened for regular `ARG`s in a Dockerfile, even if it didn't belong to the `FROM`, meaning that any ARG without a default would cause our update to fail.
end | ||
|
||
context "arg from" do | ||
let(:dockerfile_fixture_name) { "arg_from_curls" } | ||
|
||
describe "with curls" do | ||
let(:dockerfile_fixture_name) { "arg_from_curls" } | ||
|
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.
nice fix
key_value = line.delete_prefix("ARG ").split("=") | ||
next if key_value.count != 2 # The ARG has no default value that we can set | ||
|
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 I fully understand how this piece works. Here we split on =
, but the example in the fixture file doesn't have an =
so HUB in ARG HUB
does not qualify as a default argument?
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.
You would need to pass it in from the commandline:
docker build --build-arg=HUB=docker.io .
But since Dependabot can't know the value in this case, we don't perform an update
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.
That makes a lot more sense in context 👍🏾
Sorry, this still fails, because I forgot to update the file-updater... |
For anyone who stumbles across this later, ☝️ is tracked in #4725. |
In #4598 we added
support for ARG FROM. However, this assumed that a default value is
always specified, when it isn't the code would crash.
This is not that common, however:
Due to how we parse Dockerfiles, this actually also happened for regular
ARG
s in a Dockerfile, even if it didn't belong to theFROM
, meaningthat any ARG without a default would cause our update to fail.