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

Introduce environmental variable handling to kraft build and kraft run #787

Closed
nderjung opened this issue Sep 7, 2023 · 4 comments · Fixed by #1463
Closed

Introduce environmental variable handling to kraft build and kraft run #787

nderjung opened this issue Sep 7, 2023 · 4 comments · Fixed by #1463
Assignees
Labels
kind/enhancement New feature or request priority/medium Issue which is important, but KraftKit is usable without it also.

Comments

@nderjung
Copy link
Member

nderjung commented Sep 7, 2023

Feature request summary

This issue tracks allowing the parsing and passing of environmental variables from kraft build and kraft run via the command-line flag -e flag and an env element in the Kraftfile specification such that these key-values are correctly passed into posix-environ

  • In the case of kraft build, these can be statically set at compile-time such that these variables are persistent with the unikernel.

  • In the case of kraft run, they are passed via uklibparam via the syntax and requiring the KConfig option CONFIG_LIBPOSIX_ENVIRON_LIBPARAM:

    env.vars=[ "${NAME0}=${VALUE0}" "${NAME1}=${VALUE1}" ]
    

When no key is provided, for example kraft run -e HOME, the value should be automatically determined from the host environment via os.Getenv.

A new wrapper library should be introduced in unikraft/export/v0/posix-environ to accommodate handling the list of key-value environmental variables and the correct format to be used when instantiating the VM.

To statically serialize environmental variables, a new top-level env element should be added to the Kraftfile specification such that these are passed in the same way to kraft build and kraft run.

Map form:

spec: v0.6

env:
  KEY: value

List form:

spec: v0.6

env:
- KEY=value

Describe alternatives

No response

Related architectures

None

Related platforms

None

Additional context

See posix-environ: Handling Environmental Variables for additional details.

@nderjung nderjung added the kind/enhancement New feature or request label Sep 7, 2023
@github-project-automation github-project-automation bot moved this to 🧊 Icebox in KraftKit Roadmap Sep 7, 2023
@nderjung nderjung changed the title Introduce -e flag to kraft build and kraft run for passing environmental variables Introduce environmental variable handling to kraft build and kraft run Sep 8, 2023
@craciunoiuc craciunoiuc added the priority/medium Issue which is important, but KraftKit is usable without it also. label Feb 29, 2024
@LucaSeri
Copy link
Contributor

Is anyone working on this at the moment? If not, can you please assign it to me?

@nderjung
Copy link
Member Author

@LucaSeri 🪄

@nderjung
Copy link
Member Author

@LucaSeri can you also introduce packmanager.PackWithEnv(env ...string) and inject the environmental variables into the ocispec.ImageConfig object?

See:

Please & thank you! :)

@nderjung
Copy link
Member Author

This draft PR may be interesting for you too see all the bits that need touching: #1286

@nderjung nderjung moved this from 🧊 Icebox to 🏗 In Progress in KraftKit Roadmap Mar 26, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In Progress to 🚀 Done in KraftKit Roadmap Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request priority/medium Issue which is important, but KraftKit is usable without it also.
Projects
Status: Done
Status: 🚀 Done
Development

Successfully merging a pull request may close this issue.

3 participants