diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b895743..16c98ff6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -59,7 +59,7 @@ jobs: command: TESTARGS="-run TestAccEnvironment" make testacc-with-retry - run: name: Test Feature Flag Resource - command: TESTARGS="-run TestAccFeatureFlag" make testacc-with-retry + command: TESTARGS="-run TestAccFeatureFlag_" make testacc-with-retry - run: name: Test Feature Flag Environment Resource command: TESTARGS="-run TestAccFeatureFlagEnvironment" make testacc-with-retry diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bbb881c..2a67afa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [2.9.5] (January 30, 2023) + +BUG FIXES: + +- Fixes a bug that allowed target blocks to be defined with no values in Terraform, resulting in a plan differential post-apply. A minimum of 1 item has been applied to the `values` field of `launchdarkly_feature_flag_environment` resource blocks. + +NOTES: + +- Adds a note to the `launchdarkly_feature_flag_environment` documentation to recommend against usage with experimentation. +- Updates links to LaunchDarkly product and REST API documentation. + ## [2.9.4] (October 26, 2022) BUG FIXES: diff --git a/GNUmakefile b/GNUmakefile index 1316c43b..9258aea6 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -20,10 +20,7 @@ testacc: fmtcheck TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m testacc-with-retry: fmtcheck - make testacc; if [ $$? -eq 1 ]; then \ - printf "\n\nRetrying failed test\n\n"; \ - make testacc; \ - fi + make testacc || make testacc vet: @echo "go vet ." diff --git a/launchdarkly/custom_properties_helper.go b/launchdarkly/custom_properties_helper.go index 67fa6582..33c66cca 100644 --- a/launchdarkly/custom_properties_helper.go +++ b/launchdarkly/custom_properties_helper.go @@ -9,7 +9,7 @@ import ( ldapi "github.com/launchdarkly/api-client-go/v10" ) -// https://docs.launchdarkly.com/docs/custom-properties +// https://docs.launchdarkly.com/home/connecting/custom-properties const CUSTOM_PROPERTY_CHAR_LIMIT = 64 const CUSTOM_PROPERTY_ITEM_LIMIT = 64 diff --git a/launchdarkly/data_source_launchdarkly_team_test.go b/launchdarkly/data_source_launchdarkly_team_test.go index 06cb05dc..179404a5 100644 --- a/launchdarkly/data_source_launchdarkly_team_test.go +++ b/launchdarkly/data_source_launchdarkly_team_test.go @@ -7,6 +7,7 @@ import ( "regexp" "testing" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ldapi "github.com/launchdarkly/api-client-go/v10" "github.com/stretchr/testify/require" @@ -14,7 +15,7 @@ import ( func testAccDataSourceTeamConfig(teamKey string) string { return fmt.Sprintf(` -data "launchdarkly_team" "chicken-nugget" { +data "launchdarkly_team" "test" { key = "%s" } `, teamKey) @@ -66,11 +67,11 @@ func TestAccDataSourceTeam_exists(t *testing.T) { // Populate account with dummy team client, err := newClient(os.Getenv(LAUNCHDARKLY_ACCESS_TOKEN), os.Getenv(LAUNCHDARKLY_API_HOST), false) require.NoError(t, err) - teamKey := "chicken-nugget" + teamKey := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) team, createErr := testAccDataSourceTeamCreate(client, teamKey) require.NoError(t, createErr) - resourceName := fmt.Sprintf("data.launchdarkly_team.%s", teamKey) + resourceName := "data.launchdarkly_team.test" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) diff --git a/launchdarkly/environments_helper.go b/launchdarkly/environments_helper.go index aef0d0a1..46b8f56f 100644 --- a/launchdarkly/environments_helper.go +++ b/launchdarkly/environments_helper.go @@ -43,7 +43,7 @@ func baseEnvironmentSchema(forProject bool) map[string]*schema.Schema { Type: schema.TypeInt, Optional: true, Default: 0, - // Default TTL should be between 0 and 60 minutes: https://docs.launchdarkly.com/docs/environments + // Default TTL should be between 0 and 60 minutes: https://docs.launchdarkly.com/home/organize/environments#ttl-settings Description: "The TTL for the environment. This must be between 0 and 60 minutes. The TTL setting only applies to environments using the PHP SDK", ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 60)), }, diff --git a/launchdarkly/resource_launchdarkly_feature_flag.go b/launchdarkly/resource_launchdarkly_feature_flag.go index 403c5bce..404b345f 100644 --- a/launchdarkly/resource_launchdarkly_feature_flag.go +++ b/launchdarkly/resource_launchdarkly_feature_flag.go @@ -153,7 +153,7 @@ func resourceFeatureFlagCreate(ctx context.Context, d *schema.ResourceData, meta } // ld's api does not allow some fields to be passed in during flag creation so we do an update: - // https://apidocs.launchdarkly.com/docs/create-feature-flag + // https://apidocs.launchdarkly.com/tag/Feature-flags#operation/postFeatureFlag updateDiags := resourceFeatureFlagUpdate(ctx, d, metaRaw) if updateDiags.HasError() { // if there was a problem in the update state, we need to clean up completely by deleting the flag diff --git a/launchdarkly/resource_launchdarkly_feature_flag_environment_test.go b/launchdarkly/resource_launchdarkly_feature_flag_environment_test.go index 5081fb9d..f38edfca 100644 --- a/launchdarkly/resource_launchdarkly_feature_flag_environment_test.go +++ b/launchdarkly/resource_launchdarkly_feature_flag_environment_test.go @@ -96,10 +96,6 @@ resource "launchdarkly_feature_flag_environment" "basic" { values = ["user1", "user2"] variation = 1 } - targets { - values = [] - variation = 2 - } rules { clauses { attribute = "country" @@ -537,13 +533,11 @@ func TestAccFeatureFlagEnvironment_Update(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "fallthrough.0.rollout_weights.1", "40000"), resource.TestCheckResourceAttr(resourceName, "fallthrough.0.rollout_weights.2", "0"), resource.TestCheckResourceAttr(resourceName, "fallthrough.0.bucket_by", "email"), - resource.TestCheckResourceAttr(resourceName, "targets.#", "2"), + resource.TestCheckResourceAttr(resourceName, "targets.#", "1"), resource.TestCheckResourceAttr(resourceName, "targets.0.values.#", "2"), resource.TestCheckResourceAttr(resourceName, "targets.0.values.0", "user1"), resource.TestCheckResourceAttr(resourceName, "targets.0.variation", "1"), resource.TestCheckResourceAttr(resourceName, "targets.0.values.1", "user2"), - resource.TestCheckResourceAttr(resourceName, "targets.1.values.#", "0"), - resource.TestCheckResourceAttr(resourceName, "targets.1.variation", "2"), resource.TestCheckResourceAttr(resourceName, "rules.#", "2"), resource.TestCheckResourceAttr(resourceName, "rules.0.variation", "0"), resource.TestCheckResourceAttr(resourceName, "rules.0.clauses.#", "1"), diff --git a/launchdarkly/target_helper.go b/launchdarkly/target_helper.go index f9b7494c..3289a07c 100644 --- a/launchdarkly/target_helper.go +++ b/launchdarkly/target_helper.go @@ -18,6 +18,7 @@ func targetsSchema() *schema.Schema { Type: schema.TypeList, Elem: &schema.Schema{Type: schema.TypeString}, Required: true, + MinItems: 1, Description: "List of user strings to target", }, VARIATION: { diff --git a/scripts/codegen/manifestgen/generator.go b/scripts/codegen/manifestgen/generator.go index 43ff974e..186d5475 100644 --- a/scripts/codegen/manifestgen/generator.go +++ b/scripts/codegen/manifestgen/generator.go @@ -7,6 +7,7 @@ import ( ) var OMITTED_INTEGRATION_KEYS = []string{ + "msteams-app", "zapier", // Zapier is omitted because it the integration configuration is managed by Zapier } diff --git a/website/docs/d/environment.html.markdown b/website/docs/d/environment.html.markdown index da432340..4b446008 100644 --- a/website/docs/d/environment.html.markdown +++ b/website/docs/d/environment.html.markdown @@ -40,9 +40,9 @@ In addition to the arguments above, the resource exports the following attribute - `secure_mode` - A value of true `true` ensures a user of the client-side SDK cannot impersonate another user. -- `default_track_events` - A value of `true` enables data export for every flag created in this environment. To learn more, read [Data Export](https://docs.launchdarkly.com/docs/data-export). +- `default_track_events` - A value of `true` enables data export for every flag created in this environment. To learn more, read [Data Export](https://docs.launchdarkly.com/home/data-export). -- `default_ttl` - The TTL for the environment. This will be a numeric value between 0 and 60 in minutes. The TTL setting only applies to environments using the PHP SDK. To learn more, read [TTL settings](https://docs.launchdarkly.com/docs/environments#section-ttl-settings). +- `default_ttl` - The TTL for the environment. This will be a numeric value between 0 and 60 in minutes. The TTL setting only applies to environments using the PHP SDK. To learn more, read [TTL settings](https://docs.launchdarkly.com/home/organize/environments#ttl-settings). - `require_comments` - A value of `true` indicates that this environment requires comments for flag and segment changes. diff --git a/website/docs/d/feature_flag.html.markdown b/website/docs/d/feature_flag.html.markdown index e9dff707..c7f0cd14 100644 --- a/website/docs/d/feature_flag.html.markdown +++ b/website/docs/d/feature_flag.html.markdown @@ -52,7 +52,7 @@ In addition to the arguments above, the resource exports the following attribute - `client_side_availability` - A map describing whether this flag has been made available to the client-side JavaScript SDK. To learn more, read [Nested Client-Side Availability Block](#nested-client-side-availability-block). -- `custom_properties` - List of nested blocks describing the feature flag's [custom properties](https://docs.launchdarkly.com/docs/custom-properties). To learn more, read [Nested Custom Properties](#nested-custom-properties). +- `custom_properties` - List of nested blocks describing the feature flag's [custom properties](https://docs.launchdarkly.com/home/connecting/custom-properties). To learn more, read [Nested Custom Properties](#nested-custom-properties). ### Nested Variations Blocks diff --git a/website/docs/r/access_token.html.markdown b/website/docs/r/access_token.html.markdown index 16bf93f6..f2215c33 100644 --- a/website/docs/r/access_token.html.markdown +++ b/website/docs/r/access_token.html.markdown @@ -63,9 +63,9 @@ An access token may have its permissions specified by a built-in LaunchDarkly ro - `custom_roles` - (Optional) A list of custom role IDs to use as access limits for the access token -- `policy_statements` - (Optional, **Deprecated**) Define inline custom roles. An array of statements represented as config blocks with 3 attributes: effect, resources, actions. May be used in place of a built-in or custom role. [Policies in custom roles](https://docs.launchdarkly.com/docs/policies-in-custom-roles). May be specified more than once. This field argument is **deprecated**. Please update your config to use `inline_role` to maintain compatibility with future versions. +- `policy_statements` - (Optional, **Deprecated**) Define inline custom roles. An array of statements represented as config blocks with three attributes: effect, resources, actions. May be used in place of a built-in or custom role. May be specified more than once. This field argument is **deprecated**. Update your config to use `inline_role` to maintain compatibility with future versions. -- `inline_role` - (Optional) Define inline custom roles. An array of statements represented as config blocks with 3 attributes: effect, resources, actions. May be used in place of a built-in or custom role. [Policies in custom roles](https://docs.launchdarkly.com/docs/policies-in-custom-roles). May be specified more than once. +- `inline_role` - (Optional) Define inline custom roles. An array of statements represented as config blocks with three attributes: effect, resources, actions. May be used in place of a built-in or custom role. [Using polices](https://docs.launchdarkly.com/home/members/role-policies). May be specified more than once. Access token `policy_statements` and `inline_role` blocks are composed of the following arguments: diff --git a/website/docs/r/custom_role.html.markdown b/website/docs/r/custom_role.html.markdown index 1365c818..c32a01e3 100644 --- a/website/docs/r/custom_role.html.markdown +++ b/website/docs/r/custom_role.html.markdown @@ -44,19 +44,19 @@ resource "launchdarkly_custom_role" "example" { - `base_permissions` - (Optional) The base permission level. Either `reader` or `no_access`. Defaults to `reader` if not set. -- `policy_statements` - (Required) The custom role policy block. To learn more, read [Policies in custom roles](https://docs.launchdarkly.com/docs/policies-in-custom-roles). +- `policy_statements` - (Required) The custom role policy block. To learn more, read [Using policies](https://docs.launchdarkly.com/home/members/role-policies). Custom role `policy_statements` blocks are composed of the following arguments: - `effect` - (Required) - Either `allow` or `deny`. This argument defines whether the statement allows or denies access to the named resources and actions. -- `resources` - (Optional) - The list of resource specifiers defining the resources to which the statement applies. Either `resources` or `not_resources` must be specified. For a list of available resources read [Understanding resource types and scopes](https://docs.launchdarkly.com/home/account-security/custom-roles/resources#understanding-resource-types-and-scopes). +- `resources` - (Optional) - The list of resource specifiers defining the resources to which the statement applies. Either `resources` or `not_resources` must be specified. For a list of available resources read [Understanding resource types and scopes](https://docs.launchdarkly.com/home/members/role-resources#understanding-resource-types-and-scopes). -- `not_resources` - (Optional) - The list of resource specifiers defining the resources to which the statement does not apply. Either `resources` or `not_resources` must be specified. For a list of available resources read [Understanding resource types and scopes](https://docs.launchdarkly.com/home/account-security/custom-roles/resources#understanding-resource-types-and-scopes). +- `not_resources` - (Optional) - The list of resource specifiers defining the resources to which the statement does not apply. Either `resources` or `not_resources` must be specified. For a list of available resources read [Understanding resource types and scopes](https://docs.launchdarkly.com/home/members/role-resources#understanding-resource-types-and-scopes). -- `actions` - (Optional) The list of action specifiers defining the actions to which the statement applies. Either `actions` or `not_actions` must be specified. For a list of available actions read [Actions reference](https://docs.launchdarkly.com/home/account-security/custom-roles/actions#actions-reference). +- `actions` - (Optional) The list of action specifiers defining the actions to which the statement applies. Either `actions` or `not_actions` must be specified. For a list of available actions read [Actions reference](https://docs.launchdarkly.com/home/members/role-actions#actions-reference). -- `not_actions` - (Optional) The list of action specifiers defining the actions to which the statement does not apply. Either `actions` or `not_actions` must be specified. For a list of available actions read [Actions reference](https://docs.launchdarkly.com/home/account-security/custom-roles/actions#actions-reference). +- `not_actions` - (Optional) The list of action specifiers defining the actions to which the statement does not apply. Either `actions` or `not_actions` must be specified. For a list of available actions read [Actions reference](https://docs.launchdarkly.com/home/members/role-actions#actions-reference). ## Import diff --git a/website/docs/r/environment.html.markdown b/website/docs/r/environment.html.markdown index f6770191..15661a3d 100644 --- a/website/docs/r/environment.html.markdown +++ b/website/docs/r/environment.html.markdown @@ -58,9 +58,9 @@ resource "launchdarkly_environment" "approvals_example" { - `secure_mode` - (Optional) Set to `true` to ensure a user of the client-side SDK cannot impersonate another user. This field will default to `false` when not set. -- `default_track_events` - (Optional) 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/docs/data-export). +- `default_track_events` - (Optional) 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` - (Optional) 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/docs/environments#section-ttl-settings). +- `default_ttl` - (Optional) 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` - (Optional) 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/website/docs/r/feature_flag.html.markdown b/website/docs/r/feature_flag.html.markdown index 198755d6..9ac42208 100644 --- a/website/docs/r/feature_flag.html.markdown +++ b/website/docs/r/feature_flag.html.markdown @@ -100,7 +100,7 @@ resource "launchdarkly_feature_flag" "json_example" { - `client_side_availability` - (Optional) A block describing whether this flag should be made available to the client-side JavaScript SDK using the client-side Id, mobile key, or both. This value gets its default from your project configuration if not set. To learn more, read [Nested Client-Side Availability Block](#nested-client-side-availability-block). -- `custom_properties` - (Optional) List of nested blocks describing the feature flag's [custom properties](https://docs.launchdarkly.com/docs/custom-properties). To learn more, read [Nested Custom Properties](#nested-custom-properties). +- `custom_properties` - (Optional) List of nested blocks describing the feature flag's [custom properties](https://docs.launchdarkly.com/home/connecting/custom-properties). To learn more, read [Nested Custom Properties](#nested-custom-properties). ### Nested Variations Blocks diff --git a/website/docs/r/feature_flag_environment.html.markdown b/website/docs/r/feature_flag_environment.html.markdown index 337d678a..48ee49ab 100644 --- a/website/docs/r/feature_flag_environment.html.markdown +++ b/website/docs/r/feature_flag_environment.html.markdown @@ -11,6 +11,8 @@ Provides a LaunchDarkly environment-specific feature flag resource. This resource allows you to create and manage environment-specific feature flags attributes within your LaunchDarkly organization. +-> **Note:** If you intend to attach a feature flag to any experiments, we do _not_ recommend configuring environment-specific flag settings using Terraform. Subsequent applies may overwrite the changes made by experiments and break your experiment. An alternate workaround is to use the [lifecycle.ignore_changes](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle#ignore_changes) Terraform meta-argument on the `fallthrough` field to prevent potential overwrites. + ## Example Usage ```hcl diff --git a/website/docs/r/project.html.markdown b/website/docs/r/project.html.markdown index 14b937ac..bee28b51 100644 --- a/website/docs/r/project.html.markdown +++ b/website/docs/r/project.html.markdown @@ -74,9 +74,9 @@ Nested `environments` blocks have the following structure: - `secure_mode` - (Optional) Set to `true` to ensure a user of the client-side SDK cannot impersonate another user. This field will default to `false` when not set. -- `default_track_events` - (Optional) 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/docs/data-export). +- `default_track_events` - (Optional) 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` - (Optional) 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/docs/environments#section-ttl-settings). +- `default_ttl` - (Optional) 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` - (Optional) 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/website/docs/r/team_member.html.markdown b/website/docs/r/team_member.html.markdown index fc9795be..f4024789 100644 --- a/website/docs/r/team_member.html.markdown +++ b/website/docs/r/team_member.html.markdown @@ -11,7 +11,7 @@ Provides a LaunchDarkly team member resource. This resource allows you to create and manage team members within your LaunchDarkly organization. --> **Note:** You can only manage team members with "admin" level personal access tokens. To learn more, read [Managing Teams](https://docs.launchdarkly.com/docs/teams/managing). +-> **Note:** You can only manage team members with "admin" level personal access tokens. To learn more, read [Managing Teams](https://docs.launchdarkly.com/home/teams/managing). ## Example Usage