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

feat: expand env variable by default #7173

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

Conversation

wingyplus
Copy link
Contributor

@wingyplus wingyplus commented Apr 24, 2024

Fixes #7171

The withEnvVariable API will expand shell env variable by default. And
add noExpand option to do not expand when it's set to true. The
expand option is now deprecated but still compatible with the previous
version.

@wingyplus wingyplus marked this pull request as draft April 24, 2024 10:56
@wingyplus
Copy link
Contributor Author

Just open a PR to see what you thought. If you're all agree, I can put this work forward. :)

@wingyplus wingyplus marked this pull request as ready for review April 24, 2024 15:50
@wingyplus
Copy link
Contributor Author

wingyplus commented Apr 24, 2024

I hit an issue on Go SDK now. When I change Expand default in GraphQL api to true. The no expand variable test get failure:

=== NAME  TestContainerWithEnvVariableExpand/add_env_var_without_expansion
    container_test.go:1080: 
                Error Trace:    /home/wingyplus/src/github.com/dagger/dagger/core/integration/contain
                Error:          Not equal: 
                                expected: "foo:$PATH\n"
                                actual  : "foo:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbi
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1,2 @@
                                -foo:$PATH
                                +foo:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
                                 
                Test:           TestContainerWithEnvVariableExpand/add_env_var_without_expansion

After digging into an issue. The WithEnvVarible Go SDK api detect optional argument by IsZero, cause boolean value not set to query when Expand is false.

If I understand it correctly, we need to modify the codegen to always pass the boolean value. Or we have another way to fix this?

@helderco
Copy link
Contributor

If I understand it correctly, we need to modify the codegen to always pass the boolean value. Or we have another way to fix this?

Yeah, I guess we've always avoided this. Even in #7136, the way to flip the default on skipEntrypoint is to deprecate it in favor of a new useEntrypoint.

To do the same here we'd need a new option like noExpand that defaults to false. It also helps with the deprecation because you can detect if someone is using the older expand or not.

@wingyplus
Copy link
Contributor Author

@helderco I just add noExpand option as you suggested. I'm not sure how to do with expand so I make it compatible for now. 🙏

The `withEnvVariable` API will expand shell env variable by default. And
add `noExpand` option to do not expand when it's set to `true`. The
`expand` option is now deprecated but still compatible with the previous
version.

Updates dagger#7171

Signed-off-by: Thanabodee Charoenpiriyakij <[email protected]>
@helderco
Copy link
Contributor

helderco commented May 7, 2024

Waiting on status of:

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.

Allow env variable interpolation in Container.withEnvVariable
2 participants