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

Pass env to run_sh #2050

Closed
barnabasbusa opened this issue Jan 16, 2024 · 2 comments · Fixed by #2114 or #2094
Closed

Pass env to run_sh #2050

barnabasbusa opened this issue Jan 16, 2024 · 2 comments · Fixed by #2114 or #2094
Assignees
Labels
cli For bugs relating to the CLI feature request painful Painful bug

Comments

@barnabasbusa
Copy link
Contributor

barnabasbusa commented Jan 16, 2024

Background & motivation

It would be great if I could pass env variables to run_sh.

Desired behaviour

result = plan.run_sh(
        run = "mkdir -p kurtosis && echo $EXAMPLE",
        image = "badouralix/curl-jq",
        files = {
            "/path/to/file/1": files_artifact_1,
            "/path/to/file/2": files_artifact_2,
        },
        env = {
            "EXAMPLE": value
        },
        store = [
            # EXAMPLE: Creates a files artifact named `kurtosis_txt` containing the `kurtosis.txt` file
            StoreSpec(src = "/src/kurtosis.txt", name = "kurtosis_txt"),
            
            # EXAMPLE: Creates a files artifact with an automatically-generated name containing `genesis.json`
            StoreSpec(src = "/genesis.json"),

            # EXAMPLE: Creates a files artifact with an automatically-generated name containing `address.json`
            # This is just syntactic sugar for:
            # StoreSpec(src = "/coinbase/address.json")
            "/coinbase/address.json"
        ],
        wait="180s"
    )

How important is this to you?

Painful; the lack of this feature makes using Kurtosis frictionful.

What area of the product does this pertain to?

CLI: the Command Line Interface

@github-actions github-actions bot added cli For bugs relating to the CLI painful Painful bug labels Jan 16, 2024
@mieubrisse
Copy link
Member

hey @barnabasbusa ! It's not an actual solution, but a workaround would be inlining the environment variable:

run="mkdir -p kurtosis && EXAMPLE=" + some_value + " echo $EXAMPLE"

@barnabasbusa
Copy link
Contributor Author

my point would be to be able to inject a variable from outside.

somevalue = (1+2)
...
env ={EXAMPLE: somevalue}
...

@adschwartz adschwartz self-assigned this Feb 2, 2024
github-merge-queue bot pushed a commit that referenced this issue Feb 5, 2024
## Description:
This change adds `env_vars` to the run_sh. Feature was requested in
issue #2050. Example of used in practice:

```
def run(plan, args={}):
    result = plan.run_sh(
        run = "mkdir -p kurtosis && echo $EXAMPLE",
        image = "badouralix/curl-jq",
        env_vars = {
            "EXAMPLE": "this_is_a_test"
        },
    )
```
outputs:

```
Container images used in this run:
> badouralix/curl-jq - locally cached

> run_sh run="mkdir -p kurtosis && echo $EXAMPLE" image="badouralix/curl-jq" env_vars={"EXAMPLE": "this_is_a_test"}
Command returned with exit code '0' and the following output:
--------------------
this_is_a_test

--------------------

Starlark code successfully run. No output was returned.
```


## Is this change user facing?
YES

## References (if applicable):
Closes: #2050
github-merge-queue bot pushed a commit that referenced this issue Feb 5, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.86.13](0.86.12...0.86.13)
(2024-02-05)


### Features

* add `env_vars` as input to `run_sh`
([#2114](#2114))
([5a30ea7](5a30ea7)),
closes [#2050](#2050)
* add nodejs devtools to Nix
([#2099](#2099))
([7bbb2bc](7bbb2bc))
* add run docker compose with kurtosis guide
([#2085](#2085))
([7bbe479](7bbe479))
* Add RunStarlarkScript to enclave manager API
([#2103](#2103))
([1eeb3eb](1eeb3eb))


### Bug Fixes

* adding the `core script build call`, which was removed by accident, in
the main build script
([#2118](#2118))
([1f73821](1f73821))
* Fix calls to stacktrace in the reverse proxy module
([#2100](#2100))
([a7fefc2](a7fefc2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: kurtosisbot <kurtosisbot@users.noreply.github.com>
Co-authored-by: Anders Schwartz <adschwartz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli For bugs relating to the CLI feature request painful Painful bug
Projects
None yet
3 participants