From fd39b2fa79722c2f110356fce1102d100dcda5b0 Mon Sep 17 00:00:00 2001 From: Santhosh Date: Mon, 24 Oct 2022 16:43:23 +0530 Subject: [PATCH] set configScanDir as package scoped var (#264) set config.Install.env variables in environment adding env to config to use across all stages switch to config.Scan to read config --- pkg/config/config.go | 1 + pkg/utils/env.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 pkg/utils/env.go diff --git a/pkg/config/config.go b/pkg/config/config.go index bc2d602..c035f70 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -40,6 +40,7 @@ type Config struct { FailOnBundleErrors bool `yaml:"fail_on_bundles_errors,omitempty"` Bundles Bundles `yaml:"bundles,omitempty"` GrubOptions map[string]string `yaml:"grub_options,omitempty"` + Env []string `yaml:"env,omitempty"` } type Bundles []Bundle diff --git a/pkg/utils/env.go b/pkg/utils/env.go new file mode 100644 index 0000000..514ab66 --- /dev/null +++ b/pkg/utils/env.go @@ -0,0 +1,16 @@ +package utils + +import ( + "os" + "strings" +) + +func SetEnv(env []string) { + + for _, e := range env { + pair := strings.SplitN(e, "=", 2) + if len(pair) >= 2 { + os.Setenv(pair[0], pair[1]) + } + } +}