@@ -31,6 +31,7 @@ type GrowthbookFeatureSpec struct {
3131 Environments []Environment `json:"environments,omitempty"`
3232}
3333
34+ // +kubebuilder:validation:Enum=boolean;string;number;json
3435type FeatureValueType string
3536
3637var (
4041 FeatureValueTypeJSON FeatureValueType = "json"
4142)
4243
44+ // +kubebuilder:validation:Enum=all;none;any
45+ type SavedGroupTargetingMatch string
46+
47+ var (
48+ SavedGroupTargetingMatchAll SavedGroupTargetingMatch = "all"
49+ SavedGroupTargetingMatchNone SavedGroupTargetingMatch = "none"
50+ SavedGroupTargetingMatchAny SavedGroupTargetingMatch = "any"
51+ )
52+
53+ // +kubebuilder:validation:Enum=force;rollout;experiment
54+ type FeatureRuleType string
55+
56+ var (
57+ FeatureRuleTypeForce FeatureRuleType = "force"
58+ FeatureRuleTypeRollout FeatureRuleType = "rollout"
59+ FeatureRuleTypeExperiment FeatureRuleType = "experiment"
60+ )
61+
62+ type FeatureRule struct {
63+ Type FeatureRuleType `json:"type,omitempty"`
64+ Description string `json:"description,omitempty"`
65+ Condition string `json:"condition,omitempty"`
66+ Enabled bool `json:"enabled,omitempty"`
67+ ScheduleRules []ScheduleRule `json:"scheduleRules,omitempty"`
68+ SavedGroups []SavedGroupTargeting `json:"savedGroups,omitempty"`
69+ Prerequisites []FeaturePrerequisite `json:"prerequisites,omitempty"`
70+ Value string `json:"value,omitempty"`
71+ Coverage string `json:"coverage,omitempty"`
72+ HashAttribute string `json:"hashAttribute,omitempty"`
73+ TrackingKey string `json:"trackingKey,omitempty"`
74+ FallbackAttribute * string `json:"fallbackAttribute,omitempty"`
75+ DisableStickyBucketing * bool `json:"disableStickyBucketing,omitempty"`
76+ BucketVersion * int64 `json:"bucketVersion,omitempty"`
77+ MinBucketVersion * int64 `json:"minBucketVersion,omitempty"`
78+ Namespace * NamespaceValue `json:"namespace,omitempty"`
79+ Values []ExperimentValue `json:"values,omitempty"`
80+ }
81+
82+ type FeaturePrerequisite struct {
83+ ID string `json:"id,omitempty"`
84+ Condition string `json:"condition,omitempty"`
85+ }
86+
87+ type ScheduleRule struct {
88+ Timestamp string `json:"timestamp,omitempty"`
89+ Enabled bool `json:"enabled,omitempty"`
90+ }
91+
92+ type SavedGroupTargeting struct {
93+ Match SavedGroupTargetingMatch `json:"match,omitempty"`
94+ IDs []string `json:"ids,omitempty"`
95+ }
96+
97+ type ExperimentValue struct {
98+ Value string `json:"value,omitempty"`
99+ Weight int64 `json:"weight,omitempty"`
100+ Name * string `json:"name,omitempty"`
101+ }
102+
103+ type NamespaceValue struct {
104+ Enabled bool `json:"enabled,omitempty"`
105+ Name string `json:"name,omitempty"`
106+ Range []int64 `json:"range,omitempty"`
107+ }
108+
43109// GetID returns the feature ID which is the resource name if not overwritten by spec.ID
44110func (f * GrowthbookFeature ) GetID () string {
45111 if f .Spec .ID == "" {
@@ -51,8 +117,9 @@ func (f *GrowthbookFeature) GetID() string {
51117
52118// Environment defines a grothbook environment
53119type Environment struct {
54- Name string `json:"name,omitempty"`
55- Enabled bool `json:"enabled,omitempty"`
120+ Name string `json:"name,omitempty"`
121+ Enabled bool `json:"enabled,omitempty"`
122+ Rules []FeatureRule `json:"rules,omitempty"`
56123}
57124
58125// +kubebuilder:object:root=true
0 commit comments