github.com/helmwave/helmwave@v0.36.4-0.20240509190856-b35563eba4c6/pkg/hooks/env.go (about) 1 package hooks 2 3 import ( 4 "context" 5 "fmt" 6 "os" 7 8 "github.com/helmwave/helmwave/pkg/helper" 9 ) 10 11 const ( 12 EnvReleaseUniqname = "HELMWAVE_LIFECYCLE_RELEASE_UNIQNAME" 13 EnvLifecycleType = "HELMWAVE_LIFECYCLE_TYPE" 14 ) 15 16 func (h *hook) getCommandEnviron(ctx context.Context) []string { 17 env := os.Environ() 18 19 if uniq, exists := helper.ContextGetReleaseUniq(ctx); exists { 20 env = addToEnviron(env, EnvReleaseUniqname, uniq.String()) 21 } 22 23 if typ, exists := helper.ContextGetLifecycleType(ctx); exists { 24 env = addToEnviron(env, EnvLifecycleType, typ) 25 } 26 27 return env 28 } 29 30 func addToEnviron(env []string, key, value string) []string { 31 return append(env, fmt.Sprintf("%s=%s", key, value)) 32 }