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

Allow args without a value #25

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ghiculescu
Copy link

@ghiculescu ghiculescu commented Mar 9, 2023

This is a WIP. I'd appreciate some help with it, as well as confirmation it's worth doing.

In a Dockerfile, the ENV keyword requires a name and value. But ARG just requires a name; a default value is optional. There's some examples here, and another one here which is what led me to this.

So this PR allows you to provide args without a default value.

@ghiculescu
Copy link
Author

I can't get the tests to run at the moment.

Error:
TestArg#test_env:
Errno::ENOENT: No such file or directory @ rb_sysopen - Dockerfile
    /Users/alex/Code/dockerfile-rails/test/base.rb:43:in `read'
    /Users/alex/Code/dockerfile-rails/test/base.rb:43:in `check_dockerfile'
    test/test_arg.rb:10:in `test_env'

Can come back to this another time, posting here in case anyone has any tips...

@rubys
Copy link
Collaborator

rubys commented Mar 9, 2023

I approved running of the tests, so you can see the results.

Note that test/base.rb replaces arg values in the actual and expected results with xxx so that (for example) you can run the tests with a different node version and have the tests pass.

Given that any option you specify is saved to dockerfile.yml and included by default in subsequent runs, I'd like for there to be some way to remove an ARG that you previously specified without requiring manual edit of the dockerfile.yml file itself.

@caius
Copy link

caius commented Feb 8, 2024

Given that any option you specify is saved to dockerfile.yml and included by default in subsequent runs, I'd like for there to be some way to remove an ARG that you previously specified without requiring manual edit of the dockerfile.yml file itself.

(Just as a side note, from the start I've found this a slightly odd design decision. If I'm removing something from the existing config or changing it, I go edit the config file and treat bin/rails g dockerfile as the command to regenerate it rather than driving it from the CLI. Appreciate that's probably not up for debate now though 😀)

That said, I wonder if we could use the somewhat common practice of prepending no- to flags to remove things. So running --no-arg=IMPORTANT:value would delete the ARG IMPORTANT="value" from the Dockerfile, and running --arg=IMPORTANT would add ARG IMPORTANT to the Dockerfile?

Means there's a clear distinction between "I want to remove this arg entirely" and "I want this arg required without a value set".

@rubys
Copy link
Collaborator

rubys commented Feb 8, 2024

So running --no-arg=IMPORTANT:value would delete the ARG IMPORTANT="value"

Seems reasonable (though I would argue against including :value in --no-arg)

@caius
Copy link

caius commented Feb 8, 2024

So running --no-arg=IMPORTANT:value would delete the ARG IMPORTANT="value"

Seems reasonable (though I would argue against including :value in --no-arg)

Ugh, knew I’d missed something obvious. Agreed, just --no-arg=IMPORTANT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants