Skip to content

Commit

Permalink
FFM-9439: Allow feature flag to add rules to multiple environments (#742
Browse files Browse the repository at this point in the history
)

After this change, we will allow the user to deploy updates to multiple
environments. Previously, we only allowed one environment to be changed
per feature flag. Now, we let multiple environments to be changed.
Target Groups and Rules are now defined inside the environment

Also include document and examples update, as well as the changelog
  • Loading branch information
ribeirophillipe committed Nov 9, 2023
1 parent 4f99a30 commit a218211
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 205 deletions.
3 changes: 3 additions & 0 deletions .changelog/742.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
Allow for multiple environments, with each environment containing its own target group and rules
```
51 changes: 28 additions & 23 deletions docs/resources/platform_feature_flag.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,12 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
value = "20"
}
add_target_rule {
variation = "trial14"
targets = ["targets1", "targets2"]
environment {
identifier = "MY_ENVIRONMENT"
add_target_rule {
variation = "trial14"
targets = ["targets1", "targets2"]
}
}
}
Expand All @@ -126,7 +129,6 @@ 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 @@ -153,24 +155,27 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
value = "20"
}
add_target_groups_rule {
group_name = "group_name"
variation = "trial14"
distribution = {
variations = [
{
variation = "trial7"
weight = 30
},
{
variation = "trial14"
weight = 30
},
{
variation = "trial20"
weight = 40
}
]
environment {
identifier = "MY_ENVIRONMENT"
add_target_groups_rule {
group_name = "group_name"
variation = "trial14"
distribution = {
variations = [
{
variation = "trial7"
weight = 30
},
{
variation = "trial14"
weight = 30
},
{
variation = "trial20"
weight = 40
}
]
}
}
}
}
Expand All @@ -196,7 +201,7 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
- `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
- `environment` (Block List, Min: 0) Environment block, containing the target group and rules
- `git_details` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--git_details))
- `owner` (String) The owner of the flag

Expand Down
49 changes: 27 additions & 22 deletions examples/resources/harness_platform_feature_flag/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
value = "20"
}

add_target_rule {
variation = "trial14"
targets = ["targets1", "targets2"]
environment {
identifier = "MY_ENVIRONMENT"
add_target_rule {
variation = "trial14"
targets = ["targets1", "targets2"]
}
}
}

Expand All @@ -111,7 +114,6 @@ 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 @@ -138,24 +140,27 @@ resource "harness_platform_feature_flag" "mymultivariateflag" {
value = "20"
}

add_target_groups_rule {
group_name = "group_name"
variation = "trial14"
distribution = {
variations = [
{
variation = "trial7"
weight = 30
},
{
variation = "trial14"
weight = 30
},
{
variation = "trial20"
weight = 40
}
]
environment {
identifier = "MY_ENVIRONMENT"
add_target_groups_rule {
group_name = "group_name"
variation = "trial14"
distribution = {
variations = [
{
variation = "trial7"
weight = 30
},
{
variation = "trial14"
weight = 30
},
{
variation = "trial20"
weight = 40
}
]
}
}
}
}
Loading

0 comments on commit a218211

Please sign in to comment.