Skip to content

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

@nderjung

Description

@nderjung

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.

Metadata

Metadata

Assignees

Labels

kind/enhancementNew feature or requestpriority/mediumIssue which is important, but KraftKit is usable without it also.

Type

No type

Projects

Status

🚀 Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions