Skip to content

Make passing caller environment variables to modules more seamless #6112

Closed

Description

@sipsma

Right now callers can pass their environment variables to modules by just reading them and setting them to function arg values, e.g. w/ the cli:

dagger call my-function --some-arg $SOME_ARG_VALUE --other-arg env:OTHER_VALUE

This suffices for straightforward use cases but multiple users have found it to be tedious + clunky once you need to pass a lot of env vars. It also isn't ideal for some use cases where the caller may not know what they are even supposed to pass.

This issue is to discuss any possible improvements we can make.

One very obvious potential solution would be to just give module code an api to read these from the caller. We intentionally didn't go that route because it pokes a really big whole in the idea of modules being sandboxed. This is bad both from a security and portability perspective.

Some ideas around potential solutions (not mutually exclusive):

  1. Do give modules a way of reading env vars from the caller, but wrap it up in a "trust model" where callers have to (one way or another) explicitly allow a given module to do so (and ideally scope it to certain env vars).
  2. Formalize the ideas of "main" and "library" modules, make reading env vars an exclusive feature of "main" modules
    • We've talked vaguely about how there are certain modules that are meant to be invoked directly (what I called a "main" module here) and those that are just providing re-usable functionality for other modules ("library" modules)
    • The idea here would be to actually encode that idea in the module API. Main modules have to be invoked directly by a caller (i.e. either the CLI or an SDK running outside of a module). They are still sandboxed but are given extra abilities for more directly interacting with the caller.
    • We'd still want the trust model idea, but this would at least avoid the possibility of some transitive dependency module 10 deps deep trying to encode a bunch of logic that relies on the caller having variables being set, which feels like a potential massive footgun.
    • To be clear, I don't love this idea from a simplicity perspective (the less concepts the better), but I think it should be on the table, especially if other use cases for the distinction between main+library mods come up outside this

