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 }