depenv: ntppool configuration for deployment environments
This commit is contained in:
18
config/depenv/context.go
Normal file
18
config/depenv/context.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package depenv
|
||||
|
||||
import "context"
|
||||
|
||||
type contextKey struct{}
|
||||
|
||||
// NewContext adds the deployment environment to the context
|
||||
func NewContext(ctx context.Context, d DeploymentEnvironment) context.Context {
|
||||
return context.WithValue(ctx, contextKey{}, d)
|
||||
}
|
||||
|
||||
// FromContext retrieves the deployment environment from the context
|
||||
func FromContext(ctx context.Context) DeploymentEnvironment {
|
||||
if d, ok := ctx.Value(contextKey{}).(DeploymentEnvironment); ok {
|
||||
return d
|
||||
}
|
||||
return DeployUndefined
|
||||
}
|
Reference in New Issue
Block a user