github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/internal/domain/scenariogroups/scenarioGroups.go (about) 1 package scenariogroups 2 3 import ( 4 "context" 5 ) 6 7 // Key is used for type of the key for scenarioGroups in context 8 type Key string 9 10 // ScenarioGroupsContextKey is the key of the value for scenarioGroups coming from header 11 const ScenarioGroupsContextKey Key = "scenarioGroups" 12 13 // LoadFromContext retrieves the value of the scenario groups in the context 14 func LoadFromContext(ctx context.Context) []string { 15 scenarioGroups := ctx.Value(ScenarioGroupsContextKey) 16 if scenarioGroups == nil { 17 return []string{} 18 } 19 20 return scenarioGroups.([]string) 21 } 22 23 // SaveToContext adds the value of scenario groups to the context 24 func SaveToContext(ctx context.Context, scenarioGroups []string) context.Context { 25 return context.WithValue(ctx, ScenarioGroupsContextKey, scenarioGroups) 26 }