diff --git a/docs/data-sources/environment.md b/docs/data-sources/environment.md index 2b462936..f26b2999 100644 --- a/docs/data-sources/environment.md +++ b/docs/data-sources/environment.md @@ -30,6 +30,10 @@ data "launchdarkly_environment" "example" { - `key` (String) The project-unique key for the environment. - `project_key` (String) The environment's project key. +### Optional + +- `critical` (Boolean) Denotes whether the environment is critical. + ### Read-Only - `api_key` (String, Sensitive) The environment's SDK key. diff --git a/docs/resources/environment.md b/docs/resources/environment.md index 55d59212..3d4ef838 100644 --- a/docs/resources/environment.md +++ b/docs/resources/environment.md @@ -59,6 +59,7 @@ resource "launchdarkly_environment" "approvals_example" { - `approval_settings` (Block List) (see [below for nested schema](#nestedblock--approval_settings)) - `confirm_changes` (Boolean) Set to `true` if this environment requires confirmation for flag and segment changes. This field will default to `false` when not set. +- `critical` (Boolean) Denotes whether the environment is critical. - `default_track_events` (Boolean) Set to `true` to enable data export for every flag created in this environment after you configure this argument. This field will default to `false` when not set. To learn more, read [Data Export](https://docs.launchdarkly.com/home/data-export). - `default_ttl` (Number) The TTL for the environment. This must be between 0 and 60 minutes. The TTL setting only applies to environments using the PHP SDK. This field will default to `0` when not set. To learn more, read [TTL settings](https://docs.launchdarkly.com/home/organize/environments#ttl-settings). - `require_comments` (Boolean) Set to `true` if this environment requires comments for flag and segment changes. This field will default to `false` when not set. diff --git a/docs/resources/feature_flag_environment.md b/docs/resources/feature_flag_environment.md index d0916f9b..507b9327 100644 --- a/docs/resources/feature_flag_environment.md +++ b/docs/resources/feature_flag_environment.md @@ -19,6 +19,7 @@ This resource allows you to create and manage environment-specific feature flags ## Example Usage ```terraform +# This example shows the use of prerequisites, targets, context targets, rules, and fallthrough for a feature flag environment resource "launchdarkly_feature_flag_environment" "number_ff_env" { flag_id = launchdarkly_feature_flag.number.id env_key = launchdarkly_environment.staging.key @@ -68,6 +69,115 @@ resource "launchdarkly_feature_flag_environment" "number_ff_env" { } off_variation = 2 } + +# This example shows the minimum configuration required to create a feature flag environment +resource "launchdarkly_feature_flag_environment" "basic_flag_environment" { + flag_id = launchdarkly_feature_flag.basic_flag.id + env_key = "development" + + on = true + + fallthrough { + variation = 1 + } + off_variation = 0 +} + +# This example shows a feature flag environment with a targeting rule that uses every clause operator +resource "launchdarkly_feature_flag_environment" "big_flag_environment" { + flag_id = launchdarkly_feature_flag.big_flag.id + env_key = "development" + + on = true + + rules { + description = "Example targeting rule with every clause operator" + clauses { + attribute = "username" + op = "in" // Maps to 'is one of' in the UI + values = ["henrietta powell", "wally waterbear"] + } + clauses { + attribute = "username" + op = "endsWith" // Maps to 'ends with' in the UI + values = ["powell", "waterbear"] + } + clauses { + attribute = "username" + op = "startsWith" // Maps to 'starts with' in the UI + values = ["henrietta", "wally"] + } + clauses { + attribute = "username" + op = "matches" // Maps to 'matches regex' in the UI + values = ["henr*"] + } + clauses { + attribute = "username" + op = "contains" // Maps to 'contains' in the UI + values = ["water"] + } + clauses { + attribute = "pageVisits" + op = "lessThan" // Maps to 'less than (<)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "lessThanOrEqual" // Maps to 'less than or equal to (<=)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "greaterThan" // Maps to 'greater than (>)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "greaterThanOrEqual" // Maps to 'greater than or equal to (>=)' in the UI + values = [100] + } + clauses { + attribute = "creationDate" + op = "before" // Maps to 'before' in the UI + values = ["2024-05-03T15:57:30Z"] + } + clauses { + attribute = "creationDate" + op = "after" // Maps to 'after' in the UI + values = ["2024-05-03T15:57:30Z"] + } + clauses { + attribute = "version" + op = "semVerEqual" // Maps to 'semantic version is one of (=)' in the UI + values = ["1.0.0", "1.0.1"] + context_kind = "application" + } + clauses { + attribute = "version" + op = "semVerLessThan" // Maps to 'semantic version less than (<)' in the UI + values = ["1.0.0"] + context_kind = "application" + } + clauses { + attribute = "version" + op = "semVerGreaterThan" // Maps to 'semantic version greater than (>)' in the UI + values = ["1.0.0"] + context_kind = "application" + } + clauses { + attribute = "context" + op = "segmentMatch" // Maps to 'Context is in' in the UI + values = ["test-segment"] + } + variation = 0 + } + + fallthrough { + variation = 1 + } + off_variation = 0 +} ``` @@ -140,7 +250,7 @@ Optional: Required: - `attribute` (String) The user attribute to operate on -- `op` (String) The operator associated with the rule clause. Available options are `in`, `endsWith`, `startsWith`, `matches`, `contains`, `lessThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `segmentMatch`, `semVerEqual`, `semVerLessThan`, and `semVerGreaterThan`. +- `op` (String) The operator associated with the rule clause. Available options are `in`, `endsWith`, `startsWith`, `matches`, `contains`, `lessThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `segmentMatch`, `semVerEqual`, `semVerLessThan`, and `semVerGreaterThan`. Read LaunchDarkly's [Operators](https://docs.launchdarkly.com/sdk/concepts/flag-evaluation-rules#operators) documentation for more information. - `values` (List of String) The list of values associated with the rule clause. Optional: diff --git a/docs/resources/segment.md b/docs/resources/segment.md index 7b24e85d..1b8c5454 100644 --- a/docs/resources/segment.md +++ b/docs/resources/segment.md @@ -16,6 +16,7 @@ This resource allows you to create and manage segments within your LaunchDarkly ## Example Usage ```terraform +# This example shows the use of tags, targets, context targets, and rules for a segment resource "launchdarkly_segment" "example" { key = "example-segment-key" project_key = launchdarkly_project.example.key @@ -41,6 +42,7 @@ resource "launchdarkly_segment" "example" { } } +# This example shows a segment configured to have an unbounded number of individual targets resource "launchdarkly_segment" "big-example" { key = "example-big-segment-key" project_key = launchdarkly_project.example.key @@ -51,6 +53,95 @@ resource "launchdarkly_segment" "big-example" { unbounded = true unbounded_context_kind = "user" } + +# This example shows a segment with a targeting rule that uses all clause operators +resource "launchdarkly_segment" "segment_with_all_clause_operators" { + name = "Segment with all clause operators" + key = "segment-operators" + project_key = "projectx" + env_key = "development" + + rules { + clauses { + attribute = "username" + op = "in" // Maps to 'is one of' in the UI + values = ["henrietta powell", "wally waterbear"] + } + clauses { + attribute = "username" + op = "endsWith" // Maps to 'ends with' in the UI + values = ["powell", "waterbear"] + } + clauses { + attribute = "username" + op = "startsWith" // Maps to 'starts with' in the UI + values = ["henrietta", "wally"] + } + clauses { + attribute = "username" + op = "matches" // Maps to 'matches regex' in the UI + values = ["henr*"] + } + clauses { + attribute = "username" + op = "contains" // Maps to 'contains' in the UI + values = ["water"] + } + clauses { + attribute = "pageVisits" + op = "lessThan" // Maps to 'less than (<)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "lessThanOrEqual" // Maps to 'less than or equal to (<=)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "greaterThan" // Maps to 'greater than (>)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "greaterThanOrEqual" // Maps to 'greater than or equal to (>=)' in the UI + values = [100] + } + clauses { + attribute = "creationDate" + op = "before" // Maps to 'before' in the UI + values = ["2024-05-03T15:57:30Z"] + } + clauses { + attribute = "creationDate" + op = "after" // Maps to 'after' in the UI + values = ["2024-05-03T15:57:30Z"] + } + clauses { + attribute = "version" + op = "semVerEqual" // Maps to 'semantic version is one of (=)' in the UI + values = ["1.0.0", "1.0.1"] + context_kind = "application" + } + clauses { + attribute = "version" + op = "semVerLessThan" // Maps to 'semantic version less than (<)' in the UI + values = ["1.0.0"] + context_kind = "application" + } + clauses { + attribute = "version" + op = "semVerGreaterThan" // Maps to 'semantic version greater than (>)' in the UI + values = ["1.0.0"] + context_kind = "application" + } + clauses { + attribute = "context" + op = "segmentMatch" // Maps to 'Context is in' in the UI + values = ["test-segment"] + } + } +} ``` @@ -114,7 +205,7 @@ Optional: Required: - `attribute` (String) The user attribute to operate on -- `op` (String) The operator associated with the rule clause. Available options are `in`, `endsWith`, `startsWith`, `matches`, `contains`, `lessThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `segmentMatch`, `semVerEqual`, `semVerLessThan`, and `semVerGreaterThan`. +- `op` (String) The operator associated with the rule clause. Available options are `in`, `endsWith`, `startsWith`, `matches`, `contains`, `lessThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `segmentMatch`, `semVerEqual`, `semVerLessThan`, and `semVerGreaterThan`. Read LaunchDarkly's [Operators](https://docs.launchdarkly.com/sdk/concepts/flag-evaluation-rules#operators) documentation for more information. - `values` (List of String) The list of values associated with the rule clause. Optional: diff --git a/examples/resources/launchdarkly_feature_flag_environment/resource.tf b/examples/resources/launchdarkly_feature_flag_environment/resource.tf index 01ca4965..50f63dec 100644 --- a/examples/resources/launchdarkly_feature_flag_environment/resource.tf +++ b/examples/resources/launchdarkly_feature_flag_environment/resource.tf @@ -1,3 +1,4 @@ +# This example shows the use of prerequisites, targets, context targets, rules, and fallthrough for a feature flag environment resource "launchdarkly_feature_flag_environment" "number_ff_env" { flag_id = launchdarkly_feature_flag.number.id env_key = launchdarkly_environment.staging.key @@ -47,3 +48,112 @@ resource "launchdarkly_feature_flag_environment" "number_ff_env" { } off_variation = 2 } + +# This example shows the minimum configuration required to create a feature flag environment +resource "launchdarkly_feature_flag_environment" "basic_flag_environment" { + flag_id = launchdarkly_feature_flag.basic_flag.id + env_key = "development" + + on = true + + fallthrough { + variation = 1 + } + off_variation = 0 +} + +# This example shows a feature flag environment with a targeting rule that uses every clause operator +resource "launchdarkly_feature_flag_environment" "big_flag_environment" { + flag_id = launchdarkly_feature_flag.big_flag.id + env_key = "development" + + on = true + + rules { + description = "Example targeting rule with every clause operator" + clauses { + attribute = "username" + op = "in" // Maps to 'is one of' in the UI + values = ["henrietta powell", "wally waterbear"] + } + clauses { + attribute = "username" + op = "endsWith" // Maps to 'ends with' in the UI + values = ["powell", "waterbear"] + } + clauses { + attribute = "username" + op = "startsWith" // Maps to 'starts with' in the UI + values = ["henrietta", "wally"] + } + clauses { + attribute = "username" + op = "matches" // Maps to 'matches regex' in the UI + values = ["henr*"] + } + clauses { + attribute = "username" + op = "contains" // Maps to 'contains' in the UI + values = ["water"] + } + clauses { + attribute = "pageVisits" + op = "lessThan" // Maps to 'less than (<)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "lessThanOrEqual" // Maps to 'less than or equal to (<=)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "greaterThan" // Maps to 'greater than (>)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "greaterThanOrEqual" // Maps to 'greater than or equal to (>=)' in the UI + values = [100] + } + clauses { + attribute = "creationDate" + op = "before" // Maps to 'before' in the UI + values = ["2024-05-03T15:57:30Z"] + } + clauses { + attribute = "creationDate" + op = "after" // Maps to 'after' in the UI + values = ["2024-05-03T15:57:30Z"] + } + clauses { + attribute = "version" + op = "semVerEqual" // Maps to 'semantic version is one of (=)' in the UI + values = ["1.0.0", "1.0.1"] + context_kind = "application" + } + clauses { + attribute = "version" + op = "semVerLessThan" // Maps to 'semantic version less than (<)' in the UI + values = ["1.0.0"] + context_kind = "application" + } + clauses { + attribute = "version" + op = "semVerGreaterThan" // Maps to 'semantic version greater than (>)' in the UI + values = ["1.0.0"] + context_kind = "application" + } + clauses { + attribute = "context" + op = "segmentMatch" // Maps to 'Context is in' in the UI + values = ["test-segment"] + } + variation = 0 + } + + fallthrough { + variation = 1 + } + off_variation = 0 +} diff --git a/examples/resources/launchdarkly_segment/resource.tf b/examples/resources/launchdarkly_segment/resource.tf index 58d0299b..2181ec37 100644 --- a/examples/resources/launchdarkly_segment/resource.tf +++ b/examples/resources/launchdarkly_segment/resource.tf @@ -1,3 +1,4 @@ +# This example shows the use of tags, targets, context targets, and rules for a segment resource "launchdarkly_segment" "example" { key = "example-segment-key" project_key = launchdarkly_project.example.key @@ -23,6 +24,7 @@ resource "launchdarkly_segment" "example" { } } +# This example shows a segment configured to have an unbounded number of individual targets resource "launchdarkly_segment" "big-example" { key = "example-big-segment-key" project_key = launchdarkly_project.example.key @@ -33,3 +35,92 @@ resource "launchdarkly_segment" "big-example" { unbounded = true unbounded_context_kind = "user" } + +# This example shows a segment with a targeting rule that uses all clause operators +resource "launchdarkly_segment" "segment_with_all_clause_operators" { + name = "Segment with all clause operators" + key = "segment-operators" + project_key = "projectx" + env_key = "development" + + rules { + clauses { + attribute = "username" + op = "in" // Maps to 'is one of' in the UI + values = ["henrietta powell", "wally waterbear"] + } + clauses { + attribute = "username" + op = "endsWith" // Maps to 'ends with' in the UI + values = ["powell", "waterbear"] + } + clauses { + attribute = "username" + op = "startsWith" // Maps to 'starts with' in the UI + values = ["henrietta", "wally"] + } + clauses { + attribute = "username" + op = "matches" // Maps to 'matches regex' in the UI + values = ["henr*"] + } + clauses { + attribute = "username" + op = "contains" // Maps to 'contains' in the UI + values = ["water"] + } + clauses { + attribute = "pageVisits" + op = "lessThan" // Maps to 'less than (<)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "lessThanOrEqual" // Maps to 'less than or equal to (<=)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "greaterThan" // Maps to 'greater than (>)' in the UI + values = [100] + } + clauses { + attribute = "pageVisits" + op = "greaterThanOrEqual" // Maps to 'greater than or equal to (>=)' in the UI + values = [100] + } + clauses { + attribute = "creationDate" + op = "before" // Maps to 'before' in the UI + values = ["2024-05-03T15:57:30Z"] + } + clauses { + attribute = "creationDate" + op = "after" // Maps to 'after' in the UI + values = ["2024-05-03T15:57:30Z"] + } + clauses { + attribute = "version" + op = "semVerEqual" // Maps to 'semantic version is one of (=)' in the UI + values = ["1.0.0", "1.0.1"] + context_kind = "application" + } + clauses { + attribute = "version" + op = "semVerLessThan" // Maps to 'semantic version less than (<)' in the UI + values = ["1.0.0"] + context_kind = "application" + } + clauses { + attribute = "version" + op = "semVerGreaterThan" // Maps to 'semantic version greater than (>)' in the UI + values = ["1.0.0"] + context_kind = "application" + } + clauses { + attribute = "context" + op = "segmentMatch" // Maps to 'Context is in' in the UI + values = ["test-segment"] + } + } +} diff --git a/go.mod b/go.mod index 36ba912f..7250b3e7 100644 --- a/go.mod +++ b/go.mod @@ -73,12 +73,12 @@ require ( github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/zclconf/go-cty v1.13.2 // indirect - golang.org/x/crypto v0.17.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect golang.org/x/mod v0.11.0 // indirect - golang.org/x/net v0.17.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.6.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index fb8c7020..0b662281 100644 --- a/go.sum +++ b/go.sum @@ -863,8 +863,8 @@ golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5 golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -960,8 +960,8 @@ golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1086,12 +1086,12 @@ golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= 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.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/launchdarkly/clause_helper.go b/launchdarkly/clause_helper.go index 7fcb8d40..8a028fef 100644 --- a/launchdarkly/clause_helper.go +++ b/launchdarkly/clause_helper.go @@ -31,7 +31,7 @@ func clauseSchema() *schema.Schema { OP: { Type: schema.TypeString, Required: true, - Description: "The operator associated with the rule clause. Available options are `in`, `endsWith`, `startsWith`, `matches`, `contains`, `lessThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `segmentMatch`, `semVerEqual`, `semVerLessThan`, and `semVerGreaterThan`.", + Description: "The operator associated with the rule clause. Available options are `in`, `endsWith`, `startsWith`, `matches`, `contains`, `lessThan`, `lessThanOrEqual`, `greaterThanOrEqual`, `before`, `after`, `segmentMatch`, `semVerEqual`, `semVerLessThan`, and `semVerGreaterThan`. Read LaunchDarkly's [Operators](https://docs.launchdarkly.com/sdk/concepts/flag-evaluation-rules#operators) documentation for more information.", ValidateDiagFunc: validateOp(), }, VALUES: { diff --git a/launchdarkly/environments_helper.go b/launchdarkly/environments_helper.go index 7eb22e34..c71499c3 100644 --- a/launchdarkly/environments_helper.go +++ b/launchdarkly/environments_helper.go @@ -29,6 +29,12 @@ func baseEnvironmentSchema(options environmentSchemaOptions) map[string]*schema. ForceNew: !options.forProject, ValidateDiagFunc: validateKey(), }, + CRITICAL: { + Type: schema.TypeBool, + Optional: true, + Default: false, + Description: "Denotes whether the environment is critical.", + }, API_KEY: { Type: schema.TypeString, Computed: true, @@ -130,12 +136,22 @@ func getEnvironmentUpdatePatches(oldConfig, config map[string]interface{}) ([]ld patches = append(patches, patchReplace("/confirmChanges", confirmChanges)) } + kind, ok := config[KIND] + if ok { + patches = append(patches, patchReplace("/kind", kind)) + } + tags, ok := config[TAGS] if ok { envTags := stringsFromSchemaSet(tags.(*schema.Set)) patches = append(patches, patchReplace("/tags", &envTags)) } + critical, ok := config[CRITICAL] + if ok { + patches = append(patches, patchReplace("/critical", critical)) + } + var oldApprovalSettings []interface{} if oldSettings, ok := oldConfig[APPROVAL_SETTINGS]; ok { oldApprovalSettings = oldSettings.([]interface{}) @@ -225,6 +241,7 @@ func environmentToResourceData(env ldapi.Environment) envResourceData { REQUIRE_COMMENTS: env.RequireComments, CONFIRM_CHANGES: env.ConfirmChanges, TAGS: env.Tags, + CRITICAL: env.Critical, } if env.ApprovalSettings != nil { envData[APPROVAL_SETTINGS] = approvalSettingsToResourceData(*env.ApprovalSettings) @@ -273,6 +290,7 @@ func environmentRead(ctx context.Context, d *schema.ResourceData, meta interface _ = d.Set(DEFAULT_TTL, int(env.DefaultTtl)) _ = d.Set(SECURE_MODE, env.SecureMode) _ = d.Set(DEFAULT_TRACK_EVENTS, env.DefaultTrackEvents) + _ = d.Set(CRITICAL, env.Critical) // We need to update the LaunchDarkly go api client's version of Environment _ = d.Set(TAGS, env.Tags) _ = d.Set(REQUIRE_COMMENTS, env.RequireComments) _ = d.Set(CONFIRM_CHANGES, env.ConfirmChanges) diff --git a/launchdarkly/environments_helper_test.go b/launchdarkly/environments_helper_test.go index 0f5c1ebc..63df618b 100644 --- a/launchdarkly/environments_helper_test.go +++ b/launchdarkly/environments_helper_test.go @@ -90,6 +90,7 @@ func TestEnvironmentToResourceData(t *testing.T) { MOBILE_KEY: "b1235363456", CLIENT_SIDE_ID: "b234234234234", COLOR: "FFFFFF", + CRITICAL: false, DEFAULT_TTL: 60, SECURE_MODE: true, DEFAULT_TRACK_EVENTS: true, @@ -137,6 +138,40 @@ func TestEnvironmentToResourceData(t *testing.T) { DEFAULT_TRACK_EVENTS: true, REQUIRE_COMMENTS: true, CONFIRM_CHANGES: true, + CRITICAL: false, + TAGS: []string{"test"}, + }, + }, + { + name: "with critical set to true", + input: ldapi.Environment{ + Key: "test-env", + Name: "Test Env", + ApiKey: "sdk-234123123", + MobileKey: "b1235363456", + Id: "b234234234234", + Color: "FFFFFF", + DefaultTtl: 60, + SecureMode: true, + DefaultTrackEvents: true, + RequireComments: true, + ConfirmChanges: true, + Critical: true, + Tags: []string{"test"}, + }, + expected: envResourceData{ + KEY: "test-env", + NAME: "Test Env", + API_KEY: "sdk-234123123", + MOBILE_KEY: "b1235363456", + CLIENT_SIDE_ID: "b234234234234", + COLOR: "FFFFFF", + DEFAULT_TTL: 60, + SECURE_MODE: true, + DEFAULT_TRACK_EVENTS: true, + REQUIRE_COMMENTS: true, + CONFIRM_CHANGES: true, + CRITICAL: true, TAGS: []string{"test"}, }, }, diff --git a/launchdarkly/keys.go b/launchdarkly/keys.go index e3850730..7e330c60 100644 --- a/launchdarkly/keys.go +++ b/launchdarkly/keys.go @@ -23,6 +23,7 @@ const ( CONTEXT_KIND = "context_kind" CONTEXT_TARGETS = "context_targets" CREATION_DATE = "creation_date" + CRITICAL = "critical" CUSTOM_PROPERTIES = "custom_properties" CUSTOM_ROLES = "custom_roles" CUSTOM_ROLE_KEYS = "custom_role_keys"