Skip to content

Conversation

@neunenak
Copy link
Contributor

The env attribute accepts two arguments (env_var, value) and can be used multiple times per recipe to set environment variables without using the existing $parameter syntax:

[env('API_KEY', 'secret')]
[env('LOG_LEVEL', 'debug')]
deploy:
    ./deploy.sh

Addresses #2825

@neunenak
Copy link
Contributor Author

Also as a general note, I initially generated this PR with LLM coding tools and then manually audited+tweaked some things. I dunno if just as a project does or should have some kind of stated policy on that, but I wanted to mention that for the sake of transparency.

I'm personally pretty bullish on AI-assisted coding, I do it all the time myself, and I take the position that in general a human developer is responsible for the code they submit to a project, but the project shouldn't care exactly how they generated that code.

@neunenak
Copy link
Contributor Author

@casey it'd be great if you could take a look at this, I think this is a pretty simple change that yields a pretty useful feature

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Some minor tweaks.

A couple bigger questions:

Should exported environment variables should be available to recipe parameters?

[env("foo", "bar")]
baz x=`echo ${foo}.txt`:

Also, should they be available to env functions?

[env("foo", "bar")]
baz:
  echo {{ env("foo") }}.txt

I think the answer to both is probably yes.

As far as AI goes, I have no problem at all with LLM and AI generated code, as long as you the human coder "vouches" for the code to the same degree as code you wrote yourself, which requires reviewing the whole thing in depth before submitting it.

@casey
Copy link
Owner

casey commented Jan 11, 2026

Actually, maybe they shouldn't be available to env functions. The env functions don't see exported top-level assignments or parameters, so the env attribute shouldn't be an exception. The question about parameters remains.

@neunenak
Copy link
Contributor Author

neunenak commented Jan 13, 2026

Actually, maybe they shouldn't be available to env functions. The env functions don't see exported top-level assignments or parameters, so the env attribute shouldn't be an exception. The question about parameters remains.

This is actually potentially confusing behavior with env(), although altering this would be a breaking change. In any case, I implemented making environment variables set via env accessible in parameters but not via env(). I think it's fine to deter thinking about what the right way for env() to behave is to another issue.

neunenak and others added 6 commits February 3, 2026 01:15
The env attribute accepts two arguments (env_var_name, value) and can be used
multiple times per recipe to set environment variables:

    [env('API_KEY', 'secret')]
    [env('LOG_LEVEL', 'debug')]
    deploy:
      ./deploy.sh
@neunenak
Copy link
Contributor Author

neunenak commented Feb 3, 2026

@casey could you take a look at this?

Copy link
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Sorry for not thinking of this earlier, but I think that a duplicate variable name in an [env] attribute should be an error, since it's almost certainly a mistake.

@casey casey enabled auto-merge (squash) February 4, 2026 00:31
@casey casey merged commit c85bf9d into casey:master Feb 4, 2026
6 checks passed
@casey
Copy link
Owner

casey commented Feb 4, 2026

Nice, merged!

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.

2 participants