Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/ext/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Distribution struct {
}

type Rollout struct {
Id string `yaml:"id,omitempty" json:"id,omitempty"`
Description string `yaml:"description,omitempty" json:"description,omitempty"`
Segment *SegmentRule `yaml:"segment,omitempty" json:"segment,omitempty"`
Threshold *ThresholdRule `yaml:"threshold,omitempty" json:"threshold,omitempty"`
Expand All @@ -71,6 +72,7 @@ type Segment struct {
}

type Constraint struct {
Id string `yaml:"id,omitempty" json:"id,omitempty"`
Type string `yaml:"type,omitempty" json:"type,omitempty"`
Property string `yaml:"property,omitempty" json:"property,omitempty"`
Operator string `yaml:"operator,omitempty" json:"operator,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions internal/ext/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func (e *Exporter) Export(ctx context.Context, encoding Encoding, w io.Writer) e

for _, r := range rollouts.Rules {
rollout := Rollout{
Id: r.Id,
Description: r.Description,
}

Expand Down Expand Up @@ -321,6 +322,7 @@ func (e *Exporter) Export(ctx context.Context, encoding Encoding, w io.Writer) e

for _, c := range s.Constraints {
segment.Constraints = append(segment.Constraints, &Constraint{
Id: c.Id,
Type: c.Type.String(),
Property: c.Property,
Operator: c.Operator,
Expand Down
104 changes: 1 addition & 103 deletions internal/ext/testdata/export.json
Original file line number Diff line number Diff line change
@@ -1,103 +1 @@
{
"version": "1.4",
"namespace": {
"key": "default",
"name": "default",
"description": "default namespace"
},
"flags": [
{
"key": "flag1",
"name": "flag1",
"type": "VARIANT_FLAG_TYPE",
"description": "description",
"enabled": true,
"variants": [
{
"key": "variant1",
"name": "variant1",
"attachment": {
"pi": 3.141,
"happy": true,
"name": "Niels",
"nothing": null,
"answer": { "everything": 42 },
"list": [1, 0, 2],
"object": { "currency": "USD", "value": 42.99 }
}
},
{
"key": "foo",
"default": true
}
],
"rules": [
{
"segment": "segment1",
"distributions": [{ "variant": "variant1", "rollout": 100 }]
},
{
"segment": {
"keys": ["segment1", "segment2"],
"operator": "AND_SEGMENT_OPERATOR"
}
}
],
"metadata": {
"label": "variant",
"area": true
}
},
{
"key": "flag2",
"name": "flag2",
"type": "BOOLEAN_FLAG_TYPE",
"description": "a boolean flag",
"enabled": false,
"rollouts": [
{
"description": "enabled for internal users",
"segment": { "key": "internal_users", "value": true }
},
{
"description": "enabled for 50%",
"threshold": { "percentage": 50, "value": true }
}
],
"metadata": {
"label": "bool",
"area": 12
}
}
],
"segments": [
{
"key": "segment1",
"name": "segment1",
"match_type": "ANY_MATCH_TYPE",
"description": "description",
"constraints": [
{
"type": "STRING_COMPARISON_TYPE",
"property": "foo",
"operator": "eq",
"value": "baz",
"description": "desc"
},
{
"type": "STRING_COMPARISON_TYPE",
"property": "fizz",
"operator": "neq",
"value": "buzz",
"description": "desc"
}
]
},
{
"key": "segment2",
"name": "segment2",
"match_type": "ANY_MATCH_TYPE",
"description": "description"
}
]
}
{"version":"1.4","namespace":{"key":"default","name":"default","description":"default namespace"},"flags":[{"key":"flag1","name":"flag1","type":"VARIANT_FLAG_TYPE","description":"description","enabled":true,"metadata":{"area":true,"label":"variant"},"variants":[{"key":"variant1","name":"variant1","attachment":{"answer":{"everything":42},"happy":true,"list":[1,0,2],"name":"Niels","nothing":null,"object":{"currency":"USD","value":42.99},"pi":3.141}},{"default":true,"key":"foo"}],"rules":[{"segment":"segment1","distributions":[{"variant":"variant1","rollout":100}]},{"segment":{"keys":["segment1","segment2"],"operator":"AND_SEGMENT_OPERATOR"}}]},{"key":"flag2","name":"flag2","type":"BOOLEAN_FLAG_TYPE","description":"a boolean flag","enabled":false,"metadata":{"area":12,"label":"bool"},"rollouts":[{"id":"1","description":"enabled for internal users","segment":{"key":"internal_users","value":true}},{"id":"2","description":"enabled for 50%","threshold":{"percentage":50,"value":true}}]}],"segments":[{"key":"segment1","name":"segment1","description":"description","constraints":[{"id":"1","type":"STRING_COMPARISON_TYPE","property":"foo","operator":"eq","value":"baz","description":"desc"},{"id":"2","type":"STRING_COMPARISON_TYPE","property":"fizz","operator":"neq","value":"buzz","description":"desc"}],"match_type":"ANY_MATCH_TYPE"},{"key":"segment2","name":"segment2","description":"description","match_type":"ANY_MATCH_TYPE"}]}
150 changes: 77 additions & 73 deletions internal/ext/testdata/export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,77 +4,81 @@ namespace:
name: default
description: default namespace
flags:
- key: flag1
name: flag1
type: "VARIANT_FLAG_TYPE"
description: description
enabled: true
variants:
- key: variant1
name: variant1
attachment:
pi: 3.141
happy: true
name: Niels
nothing:
answer:
everything: 42
list:
- 1
- 0
- 2
object:
currency: USD
value: 42.99
- key: foo
default: true
rules:
- segment: segment1
distributions:
- variant: variant1
rollout: 100
- segment:
keys:
- segment1
- segment2
operator: AND_SEGMENT_OPERATOR
metadata:
label: variant
area: true
- key: flag2
name: flag2
type: "BOOLEAN_FLAG_TYPE"
description: a boolean flag
enabled: false
rollouts:
- description: enabled for internal users
segment:
key: internal_users
value: true
- description: enabled for 50%
threshold:
percentage: 50
value: true
metadata:
label: bool
area: 12
- key: flag1
name: flag1
type: VARIANT_FLAG_TYPE
description: description
enabled: true
metadata:
area: true
label: variant
variants:
- key: variant1
name: variant1
attachment:
answer:
everything: 42
happy: true
list:
- 1
- 0
- 2
name: Niels
nothing: null
object:
currency: USD
value: 42.99
pi: 3.141
- default: true
key: foo
rules:
- segment: segment1
distributions:
- variant: variant1
rollout: 100
- segment:
keys:
- segment1
- segment2
operator: AND_SEGMENT_OPERATOR
- key: flag2
name: flag2
type: BOOLEAN_FLAG_TYPE
description: a boolean flag
enabled: false
metadata:
area: 12
label: bool
rollouts:
- id: "1"
description: enabled for internal users
segment:
key: internal_users
value: true
- id: "2"
description: enabled for 50%
threshold:
percentage: 50
value: true
segments:
- key: segment1
name: segment1
match_type: "ANY_MATCH_TYPE"
description: description
constraints:
- type: STRING_COMPARISON_TYPE
property: foo
operator: eq
value: baz
description: desc
- type: STRING_COMPARISON_TYPE
property: fizz
operator: neq
value: buzz
description: desc
- key: segment2
name: segment2
match_type: "ANY_MATCH_TYPE"
description: description
- key: segment1
name: segment1
description: description
constraints:
- id: "1"
type: STRING_COMPARISON_TYPE
property: foo
operator: eq
value: baz
description: desc
- id: "2"
type: STRING_COMPARISON_TYPE
property: fizz
operator: neq
value: buzz
description: desc
match_type: ANY_MATCH_TYPE
- key: segment2
name: segment2
description: description
match_type: ANY_MATCH_TYPE
6 changes: 3 additions & 3 deletions internal/ext/testdata/export_all_namespaces.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{"version":"1.4","namespace":{"key":"default","name": "default","description":"default namespace"}}
{"namespace":{"key":"foo","name":"foo","description":"foo namespace"},"flags":[{"key":"flag1","name":"flag1","type":"VARIANT_FLAG_TYPE","description":"description","enabled":true,"variants":[{"key":"variant1","name":"variant1","attachment":{"pi":3.141,"happy":true,"name":"Niels","nothing":null,"answer":{"everything":42},"list":[1,0,2],"object":{"currency":"USD","value":42.99}}},{"key":"foo"}],"rules":[{"segment":"segment1","distributions":[{"variant":"variant1","rollout":100}]},{"segment":{"keys":["segment1","segment2"],"operator":"AND_SEGMENT_OPERATOR"}}]},{"key":"flag2","name":"flag2","type":"BOOLEAN_FLAG_TYPE","description":"a boolean flag","enabled":false,"rollouts":[{"description":"enabled for internal users","segment":{"key":"internal_users","value":true}},{"description":"enabled for 50%","threshold":{"percentage":50,"value":true}}]}],"segments":[{"key":"segment1","name":"segment1","match_type":"ANY_MATCH_TYPE","description":"description","constraints":[{"type":"STRING_COMPARISON_TYPE","property":"foo","operator":"eq","value":"baz","description":"desc"},{"type":"STRING_COMPARISON_TYPE","property":"fizz","operator":"neq","value":"buzz","description":"desc"}]},{"key":"segment2","name":"segment2","match_type":"ANY_MATCH_TYPE","description":"description"}]}
{"namespace":{"key":"bar","name":"bar","description":"bar namespace"},"flags":[{"key":"flag1","name":"flag1","type":"VARIANT_FLAG_TYPE","description":"description","enabled":true,"variants":[{"key":"variant1","name":"variant1","attachment":{"pi":3.141,"happy":true,"name":"Niels","nothing":null,"answer":{"everything":42},"list":[1,0,2],"object":{"currency":"USD","value":42.99}}},{"key":"foo"}],"rules":[{"segment":"segment1","distributions":[{"variant":"variant1","rollout":100}]},{"segment":{"keys":["segment1","segment2"],"operator":"AND_SEGMENT_OPERATOR"}}]},{"key":"flag2","name":"flag2","type":"BOOLEAN_FLAG_TYPE","description":"a boolean flag","enabled":false,"rollouts":[{"description":"enabled for internal users","segment":{"key":"internal_users","value":true}},{"description":"enabled for 50%","threshold":{"percentage":50,"value":true}}]}],"segments":[{"key":"segment1","name":"segment1","match_type":"ANY_MATCH_TYPE","description":"description","constraints":[{"type":"STRING_COMPARISON_TYPE","property":"foo","operator":"eq","value":"baz","description":"desc"},{"type":"STRING_COMPARISON_TYPE","property":"fizz","operator":"neq","value":"buzz","description":"desc"}]},{"key":"segment2","name":"segment2","match_type":"ANY_MATCH_TYPE","description":"description"}]}
{"version":"1.4","namespace":{"key":"default","name":"default","description":"default namespace"}}
{"namespace":{"key":"foo","name":"foo","description":"foo namespace"},"flags":[{"key":"flag1","name":"flag1","type":"VARIANT_FLAG_TYPE","description":"description","enabled":true,"variants":[{"key":"variant1","name":"variant1","attachment":{"answer":{"everything":42},"happy":true,"list":[1,0,2],"name":"Niels","nothing":null,"object":{"currency":"USD","value":42.99},"pi":3.141}},{"key":"foo"}],"rules":[{"segment":"segment1","distributions":[{"variant":"variant1","rollout":100}]},{"segment":{"keys":["segment1","segment2"],"operator":"AND_SEGMENT_OPERATOR"}}]},{"key":"flag2","name":"flag2","type":"BOOLEAN_FLAG_TYPE","description":"a boolean flag","enabled":false,"rollouts":[{"id":"1","description":"enabled for internal users","segment":{"key":"internal_users","value":true}},{"id":"2","description":"enabled for 50%","threshold":{"percentage":50,"value":true}}]}],"segments":[{"key":"segment1","name":"segment1","description":"description","constraints":[{"id":"1","type":"STRING_COMPARISON_TYPE","property":"foo","operator":"eq","value":"baz","description":"desc"},{"id":"2","type":"STRING_COMPARISON_TYPE","property":"fizz","operator":"neq","value":"buzz","description":"desc"}],"match_type":"ANY_MATCH_TYPE"},{"key":"segment2","name":"segment2","description":"description","match_type":"ANY_MATCH_TYPE"}]}
{"namespace":{"key":"bar","name":"bar","description":"bar namespace"},"flags":[{"key":"flag1","name":"flag1","type":"VARIANT_FLAG_TYPE","description":"description","enabled":true,"variants":[{"key":"variant1","name":"variant1","attachment":{"answer":{"everything":42},"happy":true,"list":[1,0,2],"name":"Niels","nothing":null,"object":{"currency":"USD","value":42.99},"pi":3.141}},{"key":"foo"}],"rules":[{"segment":"segment1","distributions":[{"variant":"variant1","rollout":100}]},{"segment":{"keys":["segment1","segment2"],"operator":"AND_SEGMENT_OPERATOR"}}]},{"key":"flag2","name":"flag2","type":"BOOLEAN_FLAG_TYPE","description":"a boolean flag","enabled":false,"rollouts":[{"id":"1","description":"enabled for internal users","segment":{"key":"internal_users","value":true}},{"id":"2","description":"enabled for 50%","threshold":{"percentage":50,"value":true}}]}],"segments":[{"key":"segment1","name":"segment1","description":"description","constraints":[{"id":"1","type":"STRING_COMPARISON_TYPE","property":"foo","operator":"eq","value":"baz","description":"desc"},{"id":"2","type":"STRING_COMPARISON_TYPE","property":"fizz","operator":"neq","value":"buzz","description":"desc"}],"match_type":"ANY_MATCH_TYPE"},{"key":"segment2","name":"segment2","description":"description","match_type":"ANY_MATCH_TYPE"}]}
Loading
Loading