Skip to content

Commit

Permalink
Add strategy constraints (#89)
Browse files Browse the repository at this point in the history
* Add strategy constraints

* update fields descriptions
  • Loading branch information
jdelucaa authored Dec 15, 2023
1 parent 9e87a2a commit 6515bec
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 109 deletions.
29 changes: 29 additions & 0 deletions docs/resources/feature_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ resource "unleash_feature_v2" "with_env_strategies" {
parameters = {
IPs = "189.434.777.123,host.test.com"
}
constraint {
context_name = "appName"
operator = "SEMVER_EQ"
case_insensitive = false
inverted = false
value = "1.0.0"
}
constraint {
context_name = "appName"
operator = "IN"
values = ["foo", "bar"]
}
}
strategy {
name = "flexibleRollout"
Expand Down Expand Up @@ -99,12 +111,29 @@ Required:

Optional:

- `constraint` (Block List) Strategy constraint (see [below for nested schema](#nestedblock--environment--strategy--constraint))
- `parameters` (Map of String) Strategy parameters. All the values need to informed as strings.

Read-Only:

- `id` (String) Strategy ID

<a id="nestedblock--environment--strategy--constraint"></a>
### Nested Schema for `environment.strategy.constraint`

Required:

- `context_name` (String) Constraint context. Can be `appName`, `currentTime`, `environment`, `sessionId` or `userId`
- `operator` (String) Constraint operator. Can be `IN`, `NOT_IN`, `STR_CONTAINS`, `STR_STARTS_WITH`, `STR_ENDS_WITH`, `NUM_EQ`, `NUM_GT`, `NUM_GTE`, `NUM_LT`, `NUM_LTE`, `SEMVER_EQ`, `SEMVER_GT` or `SEMVER_LT`

Optional:

- `case_insensitive` (Boolean) If operator is case-insensitive.
- `inverted` (Boolean) If constraint expressions will be negated, meaning that they get their opposite value.
- `value` (String) Value to use in the evaluation of the constraint. Applies only to `DATE_`, `NUM_` and `SEMVER_` operators.
- `values` (List of String) List of values to use in the evaluation of the constraint. Applies to all operators, except `DATE_`, `NUM_` and `SEMVER_`.




<a id="nestedblock--tag"></a>
Expand Down
12 changes: 12 additions & 0 deletions examples/resources/unleash_feature_v2/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ resource "unleash_feature_v2" "with_env_strategies" {
parameters = {
IPs = "189.434.777.123,host.test.com"
}
constraint {
context_name = "appName"
operator = "SEMVER_EQ"
case_insensitive = false
inverted = false
value = "1.0.0"
}
constraint {
context_name = "appName"
operator = "IN"
values = ["foo", "bar"]
}
}
strategy {
name = "flexibleRollout"
Expand Down
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ go 1.18
require (
github.com/hashicorp/terraform-plugin-docs v0.14.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
github.com/philips-labs/go-unleash-api v1.0.6
github.com/philips-labs/go-unleash-api v1.0.7
)

require (
github.com/hashicorp/terraform-plugin-framework v1.3.4 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
)
Expand Down Expand Up @@ -63,8 +62,6 @@ require (
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.13.1 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/mod v0.8.0 // indirect
Expand Down
Loading

0 comments on commit 6515bec

Please sign in to comment.