depenv: ntppool configuration for deployment environments

This commit is contained in:
2025-01-26 11:08:44 -08:00
parent f6d160a7f8
commit e5836a8b97
5 changed files with 127 additions and 4 deletions

18
config/depenv/context.go Normal file
View 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
}