Skip to content

Commit

Permalink
FFM-9404: harness_platform_feature_flag cannot add targeting rules (#699
Browse files Browse the repository at this point in the history
)

* FFM-9404: harness_platform_feature_flag cannot add targeting rules

* Enable feature flags to configure targets
* Update test cases
* Fix bug in the distribution
* add constants to feature flags
* update documentation
  • Loading branch information
ribeirophillipe committed Sep 20, 2023
1 parent 5529415 commit 65d0b30
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 90 deletions.
3 changes: 3 additions & 0 deletions .changelog/699.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
harness_platform_feature_flag - Enable adding target and target groups through features
```
31 changes: 17 additions & 14 deletions docs/resources/platform_feature_flag.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
kind = "int"
name = "FREE_TRIAL_DURATION"
identifier = "FREE_TRIAL_DURATION"
environment = "MY_ENVIRONMENT"
permanent = false
default_on_variation = "trial7"
Expand All @@ -111,7 +112,7 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
value = "20"
}
add_target_rules {
add_target_rule {
variation = "trial14"
targets = ["targets1", "targets2"]
}
Expand All @@ -125,6 +126,7 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
kind = "int"
name = "FREE_TRIAL_DURATION"
identifier = "FREE_TRIAL_DURATION"
environment = "MY_ENVIRONMENT"
permanent = false
default_on_variation = "trial7"
Expand All @@ -151,7 +153,7 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
value = "20"
}
add_target_groups_rules {
add_target_groups_rule {
group_name = "group_name"
variation = "trial14"
distribution = {
Expand Down Expand Up @@ -191,9 +193,10 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {

### Optional

- `add_target_group_rules` (Block List) The targeting rules for the flag (see [below for nested schema](#nestedblock--add_target_group_rules))
- `add_target_rules` (Block List) The targeting rules for the flag (see [below for nested schema](#nestedblock--add_target_rules))
- `add_target_group_rule` (Block List) The targeting rules for the flag (see [below for nested schema](#nestedblock--add_target_group_rule))
- `add_target_rule` (Block List) The targeting rules for the flag (see [below for nested schema](#nestedblock--add_target_rule))
- `archived` (Boolean) Whether or not the flag is archived
- `environment` (String) Environment Identifier
- `git_details` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--git_details))
- `owner` (String) The owner of the flag

Expand All @@ -212,24 +215,24 @@ Required:
- `value` (String) The value of the variation


<a id="nestedblock--add_target_group_rules"></a>
### Nested Schema for `add_target_group_rules`
<a id="nestedblock--add_target_group_rule"></a>
### Nested Schema for `add_target_group_rule`

Optional:

- `distribution` (Block List) The distribution of the rule (see [below for nested schema](#nestedblock--add_target_group_rules--distribution))
- `distribution` (Block List) The distribution of the rule (see [below for nested schema](#nestedblock--add_target_group_rule--distribution))
- `group_name` (String) The name of the target group
- `variation` (String) The identifier of the variation. Valid values are `enabled`, `disabled`

<a id="nestedblock--add_target_group_rules--distribution"></a>
### Nested Schema for `add_target_group_rules.distribution`
<a id="nestedblock--add_target_group_rule--distribution"></a>
### Nested Schema for `add_target_group_rule.distribution`

Optional:

- `variations` (Block List) The variations of the rule (see [below for nested schema](#nestedblock--add_target_group_rules--distribution--variations))
- `variations` (Block List) The variations of the rule (see [below for nested schema](#nestedblock--add_target_group_rule--distribution--variations))

<a id="nestedblock--add_target_group_rules--distribution--variations"></a>
### Nested Schema for `add_target_group_rules.distribution.variations`
<a id="nestedblock--add_target_group_rule--distribution--variations"></a>
### Nested Schema for `add_target_group_rule.distribution.variations`

Optional:

Expand All @@ -239,8 +242,8 @@ Optional:



<a id="nestedblock--add_target_rules"></a>
### Nested Schema for `add_target_rules`
<a id="nestedblock--add_target_rule"></a>
### Nested Schema for `add_target_rule`

Optional:

Expand Down
2 changes: 2 additions & 0 deletions examples/resources/harness_platform_feature_flag/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
kind = "int"
name = "FREE_TRIAL_DURATION"
identifier = "FREE_TRIAL_DURATION"
environment = "MY_ENVIRONMENT"
permanent = false

default_on_variation = "trial7"
Expand Down Expand Up @@ -110,6 +111,7 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
kind = "int"
name = "FREE_TRIAL_DURATION"
identifier = "FREE_TRIAL_DURATION"
environment = "MY_ENVIRONMENT"
permanent = false

default_on_variation = "trial7"
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.45.12 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -99,4 +100,4 @@ require (

//replace github.com/harness/harness-go-sdk => ../harness-go-sdk

// replace github.com/harness/harness-openapi-go-client => ../harness-openapi-go-client
// replace github.com/harness/harness-openapi-go-client => ../harness-openapi-go-client
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkE
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aws/aws-sdk-go v1.45.12 h1:+bKbbesGNPp+TeGrcqfrWuZoqcIEhjwKyBMHQPp80Jo=
github.com/aws/aws-sdk-go v1.45.12/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
Expand Down Expand Up @@ -130,6 +132,8 @@ github.com/jhump/protoreflect v1.6.1 h1:4/2yi5LyDPP7nN+Hiird1SAJ6YoxUm13/oxHGRnb
github.com/jhump/protoreflect v1.6.1/go.mod h1:RZQ/lnuN+zqeRVpQigTwO6o0AJUkxbnSnpuG7toUTG4=
github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8=
github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand Down Expand Up @@ -255,6 +259,7 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
Expand Down Expand Up @@ -286,6 +291,7 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -294,6 +300,7 @@ golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
Expand Down Expand Up @@ -339,6 +346,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
Loading

0 comments on commit 65d0b30

Please sign in to comment.