Activity

  1. shykes commented on Nov 15, 2023

    @shykes
    Contributor

    My preference would be to start with something more lightweight, like adding a convenience in the CLI, rather than making irreversible changes in the core... We have a lot to lose if we get this wrong: part of the appeal of the Zenith design is the encapsulation. It's easy to understand what the inputs and outputs of a function are. We should be very cautious about anything that risks breaking that.

    Here's what a CLI convenience might look like:

    • When calling a function from the CLI, if mandatory arguments of type string or secret are omitted in the CLI, a new default behavior kicks in
    • The new default behavior, for an unspecified argument foo, is to look up the environment variable FOO, and use its value.
    • This behavior would require an interactive prompt, and manual approval by the user (for safety)
    • This behavior could be explicitly disabled with a flag
    • If we add a more ambitious trust model later, it could cause this behavior to be enabled or disabled depending of the trust status of a module

    The end result of this CLI convenience is that, in the most common cases, one could set env variables in advance, and omit the bulk of repetitive arguments. This would solve the UX problem that is causing this feature request in the first place. All without compromising the hermetic nature of functions.

  2. nipuna-perera commented on Nov 15, 2023

    @nipuna-perera
    Contributor

    When designing this, please consider the Enterprise use cases too. For example, I have to pass-through my company proxy (sometimes authed) to multiple areas for us to be able to use dagger. Because anything that goes out of our network has to go through our egress proxy. This is kinda? related - #6077

  3. sipsma commented on Nov 15, 2023

    @sipsma
    ContributorAuthor

    The new default behavior, for an unspecified argument foo, is to look up the environment variable FOO, and use its value.

    @shykes I like the general idea of your proposal in that we could make this a CLI-exclusive piece of functionality to start.

    The auto-matching of arg name to env var would be the most magical part and I can definitely think of various corner cases or situations it might not handle super well. But that's obviously fine provided we at least improve the situation significantly.

    I'm thinking about:

    1. Args that happen to have names of common env vars (path, lang, etc.) but are never intended to be read from the caller env
      • This could probably be addressed by just inverting the behavior so that auto reading env vars is not the default and instead has to be explicitly opted into by the caller?
    2. The args having to be required, not optional, could be sort of limiting in a case where the ideal order of preference would be A) explicit value set by user B) value set by caller's env C) some fallback default value

    But again, entirely possible those cases don't matter, so I'm curious from users who have run into a need for this: would the idea Solomon outlined work for you? I'm especially interested in the env vars you want from the caller and whether those translate well into required args w/ matching names.

  4. sagikazarmark commented on Nov 15, 2023

    @sagikazarmark
    Contributor

    I have two use cases in mind where passing environment variables through would be beneficial:

    • Using a CI/CD solution with a builtin secret management option
    • Making the same pipeline behave differently in different environments

    I understand using GHA's or Jenkins' secret management solution is not ideal for many reasons, but it's the reality today, especially for companies just getting started. Being able to introduce Dagger to an existing pipeline step-by-step is crucial for adoption.

    On the DX side: I realized I just don't enjoy writing a function with dozens of parameter. Everything in me tells me not to do it. If I have to give up those principles in Dagger...that's not a great experience.

    On the UX side: I don't enjoy passing an endless number of arguments to commands either. Regardless if it's in the GHA yaml hell or in my Makefile.

    I'm not sure adding new behavior on top of function arguments is going to improve that DX/UX for me. I would have to keep in mind how it works, that behavior is not immediately obvious from the code. Also, having to match parameter names with env var names....is a deep rabbit hole I'd like to stay away from (learned my lesson with Viper).

    Combining this issue with another one (too many function arguments), one potential solution is being able to pass in structs to functions:

    type Args struct {
        RunningInGHA Optional[bool]   `env:CI`
        GitHubToken Optional[*Secret] `env:GITHUB_TOKEN`
    }
    
    func (m *Ci) Ci(args Args) error {
        // ...
    }

    Keeping security in mind, I agree that this should probably be limited to main modules (though it may become an inconvenience at some point if you have to pass a GitHub Token to every single module).

    I could also imagine adding an explicit list of env vars to dagger.json to pass through.

    I wouldn't mind using some sort of experimental flag/config for this while the final details are being worked out (eg. dagger.experimental.json), although that's another incredibly deep rabbit hole.

    I don't think the case for env vars is going away anytime soon and changing the semantics drastically and implicitly is going to make it harder for people to understand what's going on.

  5. sipsma commented on Nov 15, 2023

    @sipsma
    ContributorAuthor

    Thanks for the thoughts @sagikazarmark, still digesting fully but want to leave some immediate thoughts before I forget:

    1. The problem around too many args in go is a big problem I agree, and definitely has some overlap here. We actually do have (undocumented) support for something along these lines where you can use an anonymous struct as args and they get turned into function parameters:
    func (m *MyMod) Fn(struct {
       Foo string
       Bar Optional[int]
    }) error {
     // ...
    }

    But we haven't fully fleshed it out and there's a handful of problems to figure out still. Support for custom struct tags (which could encompass the idea of the env tag you used) is also something that comes up along with it.

    Just letting you know that it's on our radar.


    1. Another idea that just occurred to me is this whole issue could have overlap with Call Dagger Functions from an external client #5993

    The idea being that we bucket the sorts of use cases that call for "complex interaction between the caller host and modules" into "advanced use cases" and thus require that rather than invoking the CLI directly users write Dagger SDK code that implements the logic (reading the right env vars or other host resources and passing them as the right arguments).

    So with #5993 you'd be able to write a short dagger script that runs on the host but can still easily call modules. You'd just use dagger run rather than dagger call.

    I think approach strongly requires that the majority of use cases calling for this behavior are those that run in CI or other "non-human" environments. If, however, many users want this "auto-read env var" support for use cases that involve direct human interaction, it breaks down and would at minimum require tons more polish or just be non-viable.

    The most compelling argument for this is that Dagger is already scriptable and runnable outside of modules, so why not use that existing functionality to support these sorts of use cases. It also makes sense in that it's may be a sisyphean task to really support every possible variation on how users could want to map caller env vars (and other host resources) to module function args.

    I could keep going but curious what others' immediate reactions are.

  6. nipuna-perera commented on Nov 15, 2023

    @nipuna-perera
    Contributor
    • Using a CI/CD solution with a builtin secret management option
    • Making the same pipeline behave differently in different environments

    This is a MAJOR part of the appeal of dagger for us. Simply being able to run the same pipeline in local and in CI is a top feature of dagger for us. We simply can't drop our existing CI systems and with dagger, having to maintain dagger code + CI system DSL will reduce the appeal of dagger within my company.

    Can I add another suggestion? Tell me if I'm crazy and this is a no-no.

    How about using dagger.json to have a passthrough_env_args where the module developer defines the env vars that are used by the module (required and optional). Then that can be documented (even printed out in the module CLI reference) by the module author and the consumer will have a clear idea of what ENV vars are passed through. Dagger CLI can put safeguards to prevent (or have a flag to opt-in) the passthrough ENV.

    We can even give the choice to the module developer on when they can use the ENVs. They are exposed as internal ENV to every function within the module but the function dev will have to do something like os.GetEnv to actually use them. They can unset ENVs as they please as well if they absolutely don't want an ENV present within the function scope.

    I don't know if there are any architectural/technical limitations to something like that. But I can see a few benefits

    Pros

    • ENV vars that are passthrough are fully transparent to the consumer (checked in dagger.json + generated CLI output)
    • No issue with function parameters being bloated.
    • Consumer can opt out and the module may or may not work if they do (It's up to the module author/s to code defensively around that scenario)
    • No limit as to where the module can run and can use dagger call
    • Not reliant on auto deriving ENV var names. Upto module author to pick non-conflicting vars. Maybe prefixed with the module name like MYDAGGERMOD_HTTP_PROXY.
    • less magic

    Cons

    • Consumer opting out may break module
    • dagger.json could start to get bloated
    • less magic?
    • Complicates module to module calls. I can't think of a good solution to that right now. I'm thinking module authors will have to provide convenience functions to pass through env vars from calling modules through withFunction pattern or similar.
    • Anything else I am missing (probably a LOT)
  7. sagikazarmark commented on Nov 15, 2023

    @sagikazarmark
    Contributor

    Thanks @sipsma!

    We actually do have (undocumented) support for something along these lines where you can use an anonymous struct as args and they get turned into function parameters:

    Yeah, I'm aware of that feature, but it falls in the bucket of "I don't enjoy writing that code".
    For that reason I avoid using it entirely, even temporarily.

    The idea being that we bucket the sorts of use cases that call for "complex interaction between the caller host and modules" into "advanced use cases" and thus require that rather than invoking the CLI directly users write Dagger SDK code that implements the logic (reading the right env vars or other host resources and passing them as the right arguments).

    I haven't decided if it's the right way to think about this, but one of the reasons I liked switching to Zenith is the ability to drop Mage (and even Go) as a dependency for running my pipelines. If I understand correctly, this would essentially bring those back as dependencies.

    I can't really imagine how this would look like, particularly the env var pass through, but I probably wouldn't want some additional step or code in my pipeline just to read env vars.

    I could keep going but curious what others' immediate reactions are.

    My immediate reaction to your second point: I just want env vars to work. 😄 I'd prefer if I it would require minimal work from me to achieve that. And I also want it to be obvious to whoever reads my pipeline code how it works.

    Doesn't mean I'm right though. 😄

  8. Mjb141 commented on Nov 15, 2023

    @Mjb141

    My immediate reaction to your second point: I just want env vars to work. 😄 I'd prefer if I it would require minimal work from me to achieve that. And I also want it to be obvious to whoever reads my pipeline code how it works.

    Doesn't mean I'm right though. 😄

    This is essentially what I'm looking for as well. Env vars 'just work' in almost every tool out there, I don't want to have to explain to colleagues that they now need to do something else with env vars.

    How about using dagger.json to have a passthrough_env_args where the module developer defines the env vars that are used by the module (required and optional). Then that can be documented (even printed out in the module CLI reference) by the module author and the consumer will have a clear idea of what ENV vars are passed through. Dagger CLI can put safeguards to prevent (or have a flag to opt-in) the passthrough ENV.

    We can even give the choice to the module developer on when they can use the ENVs. They are exposed as internal ENV to every function within the module but the function dev will have to do something like os.GetEnv to actually use them. They can unset ENVs as they please as well if they absolutely don't want an ENV present within the function scope.

    I like this idea, but I'm not sure how well it would work in practice. The config side is simple andeasy to understand, dagger.json is already a configuration file so it's where I'd expect to find this information, and it's self-documenting for users - "here's the env vars this file will look for if values aren't provided".

    Some form of explicit fetch would be required to avoid breaking the above mentioned workflow of "if a parameter value is provided use it, if none is provided use a default value I set here" by injecting a value in the middle of those conditions, but that also introduces another condition a module might have to check...

    Here's what a CLI convenience might look like:

    • When calling a function from the CLI, if mandatory arguments of type string or secret are omitted in the CLI, a new default behavior kicks in
    • The new default behavior, for an unspecified argument foo, is to look up the environment variable FOO, and use its value.
    • This behavior would require an interactive prompt, and manual approval by the user (for safety)
    • This behavior could be explicitly disabled with a flag
    • If we add a more ambitious trust model later, it could cause this behavior to be enabled or disabled depending of the trust status of a module

    Also fine with an implementation like this, except the interactive prompt bit. No need for that if it can be explicitly enabled/disabled. As long as it's quick and simple to 1) see if this behaviour is on/off and 2) change the behaviour to on/off I'm happy. A really clear way of displaying this to users is also going to be super helpful - perhaps something in the call -m <module> functions response?

  9. shykes commented on Nov 16, 2023

    @shykes
    Contributor

    This is essentially what I'm looking for as well. Env vars 'just work' in almost every tool out there, I don't want to have to explain to colleagues that they now need to do something else with env vars.

    Unfortunately, the reason env vars "just work" in other tools is also the reason devops is such a mess, and Dagger is needed to clean it up: the composition model is 40 years old, and it's just not good enough. If duct-taping shell scripts together with env variables and yaml actually scaled, we wouldn't be here having this conversation. A big part of the Dagger "magic" is balancing a) a better composition system, with b) a familiar user experience that fits into your existing stack.

    So that's our dilemma: to deliver on a), Dagger must break free of the traditional use of env vars for composition (because they are basically a worse version of arguments). But to deliver on b), we need env vars to be a first-class citizen in our UX.

    I just want to manage expectations: we will bend over backwards to make the UX better. But we will not, cannot compromise on the scalable composition model.

    A good rule of thumb for evaluating whether a proposal "breaks the composition model": does it create a system of "shadow arguments"? If the answer is yes, then it breaks the composition model and we shouldn't do it.

    How about using dagger.json to have a passthrough_env_args where the module developer defines the env vars that are used by the module (required and optional). Then that can be documented (even printed out in the module CLI reference) by the module author and the consumer will have a clear idea of what ENV vars are passed through. Dagger CLI can put safeguards to prevent (or have a flag to opt-in) the passthrough ENV.

    IMO this is a shadow argument system. Just use arguments + UX convenience.

    I like this idea, but I'm not sure how well it would work in practice. The config side is simple andeasy to understand, dagger.json is already a configuration file so it's where I'd expect to find this information, and it's self-documenting for users - "here's the env vars this file will look for if values aren't provided".

    IMO there's no benefit to asking module developers to think about env variable names. They already chose a name for their argument. Why make them choose a different name? That's just a step towards a shadow argument system.

    Here's what a CLI convenience might look like: [...]

    Also fine with an implementation like this, except the interactive prompt bit. No need for that if it can be explicitly enabled/disabled.

    It's a UX detail, but I think it will need for security reasons. Picture an untrusted module with an argument called netlifyToken. You run it without arguments, not knowing the intricacies of default env lookup. Boom, your NETLIFY_TOKEN env variable was collected and leaked. A warning prompt (or other implementation of a trust management system) would protect against that. This is the only reason (to my knowledge) for an interactive prompt.

    As long as it's quick and simple to 1) see if this behaviour is on/off and 2) change the behaviour to on/off I'm happy. A really clear way of displaying this to users is also going to be super helpful - perhaps something in the call -m <module> functions response?

    Yes agreed.

  10. nipuna-perera commented on Nov 16, 2023

    @nipuna-perera
    Contributor

    IMO this is a shadow argument system. Just use arguments + UX convenience.

    I just want to manage expectations: we will bend over backwards to make the UX better. But we will not, cannot compromise on the scalable composition model.

    I see what you mean here and I agree the dagger.json method won't be good for composition.

    I'll give an example where just arguments would be messy and repetitive. Within my company, we have to utilize egress proxies for a lot of stuff we do, so if we pass the proxies as args, http_proxy, https_proxy and no_proxy at a minimum would have to be passed into every function call. I could have a with setup function for the module and set them up once, but again, every call to a function the consumer of the module has to use withProxies. Besides, if I name the argument "http_proxy" that breaks certain language conventions. That's not a nice argument name in Go for example. I am hopeful the proxy problem will be solved in another way as part of something #6077 but you get the idea.

    Don't get me wrong, I really like the isolation and composition nature of what zenith is aspiring to do. But, having to jump through hoops to set up a ubiquitous env like the proxies might become too tedious.

    No matter how hard we try, we can't have dagger modules behave exactly the same way in CI systems like they behave on local machines. There are restrictions that make it necessary to tweak the behavior of a module based on where it's running. Environment variables play a big part in CI systems and having a easy way to pass them through will help adoption of Dagger. Less verbose we can make our existing DSL (which is still needed in some capacity to run dagger) the better chance people will like/use it.

    Picture an untrusted module with an argument called netlifyToken. You run it without arguments, not knowing the intricacies of default env lookup. Boom, your NETLIFY_TOKEN env variable was collected and leaked.

    Being in the face of the module consumer (warnings/documentation etc.) about env var consumption of the module could alleviate this (could also get annoying). But yeah this is an issue inherent to most CLIs today and I haven't come across many that actually warn/inform users of ENV var usage. I am glad Dagger is trying to break away from this.

    IMO there's no benefit to asking module developers to think about env variable names. They already chose a name for their argument. Why make them choose a different name? That's just a step towards a shadow argument system.

    Don't module developers still have to think about env vars like proxies? Without them, their module won't work.

    A warning prompt (or other implementation of a trust management system) would protect against that. This is the only reason (to my knowledge) for an interactive prompt.

    An interactive prompt won't work in CI though. So there will have to be some way to tell a module it's running in CI and run non-interactively. Today with non-zenith dagger I do this by looking at the CI system env vars.

    I apologize It's a long winded response without any new proposals for a solution. But I am trying my best to represent the big Enterprise landscape from my experience and help Dagger run virtually anywhere.

  11. sagikazarmark commented on Nov 16, 2023

    @sagikazarmark
    Contributor

    So that's our dilemma: to deliver on a), Dagger must break free of the traditional use of env vars for composition (because they are basically a worse version of arguments). But to deliver on b), we need env vars to be a first-class citizen in our UX.

    The only place where using env vars are beneficial is where you execute a pipeline using ‘dagger call’. I’d probably focus on those cases.

    I agree that env vars break composition in every other scenario (they are like global vars).

    But for pipeline entrypoints called from CLI, I’d argue they are actually part of the interface.

    Here is what I would really like to avoid: passing countless arguments to commands just to avoid using env vars AND passing countless arguments to functions. As I said before: I don’t enjoy writing and maintaining those at all.

  12. Mjb141 commented on Nov 16, 2023

    @Mjb141

    Unfortunately, the reason env vars "just work" in other tools is also the reason devops is such a mess, and Dagger is needed to clean it up: the composition model is 40 years old, and it's just not good enough. If duct-taping shell scripts together with env variables and yaml actually scaled, we wouldn't be here having this conversation. A big part of the Dagger "magic" is balancing a) a better composition system, with b) a familiar user experience that fits into your existing stack.

    So that's our dilemma: to deliver on a), Dagger must break free of the traditional use of env vars for composition (because they are basically a worse version of arguments). But to deliver on b), we need env vars to be a first-class citizen in our UX.

    I just want to manage expectations: we will bend over backwards to make the UX better. But we will not, cannot compromise on the scalable composition model.

    A good rule of thumb for evaluating whether a proposal "breaks the composition model": does it create a system of "shadow arguments"? If the answer is yes, then it breaks the composition model and we shouldn't do it.

    All good points - I didn't properly consider how some automagic around env vars might compromise the composition model. Thanks for explaining that! If the end result of improving the env vars experience is a CLI convenience and more explicitness in the CLI that's fine - I'd be quite happy with that.

    It's a UX detail, but I think it will need for security reasons. Picture an untrusted module with an argument called netlifyToken. You run it without arguments, not knowing the intricacies of default env lookup. Boom, your NETLIFY_TOKEN env variable was collected and leaked. A warning prompt (or other implementation of a trust management system) would protect against that. This is the only reason (to my knowledge) for an interactive prompt.

    Interactive prompts (and digging through what is often several wrong answers before finding the right way to disable) are often a pain point, alleviating that is going to be important. To reply to your example, other marketplaces typically put the onus on the user to be responsible for knowing what they're downloading/running. It's trivially simple to install and run a malicious package from npmjs/pypi for example, and so the process of using those package repositories is super quick with no/minimal barriers. Not saying that's necessarily the right idea, just outlining what I think developers/engineers are used to.

    This does put Dagger a step ahead of other marketplaces in security posture, which if implemented I'd definitely highlight when talking about it!

  13. vito commented on Nov 16, 2023

    @vito
    Contributor

    @nipuna-perera Proxy env vars are a great point to bring up, but I think they should be treated as an exceptional case. I definitely don't think module authors should ever have to think about them, because that's tedious repetitive work across the entire ecosystem. Like you said, proxy env config applies to everything. If every module author had to remember to add params for it, anyone using a proxy would end up constantly blocked.

    In Concourse we decided that this was an infra-level concern. Workers would pick up the "standard" http_proxy (etc) env vars, and Concourse would inject those same values for all containers on the worker. I suppose we could try a similar approach for Dagger, but I'm sure there are gotchas. IMO this rabbit hole should be explored in a separate issue.

    Aside from proxies, I'm in full agreement with #6112 (comment)

  14. 13 remaining items

  15. bitgandtter commented on Mar 26, 2024

    @bitgandtter

    @shykes when you said

    I understand. Dagger is not affected by this particular problem, because it doesn't allow passing the value of the env variable: you have to pass the name of the variable.

    So in your example, that potentially insecure command will not work. Instead you would use --my-secret=env:MY_SECRET.

    I'm not sure. I'm using it right now sort of like that, I mean

    --my-secret=${{ secrets.GH_TOKEN }}

    on both local and GHA

  16. helderco commented on Mar 26, 2024

    @helderco
    Contributor

    @bitgandtter you must be using an old dagger version. Secrets are no longer passed by value in the CLI for a while.

  17. bitgandtter commented on Mar 26, 2024

    @bitgandtter

    using locally
    dagger v0.10.2 (registry.dagger.io/engine) darwin/arm64
    and on gha

          - name: Call Dagger Function
            uses: dagger/dagger-for-github@v5
    
  18. shykes commented on Mar 26, 2024

    @shykes
    Contributor

    @bitgandtter that is very surprising. Definitely not expected behavior. Possible explanations:

    1. Somehow the version of Dagger being used is older than you think (not sure how)
    2. There is a regression in Dagger which allows passing by value
    3. Your argument is of type string rather than Secret
    4. ?

    🤷

  19. bitgandtter commented on Mar 26, 2024

    @bitgandtter

    option 4 for sure ;) that said and as I mention before its a DX the need of passing the values put developers in place of either:

    • doing as good practices using secrets
    • doing as string and exposing them

    this can be solve by

    • ingesting the env vars from the host
    • force arg to be secrets always

    yes this can be naive but I just wanna highlight the point of developers been allowed to expose secret values

  20. shykes commented on Mar 26, 2024

    @shykes
    Contributor

    option 4 for sure ;) that said and as I mention before its a DX the need of passing the values put developers in place of either:

    • doing as good practices using secrets
    • doing as string and exposing them

    this can be solve by

    • ingesting the env vars from the host
    • force arg to be secrets always

    yes this can be naive but I just wanna highlight the point of developers been allowed to expose secret values

    You're right that there will always be a way to leak secrets. Dagger doesn't aim to solve every security issue. If we 1) don't make security worse, and 2) make security better on average; we are in a good place.

  21. added
    area/cli
    on Apr 3, 2024
  22. rawkode commented on Sep 13, 2024

    @rawkode
    Contributor

    Now that contextual modules are out of the way, it would be nice to tackle this and make it easier to not just build projects; but deploy them to production.

    I have a module, OnePassword, that currently needs me to pass it the secret token and a secret reference to fetch a secret value from 1Password.

    This means that any function that wants to use it, needs to wire up the secret environment variable and this is now rather cumbersome.

    Now I don't think all modules should get access to environment variables, but perhaps we can bless a few?

    #dagger.json
    {
      "name": "OnePassword",
      "source": "../../../daggerverse/OnePassword",
      "env": ["OP_SERVIVE_ACCOUNT_TOKEN"]
    },
    
  23. flomedja commented on Nov 26, 2024

    @flomedja

    I am new to dagger and doing a poc on the usage of dagger to standardize the CI for Go projects.
    I just spend few hours trying to debug a module to build a Go programs, that wasn't working because I assume that dagger have access to environment variables of the host.
    Surprisingly even the WithEnvVariable() didn't seem to set the environment variable adequately to be use in the subsequent task execution of the module. os.Getenv("Env_Name" ) can't retrieve the environment variable after It was set with WithEnvVariable("Env_Name", "env_value")
    I have a use case similar to one previously mentionned by @skycaptain when a token is needed to retrieve private Go modules from Gitlab.

    It would be interesting to have a mechanism to inject the host environment variables to dagger call.
    Even If they need to be explicitely passed it is still more friendly than having to pass them through the functions input arguments as it is required now.

  24. rawkode commented on Nov 26, 2024

    @rawkode
    Contributor

    Most of the issues in this will hopefully be resolved by #8730

  25. locked and limited conversation to collaborators on Mar 24, 2026
  26. converted this issue into a discussion #12476 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliarea/sdk

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions