Skip to content

Commit

Permalink
_EXT_
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Apr 2, 2024
1 parent b89a685 commit e50d7b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
13 changes: 3 additions & 10 deletions addon/injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/konveyor/tackle2-hub/api"
"github.com/konveyor/tackle2-hub/task"
)

var (
Expand All @@ -29,19 +30,11 @@ func (r *EnvInjector) Inject(extension *api.Extension) {
extension.Metadata = mp
}

// buildEnv builds the `env`.
// Maps EXTENSION_<extension>_<var> found in the addon environment to its
// original unqualified name in the extension environment.
// buildEnv builds the extension `env`.
func (r *EnvInjector) buildEnv(extension *api.Extension) {
r.env = make(map[string]string)
for _, env := range extension.Container.Env {
key := strings.Join(
[]string{
"EXTENSION",
strings.ToUpper(extension.Name),
env.Name,
},
"_")
key := task.ExtEnv(extension.Name, env.Name)
r.env[env.Name] = os.Getenv(key)
}
}
Expand Down
21 changes: 14 additions & 7 deletions task/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,13 +961,7 @@ func (r *Task) propagateEnv(addon, extension *core.Container) {
addon.Env = append(
addon.Env,
core.EnvVar{
Name: strings.Join(
[]string{
"EXTENSION",
strings.ToUpper(extension.Name),
env.Name,
},
"_"),
Name: ExtEnv(extension.Name, env.Name),
Value: env.Value,
})
}
Expand Down Expand Up @@ -1031,3 +1025,16 @@ type Event struct {
Reporter string
Message string
}

// ExtEnv returns an environment variable named namespaced to an extension.
// Format: _EXT_<extension_<var>.
func ExtEnv(extension string, envar string) (s string) {
s = strings.Join(
[]string{
"_EXT",
strings.ToUpper(extension),
envar,
},
"_")
return
}

0 comments on commit e50d7b9

Please sign in to comment.