2021-09-05 10:36:57 -04:00
|
|
|
package envctx
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
const (
|
2022-02-06 16:53:15 -05:00
|
|
|
environmentKey string = "v2.environment"
|
2021-09-05 10:36:57 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func ContextWithEnvironment(ctx context.Context, environment interface{}) context.Context {
|
2022-06-28 08:26:01 -04:00
|
|
|
return context.WithValue(ctx, environmentKey, environment) //nolint: revive,staticcheck
|
2021-09-05 10:36:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func EnvironmentFromContext(ctx context.Context) interface{} {
|
2021-11-27 04:16:41 -05:00
|
|
|
return ctx.Value(environmentKey)
|
2021-09-05 10:36:57 -04:00
|
|
|
}
|