envvars

package
v0.0.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 4 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToDaggerEnvVarsFromMap

func ToDaggerEnvVarsFromMap(envVarsMap map[string]string) ([]types.DaggerEnvVars, error)

ToDaggerEnvVarsFromMap converts a map of environment variables into a slice of DaggerEnvVars. It ensures all entries are valid and handles empty maps gracefully.

Parameters:

  • envVarsMap: A map of environment variables where each key is a variable name and each value is the corresponding value.

Returns:

  • A slice of DaggerEnvVars, each containing the name and value of an environment variable.
  • An error if the input map is empty or contains an empty key.

Example:

envVarsMap := map[string]string{"FOO": "bar", "BAZ": "qux"}
envVarsSlice, err := ToDaggerEnvVarsFromMap(envVarsMap)
if err != nil {
    // handle error
}
// Use envVarsSlice, e.g., fmt.Println(envVarsSlice)

func ToDaggerEnvVarsFromSlice

func ToDaggerEnvVarsFromSlice(envVarsSlice []string) ([]types.DaggerEnvVars, error)

ToDaggerEnvVarsFromSlice converts a slice of key=value strings into a slice of DaggerEnvVars. It validates each entry and skips invalid entries.

Parameters:

  • envVarsSlice: A slice of strings where each string is a key=value pair representing an environment variable.

Returns:

  • A slice of DaggerEnvVars, each containing the name and value of an environment variable.
  • An error if the input slice is empty or if any of the key=value pairs are invalid.

Example:

envVarsSlice := []string{"FOO=bar", "BAZ=qux"}
envVars, err := ToDaggerEnvVarsFromSlice(envVarsSlice)
if err != nil {
    // handle error
}
// Use envVars, e.g., fmt.Println(envVars)

func ToDaggerEnvVarsFromStr

func ToDaggerEnvVarsFromStr(envVars string) ([]types.DaggerEnvVars, error)

ToDaggerEnvVarsFromStr converts a comma-separated string of key=value pairs into a slice of DaggerEnvVars. It ensures all entries are valid and handles empty strings gracefully.

Parameters:

  • envVars: A comma-separated string of key=value pairs. For example: "key1=value1,key2=value2,key3=value3".

Returns:

  • A slice of DaggerEnvVars, each containing the name and value of an environment variable.
  • An error if the input string is empty or if any of the key=value pairs are invalid.

Example:

envVarsStr := "FOO=bar,BAZ=qux"
envVars, err := ToDaggerEnvVarsFromStr(envVarsStr)
if err != nil {
    // handle error
}
// Use envVars, e.g., fmt.Println(envVars)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL