0.3.01
This commit is contained in:
@@ -400,30 +400,52 @@ func (s *Store) SetMDBListSettings(ctx context.Context, settings MDBListSettings
|
||||
const FeaturePolicyKey = "feature_policy"
|
||||
|
||||
type FeaturePolicySnapshot struct {
|
||||
Overrides map[string]bool `json:"overrides"`
|
||||
SafeMode bool `json:"safeMode"`
|
||||
Revision int64 `json:"revision"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
Overrides map[string]bool `json:"overrides"`
|
||||
Values map[string]json.RawMessage `json:"values,omitempty"`
|
||||
UserValues map[string]map[string]json.RawMessage `json:"userValues,omitempty"`
|
||||
DeviceValues map[string]map[string]json.RawMessage `json:"deviceValues,omitempty"`
|
||||
Experimental map[string]json.RawMessage `json:"experimental,omitempty"`
|
||||
SafeMode bool `json:"safeMode"`
|
||||
Revision int64 `json:"revision"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type FeaturePolicy struct {
|
||||
Overrides map[string]bool `json:"overrides"`
|
||||
SafeMode bool `json:"safeMode"`
|
||||
Revision int64 `json:"revision"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
Previous *FeaturePolicySnapshot `json:"previous,omitempty"`
|
||||
Overrides map[string]bool `json:"overrides"`
|
||||
// Values is the central typed configuration store. Raw JSON keeps the store
|
||||
// forward-compatible while the API validates each catalogue entry's type.
|
||||
Values map[string]json.RawMessage `json:"values,omitempty"`
|
||||
UserValues map[string]map[string]json.RawMessage `json:"userValues,omitempty"`
|
||||
DeviceValues map[string]map[string]json.RawMessage `json:"deviceValues,omitempty"`
|
||||
Experimental map[string]json.RawMessage `json:"experimental,omitempty"`
|
||||
SafeMode bool `json:"safeMode"`
|
||||
Revision int64 `json:"revision"`
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
Previous *FeaturePolicySnapshot `json:"previous,omitempty"`
|
||||
}
|
||||
|
||||
var ErrFeaturePolicyConflict = errors.New("store: feature policy revision conflict")
|
||||
|
||||
func DefaultFeaturePolicy() FeaturePolicy {
|
||||
return FeaturePolicy{Overrides: map[string]bool{}}
|
||||
return FeaturePolicy{Overrides: map[string]bool{}, Values: map[string]json.RawMessage{}, UserValues: map[string]map[string]json.RawMessage{}, DeviceValues: map[string]map[string]json.RawMessage{}, Experimental: map[string]json.RawMessage{}}
|
||||
}
|
||||
|
||||
func normalizeFeaturePolicy(policy FeaturePolicy) FeaturePolicy {
|
||||
if policy.Overrides == nil {
|
||||
policy.Overrides = map[string]bool{}
|
||||
}
|
||||
if policy.Values == nil {
|
||||
policy.Values = map[string]json.RawMessage{}
|
||||
}
|
||||
if policy.UserValues == nil {
|
||||
policy.UserValues = map[string]map[string]json.RawMessage{}
|
||||
}
|
||||
if policy.DeviceValues == nil {
|
||||
policy.DeviceValues = map[string]map[string]json.RawMessage{}
|
||||
}
|
||||
if policy.Experimental == nil {
|
||||
policy.Experimental = map[string]json.RawMessage{}
|
||||
}
|
||||
return policy
|
||||
}
|
||||
|
||||
@@ -475,6 +497,7 @@ func (s *Store) SetFeaturePolicy(
|
||||
next.UpdatedAt = time.Now().UTC()
|
||||
next.Previous = &FeaturePolicySnapshot{
|
||||
Overrides: current.Overrides, SafeMode: current.SafeMode,
|
||||
Values: current.Values, UserValues: current.UserValues, DeviceValues: current.DeviceValues, Experimental: current.Experimental,
|
||||
Revision: current.Revision, UpdatedAt: current.UpdatedAt,
|
||||
}
|
||||
raw, err := json.Marshal(next)
|
||||
|
||||
Reference in New Issue
Block a user