Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ConflictsWith with Lists or Sets #71

Open
jtopjian opened this issue Jan 9, 2017 · 6 comments
Open

Using ConflictsWith with Lists or Sets #71

jtopjian opened this issue Jan 9, 2017 · 6 comments
Labels
enhancement New feature or request subsystem/types Issues and feature requests related to the type system of Terraform and our shims around it. terraform-plugin-framework Resolved in terraform-plugin-framework

Comments

@jtopjian
Copy link
Contributor

jtopjian commented Jan 9, 2017

I'm trying to use ConflictsWith on a TypeList and it isn't working. I think I've narrowed down the issue, but I'm not entirely sure.

The openstack_compute_instance_v2 resource has a network attribute of TypeList. The list defines several nested attributes that can all be used to create a network.

Some of the attributes can't be used together. For example, port and floating_ip. So I made the following changes:

"port": &schema.Schema{
        Type:     schema.TypeString,
        Optional: true,
        ForceNew: true,
        Computed: true,
        ConflictsWith: []string{"network.floating_ip"},
},
"floating_ip": &schema.Schema{
        Type:     schema.TypeString,
        Optional: true,
        ForceNew: true,
        Computed: true,
        ConflictsWith: []string{"network.port"},
},

Then, given something simple like:

resource "openstack_compute_instance_v2" "instance_1" {
  name = "instance_1"
  network {
    floating_ip = "foo"
    port = "bar"
  }
}

I would expect an error to be throw, however, one isn't. But, if I change the schema to:

"port": &schema.Schema{
        Type:     schema.TypeString,
        Optional: true,
        ForceNew: true,
        Computed: true,
        ConflictsWith: []string{"network.0.floating_ip"},
},
"floating_ip": &schema.Schema{
        Type:     schema.TypeString,
        Optional: true,
        ForceNew: true,
        Computed: true,
        ConflictsWith: []string{"network.0.port"},
},

Then I get a validation error. Of course, that is only applicable to the first defined network.

Throwing some debug output into helper/schema/schema.go and terraform/resource.go, I think the following is happening:

During the loop for a conflicting key, s is network.0.port but conflicting_key is network.floating_ip. When network.floating_ip is checked here, since no index is specified, no value is returned.

@jtopjian
Copy link
Contributor Author

I think this is more of a core bug than specific to OpenStack since it deals with the core schema and resource packages. However, if I'm wrong about this, please let me know :)

@mitchellh
Copy link
Contributor

Going to tag this with enhancement since I think this is more of a feature request, I don't think this is anything we ever supported. :)

@jtopjian
Copy link
Contributor Author

That sounds good to me! I'm in no rush to implement this - I can work around it.

@rosbo
Copy link

rosbo commented Aug 4, 2017

Hi,

Having ConflictsWith work properly on a TypeList is something that would also be useful for the Google Cloud Provider.

One example among many: a Google Compute Instance can define its network_interface by referring to a network or a subnetwork. These two options are mutually exclusive. An instance can have multiple network interfaces:

resource "google_compute_instance" "i1" {
  name = "test-instance1"
  machine_type = "f1-micro"
  can_ip_forward = false
  zone = "us-east1-c"

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-8"
    }
  }

  network_interface {
    subnetwork = "${google_compute_subnetwork.network1-sub1.self_link}"
    // OR
    network = "${google_compute_network.network2.self_link}"
   // Should fail if both are defined.
  }
}

Our workaround is to fail in the Create method if both are set for a network interface. It means that terraform plan succeeds but then it fails at terraform apply. We would love to bring the validation to the planning phase.

Additionally, the schema internal validation on ConflictsWith accepts invalid path and silently do no conflict detection. We had one case in the google provider where the ConflictsWith was misused and the schema validation didn't complain. Fixed this PR

...
Schema: map[string]*schema.Schema{
  "node_pool": {
		Type:     schema.TypeList,
		Optional: true,
		Computed: true,
		ForceNew: true,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{
				"initial_node_count": {
					Type:     schema.TypeInt,
					Required: true,
                                        // WRONG: This does nothing and the schema validation does not fail!
                                        ConflictsWith: []string{"node_pool.name_prefix"},
					ForceNew: true,
				},

				"name": {
					Type:     schema.TypeString,
					Optional: true,
					Computed: true,
					ForceNew: true,
				},

				"name_prefix": {
					Type:     schema.TypeString,
					Optional: true,
					ForceNew: true,
				},
			},
		},
	},
},

ConflictsWith: []string{"node_pool.name_prefix"} does nothing because it only looks if a value is defined based on the ConflictsWith path you pass in.
https://github.com/hashicorp/terraform/blob/master/helper/schema/schema.go?utf8=%E2%9C%93#L1175

c.Get("node_pool.name_prefix") will never be set and therefor will never conflict. network_interface.0.subnetwork...network_interface.x.subnetwork are set, never the non-indexed version.

The code performing the schema validation is here:
https://github.com/hashicorp/terraform/blob/master/helper/schema/schema.go?utf8=%E2%9C%93#L590

It should make sure that the index is defined when referencing a nested field in the ConflictsWith or accept it but do proper conflict detection.

Thank you

@hashibot hashibot transferred this issue from hashicorp/terraform Sep 26, 2019
@hashibot hashibot added the enhancement New feature or request label Oct 2, 2019
@radeksimko radeksimko changed the title Using ConflictsWith with Lists Using ConflictsWith with Lists or Sets Oct 30, 2019
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Mar 18, 2020
…onflictsWith and list index/map key syntax

Reference: hashicorp#71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Mar 18, 2020
…onflictsWith and list index/map key syntax

Reference: hashicorp#71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Mar 19, 2020
…onflictsWith and list index/map key syntax

Reference: hashicorp#71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Mar 19, 2020
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Apr 24, 2020
…onflictsWith and list index/map key syntax

Reference: hashicorp#71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Apr 24, 2020
appilon pushed a commit that referenced this issue Apr 28, 2020
…onflictsWith and list index/map key syntax

Reference: #71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
bflad added a commit to bflad/terraform-plugin-sdk that referenced this issue Apr 28, 2020
appilon pushed a commit that referenced this issue Apr 28, 2020
…onflictsWith and list index/map key syntax

Reference: #71
Reference: bflad/tfproviderlint#104

The `TestSchemaMap_InternalValidate` tests also include TODOs for potential schema validation improvements.
@bflad
Copy link
Contributor

bflad commented Jul 30, 2020

Hi folks 👋 Non-SDK team member providing some additional information here.

We tightened up the validation of the AtLeastOneOf/ConflictsWith/ExactlyOneOf/RequiredWhen fields so the references can be checked via unit testing. As of the upcoming v2, the SDK should return errors if you attempt a reference of config_block_attr.child_attr instead of something like config_block_attr.0.child_attr. This validation should also be ensuring that the configuration block attributes are Type: TypeList and MaxItems: 1, to match the only supported behaviors at the moment.

As for the enhancement request, it seems like the ConflictsWith fields (and friends) could benefit from supporting relative references so that they could handle TypeList and TypeSet attributes, e.g.

Schema: map[string]*schema.Schema{
	"config_block_attr": {
		Type:     schema.TypeSet,
		Optional: true,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{
				"child_attr1": {
					Type:     schema.TypeString,
					Optional: true,
					ConflictsWith: []string{".child_attr2"},
				},
				"child_attr2": {
					Type:     schema.TypeString,
					Optional: true,
					ConflictsWith: []string{".child_attr1"},
				},
			},
		},
	},
},

Where the configuration validation could occur at the same parent-children and level of schema. It would probably need to be restricted to this specific setup rather than allowing arbitrary schema decisions. Attributes cannot begin with a period, so this new syntax should not conflict with (😅 ) existing syntax.

This is just a personal design opinion though that the SDK maintainers would need to validate if its possible and review/approve the design.

@paddycarver paddycarver added the subsystem/types Issues and feature requests related to the type system of Terraform and our shims around it. label Jan 6, 2021
shinmog added a commit to PaloAltoNetworks/terraform-provider-panos that referenced this issue Dec 31, 2021
sloloris added a commit to launchdarkly/terraform-provider-launchdarkly that referenced this issue Jan 19, 2022
* Update CHANGELOG.md

fix error in changelog

* Imiller/ch117193/rename flag_fallthrough to fallthrough & user_targets to targets (#131)

* add fallthrough and deprecate message to flag_fallthrough

* update doc

* conflicts with

* handle

* update a test

* update changelog

* fix typos in docs

* add targets attribute

* fix linter complaint

* handle in create

* update

* handle read

* update commetn

* update tests

* hack remove user_targets from plan

* set both computed attributes in read

* update changelog

* always set

* simplify helper

* fix data source test

* add test for deprecated field updates

* fix fromResourceData functions

* check renamed on as well

* Update data source d oc

* update data source tests

* Imiller/ch117375/GitHub issue empty string variation (#135)

* should fix it

* add test case

* update changelog and doc

* Fix duplicate text in CHANGELOG.md

Somehow the changelog test was duplicated. Removing, and we can fix the changelog on our next release.

* V2 main (#128)

* destination on should default to false (v2) (#124)

* remove enabled

* test that on defaults to false when removed

* Imiller/ch115579/fix include in snippet bug (#129)

* all it needed was a default val

* add test to ensure optional attributes get set correctly when removed

* fix test

* use TestCheckNoResourceAttr instead of TestCheckResourceAttr

* update changelog

* Imiller/ch113419/upgrade terraform client to v2 (#114)

* run v2 helper

* replace hashcode.String() with schema.HashString()

* replace terraform.ResourceProvider with *schema.Provider

* fix data source TypeMaps

* bump v2 sdk to latest (#116)

* merge

* Remove versions.tf (#119)

* Imiller/ch114162/upgrade resource launchdarkly environment (#121)

* make project_key required

* update descriptions

* update changelog

* Imiller/ch114165/v1 project audit (#120)

* add descriptions

* update doc dscription

* audit team member for v1 (#122)

* update descriptions

* add import instructions to team member docs

* add team member examples

* ForceNew when email is updated

* update test file structure to better reflect provider pattern

* add AtLeastOneOf for role and custom_roles

* oops wrong doc

* use validation.StringInSlice()

* refactor key conversion functions into helper file

* remove owner

* forgot changelog

* Imiller/ch114163/v1 feature flag env (#112)

* add descriptions for everything

* fix dangling default values

* fix bug where creating a non-bool flag with no variations creates a bool flag

* add bug fixes to changelog

* built in an idiotic bug, fixed now

* see if this fixes all of the tests

* found typo:

* fix broken tests

* add descriptions

* update some descriptions for clarity

* make clauses RequiredWith on variations to preempt api error

* fix error in doc

* fix docs properly

* deprecated targeting_enabled in favor of on

* remove ReuqiredWith because it's causing a bug

* fix plan bug

* hopefully this will fix it

* ughhhhh it was that it needed to be computed

* forgot the doc oops

* forgot the changelog too meep

* destination on should default to false (v2) (#124)

* remove enabled

* test that on defaults to false when removed

* Imiller/ch114160/v1 custom role (#125)

* add descriptions

* reformat tests to match pattern

* check removal of optional attributes removes

* holy crap how did this not break earlier

* not sure how that one stuck around either

* somehow we were not actually setting the flag_id

* fix feature flag read

* fix csa on project read

* apparently errors are different too

* remove lingering merge conflict text from changelog

* fix noMatchReturnsError errors

* remove hash indices on type set

* remove hash function for custom role policy

* fix destination tests

* fix feature flag tests

* fix env tests

* fix project tests

* fix segment tests

* fix segment tests and remove unused testAccTagKey function

* revert computed

* define CSA inline

* update changelog

* remove MaxItems property from data sources

* fix forProject

Co-authored-by: Henry Barrow <[email protected]>

* Imiller/ch115576/revert feature flag env optional attributes (#130)

* remove deprecated attribute targeting_enabled (replaced by on)

* on should default to false when removed

* forgot to fix data source tests

* fix test to handle on reversion

* make rules not computed

* make user_targets not computed

* update comments

* finally got fallthrough working

* fix test

* clarify

* fix more tests

* remove deprecated user_targets and flag_fallthrough from schema

* update read

* revert helpers

* update create

* update tests

* update example

* update doc

* remove deprecated fields from keys

* update changelog

* fix fallthrough and fix test

* update changelog

* missed a bit on the docs'

* make prerequisite not computed

* udate changelog again

* add test case for removing prereqs

* update flag_id description for clarity

* add defaults for optional fields

* update test again

* update changelog again

* handle off_variation defaults

* fix data source test

* have to use GetOkExists instead of GetOk to be able to set 0 off_variation on create

* remove commented-out code

* Imiller/ch115576/make fallthrough off variation required (#134)

* make required in schemas

* fix some test configs

* add required attributes to rest of tests. tests all failing

* always set both on read

* no need to check if fallthrough not set because tf will enforce

* update CRU functions

* fix data source tests

* update changelog and docs for new required attributes

* remove comment no longer applicable

* fix typo

* remove `enabled` on webhooks

* removed `policy_statements` on webhooks

* removed `targeting_enabled` on feature flag environment

* update change log

* Change schema function to use recommended one.

* Imiller/ch119139/make env configs required on project resource (#137)

* make required

* delete envs that were previously in state and have been removed

* remove redundant test & add required envs

* ImportSTateVerifyIgnore envs

* update docs

* move full_config example into v1_full_config

* add v2 full config

* update example

* update test project scaffolding function

* change State to StateContext function

* update comment

* fix destination test bug

* add test case for when we fix env defaults

* add note to import about envs

* update changelog

* remove debug bin

* add debug_bin to gitignore

* address pr comments by adding back stuff to docs

* update all example versions to 1.7

* Added logic to delete remote webhook statements when statements block… (#133)

* Added logic to delete remote webhook statements when statements block is removed

* refactored tests

* Added has changes check around the webhook policy statements

* Reverted changes in version file

* Removed check for deprecated policy_statements

* Removed deprecated fields and refactored helper functions using those deprecated fields

* Removed ConflictsWith for the webhook ON schema since ENABLED no longer exists in the schema

* Fixed test cases

* Updated changelog, refactored getWebhookOn and updated the docs

* Updated version in example and added default config for webhook ON element

* Imiller/ch119137/make segment clause negate field optional (#136)

* make oiptional and default to false + update test

* add example segment config for 2.0

* this should be v2.0.0

* Do not require fallthrough and off_variation in ff_env data source (#142)

* added version to versions.tf file for webhook

* v2 for custom_role and destination. Update read me

* Change targets schema to set and add 'variation' attribute (#141)

* Revise targets schema

* update docs

* Make target values required

* Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

* Change List to Set in description

* remove debug_bin

Co-authored-by: Isabelle Miller <[email protected]>

* Imiller/ch115572/restructure default flag variations (#146)

* add new defaults to schema

* update tests to expected configs / outcomes

* add default on

* restructure defaultVariationsFromResourceData

* update test cases

* hitting a non-empty plan error in test

* ffs just needed to be Computed

* update tests

* update docs and changelog

* fix test

* lost a brace

* fix variation helper

* fix changelog

* small doc fixes (#147)

* remove enabled from destination docs

* update webhook doc

* update doc on name issue (#151)

* environment and data_source_webhook examples (#149)

* added more examples

* added comments

* Imiller/ch120560/feature flag maintainer id should be removed (#150)

* make computed and update tes

* update doc

* update changelog

* Imiller/ch119620/audit examples (#152)

* make separate v1 and v2 feature flag examples

* ensure v2 ff example works

* move some stuff around

* some more reorg

* more reorg

* update toc in readme

* update v2 feature flag readme

* Bug Fix: Revert optional env attributes to defaults (#148)

* Fixed and tests passing

* improve env update test

* default_ttl default, and create new test

* default_ttl should reset to 0

* update docs and changelog

Co-authored-by: Isabelle Miller <[email protected]>

* remove test examples shouldn't have been checked in

* add terraform version note to changelog

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>

* Fix import of launchdarkly_project nested environments (#153)

* start importing all environments

* Preserve environment order

* Update changelog

* Add ignore_changes to withRandomProject

* update doc (#154)

* Imiller/sc 119920/add boolean archive attribute to launchdarkly (#155)

* add archived to ff env schema

* make it a global property

* put it in the wrong schema doh

* attempt archive before deleting so we can return an error if there are dependencies

* prelim test

* some syntax issues

* gotta figure out error bit

* remove failing test

* forgot to set archived in read function

* actually no need to archive first

* Update index of docs with recommended version (#156)

* Update index of docs with recommended version

* Show how to configure the access token

* Imiller/sc 123568/add approval settings to environment resource (#157)

* prelim schema

* tweak approval schema

* draft conversion functions

* i forgot you can't use conflictswith with nested attributes

* a mess of things

* fixed up patches

* handle patch remove

* okay i think this should handle all cases

* unused transformation function since no setting

* forgot to handle most obvious case

* need to set but only sometimes

* min num approvals cannot exceed 5

* make min num approvals required

* project test

* fix helper function for project - first pass

* make entire approvals schema computed

* projet tests working

* NOW project tests working

* remove dead code

* update docs

* update changelog

* simplify approval helper function

* switch old and new afunc arguments

* Imiller/sc 126337/make can apply declined changes default to (#158)

* update error message

* change default in schema

* update tests

* update docs'

* update changelog

* clarify rollout weights (#159)

* Upgrade Terraform provider to use api-client-go 7 (#160)

* Start updating go client

* Continue updating resources

* feature flag resource

* feature flag resource test

* approval settings and custom role policies

* destination resource

* environment

* feature flag environment

* project

* segment

* team member

* webhook

* rule, segment rule, segments, and team member helpers

* variations helper

* data source tests

* webhooks helper

* resource tests

* variations helper test

* policy helpers and tests probably will all fail

* custom role and access token probably also broken

* policy statements helper update

* instantiate config prior to setting other values on it

* fix 401

* vendor v7

* update all imports to v7

* missed one

* fix nil pointer dereference

* instantiate with var instead of make to fix non-empty slice bu

* custom roles now complains if you try to set more than one of Role, InlineRole, or CustomRoleIds

* fix webhook statemetns

* webhook read check if statements are nil & webhook create only set secret if defined

* update changelog

* fix webhook data source tests

* new pointers in client FeatureFlagConfig breaking ff env data source tests

* fix negative expiry thing (apparently the api no longer handles it so we have to)

* move reset into helper function

* hackily handle token reset requests until client bug is fixed

* fix variation transformation - can no longer point to empty string

* fix notResource and notActions

* fix policy helper tests

* fix the weird empty string value in variations issue

* strip protocol from host if provided

* go mod tidy && vendor

* update all go packages

* clean up commentsg

* clean up comment

* Ffeldberg/sc 130551/add the ability to adjust the sdks using (#161)

* chore: first attempts

* feat: updating flag resources works, reading/creating plan is a bit iffy

* chore: clean up comments a bit

* chore: add TODO as reminder

* chore: add more todos

* chore: use ConflictsWith to ensure users dont use both includeInSnippet and clientSideAvailablity

* chore: pr feedback - update deprecation message, always read both sdk client values

* feat: set both includeInSnippet and clientSideAvailability to computed properties

* wip: attempt to use computed and update/create logic blocks

* add comment

* use getOk instead of getOkExists for nested, rename vars

* wip: use getOk instead of getOkExists for nested, test modified read

* temp: temporary test changes for local debugging

* chore: add some comments

* feat: working apart from switching back to deprecated option in edge case

* chore: remove commented out code

* fix: fix issue with read

* test: reset tests

* fix: fix typo in read

* fix: account for datasources in featureflag read

* test: add tests for clientSideAvailability changes

* docs: update example docs

* docs: add include_in_snippet to website docs and add deprecation notice

* docs: update docs

* chore: update CHANGELOG

* fix: fix most issues caused by go client v7 merge

* fix: fix other merge issues

* chore: update CHANGELOG

* chore: apply codereview keys suggestions

Co-authored-by: Isabelle Miller <[email protected]>

* chore: Update launchdarkly/feature_flags_helper.go

keys

Co-authored-by: Isabelle Miller <[email protected]>

* chore: update keys.go to reflect clientsideavailablity keys

* chore: go fmt

* test: add tests for switching between CSA and IIS, clean up

* chore: go fmt

* test: remove pure create tests

* chore: add TODOs where required

* test: add new test case for reverting to default CSA

* feat: set clientSideAvailability according to project defaults for flags

* test: update tests accordingly and add comments

* chore: fmt

* refactor project default get into its own function

* test: account for default project CSA settings

* feat: basic working implementation of resetting to defaults using customizeDiff

* feat: attempted changes to customdiff to support CSA

* chore: clean up flag resource read

* chore: clean up comments and todos

* docs: update docs to mention project level defaults for flag sdk settings

* chore: remove prints to clean up test logs

* chore: go mod vendor

* chore: Update CHANGELOG.md

Co-authored-by: Isabelle Miller <[email protected]>

* chore: address pr feedback

* docs: update changelog

Co-authored-by: Isabelle Miller <[email protected]>

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Fabian <[email protected]>

* prepare 2.2.0 release (#75) (#162)

* Update CHANGELOG.md

fix error in changelog

* Imiller/ch117193/rename flag_fallthrough to fallthrough & user_targets to targets (#131)

* add fallthrough and deprecate message to flag_fallthrough

* update doc

* conflicts with

* handle

* update a test

* update changelog

* fix typos in docs

* add targets attribute

* fix linter complaint

* handle in create

* update

* handle read

* update commetn

* update tests

* hack remove user_targets from plan

* set both computed attributes in read

* update changelog

* always set

* simplify helper

* fix data source test

* add test for deprecated field updates

* fix fromResourceData functions

* check renamed on as well

* Update data source d oc

* update data source tests

* Imiller/ch117375/GitHub issue empty string variation (#135)

* should fix it

* add test case

* update changelog and doc

* Fix duplicate text in CHANGELOG.md

Somehow the changelog test was duplicated. Removing, and we can fix the changelog on our next release.

* V2 main (#128)

* destination on should default to false (v2) (#124)

* remove enabled

* test that on defaults to false when removed

* Imiller/ch115579/fix include in snippet bug (#129)

* all it needed was a default val

* add test to ensure optional attributes get set correctly when removed

* fix test

* use TestCheckNoResourceAttr instead of TestCheckResourceAttr

* update changelog

* Imiller/ch113419/upgrade terraform client to v2 (#114)

* run v2 helper

* replace hashcode.String() with schema.HashString()

* replace terraform.ResourceProvider with *schema.Provider

* fix data source TypeMaps

* bump v2 sdk to latest (#116)

* merge

* Remove versions.tf (#119)

* Imiller/ch114162/upgrade resource launchdarkly environment (#121)

* make project_key required

* update descriptions

* update changelog

* Imiller/ch114165/v1 project audit (#120)

* add descriptions

* update doc dscription

* audit team member for v1 (#122)

* update descriptions

* add import instructions to team member docs

* add team member examples

* ForceNew when email is updated

* update test file structure to better reflect provider pattern

* add AtLeastOneOf for role and custom_roles

* oops wrong doc

* use validation.StringInSlice()

* refactor key conversion functions into helper file

* remove owner

* forgot changelog

* Imiller/ch114163/v1 feature flag env (#112)

* add descriptions for everything

* fix dangling default values

* fix bug where creating a non-bool flag with no variations creates a bool flag

* add bug fixes to changelog

* built in an idiotic bug, fixed now

* see if this fixes all of the tests

* found typo:

* fix broken tests

* add descriptions

* update some descriptions for clarity

* make clauses RequiredWith on variations to preempt api error

* fix error in doc

* fix docs properly

* deprecated targeting_enabled in favor of on

* remove ReuqiredWith because it's causing a bug

* fix plan bug

* hopefully this will fix it

* ughhhhh it was that it needed to be computed

* forgot the doc oops

* forgot the changelog too meep

* destination on should default to false (v2) (#124)

* remove enabled

* test that on defaults to false when removed

* Imiller/ch114160/v1 custom role (#125)

* add descriptions

* reformat tests to match pattern

* check removal of optional attributes removes

* holy crap how did this not break earlier

* not sure how that one stuck around either

* somehow we were not actually setting the flag_id

* fix feature flag read

* fix csa on project read

* apparently errors are different too

* remove lingering merge conflict text from changelog

* fix noMatchReturnsError errors

* remove hash indices on type set

* remove hash function for custom role policy

* fix destination tests

* fix feature flag tests

* fix env tests

* fix project tests

* fix segment tests

* fix segment tests and remove unused testAccTagKey function

* revert computed

* define CSA inline

* update changelog

* remove MaxItems property from data sources

* fix forProject

Co-authored-by: Henry Barrow <[email protected]>

* Imiller/ch115576/revert feature flag env optional attributes (#130)

* remove deprecated attribute targeting_enabled (replaced by on)

* on should default to false when removed

* forgot to fix data source tests

* fix test to handle on reversion

* make rules not computed

* make user_targets not computed

* update comments

* finally got fallthrough working

* fix test

* clarify

* fix more tests

* remove deprecated user_targets and flag_fallthrough from schema

* update read

* revert helpers

* update create

* update tests

* update example

* update doc

* remove deprecated fields from keys

* update changelog

* fix fallthrough and fix test

* update changelog

* missed a bit on the docs'

* make prerequisite not computed

* udate changelog again

* add test case for removing prereqs

* update flag_id description for clarity

* add defaults for optional fields

* update test again

* update changelog again

* handle off_variation defaults

* fix data source test

* have to use GetOkExists instead of GetOk to be able to set 0 off_variation on create

* remove commented-out code

* Imiller/ch115576/make fallthrough off variation required (#134)

* make required in schemas

* fix some test configs

* add required attributes to rest of tests. tests all failing

* always set both on read

* no need to check if fallthrough not set because tf will enforce

* update CRU functions

* fix data source tests

* update changelog and docs for new required attributes

* remove comment no longer applicable

* fix typo

* remove `enabled` on webhooks

* removed `policy_statements` on webhooks

* removed `targeting_enabled` on feature flag environment

* update change log

* Change schema function to use recommended one.

* Imiller/ch119139/make env configs required on project resource (#137)

* make required

* delete envs that were previously in state and have been removed

* remove redundant test & add required envs

* ImportSTateVerifyIgnore envs

* update docs

* move full_config example into v1_full_config

* add v2 full config

* update example

* update test project scaffolding function

* change State to StateContext function

* update comment

* fix destination test bug

* add test case for when we fix env defaults

* add note to import about envs

* update changelog

* remove debug bin

* add debug_bin to gitignore

* address pr comments by adding back stuff to docs

* update all example versions to 1.7

* Added logic to delete remote webhook statements when statements block… (#133)

* Added logic to delete remote webhook statements when statements block is removed

* refactored tests

* Added has changes check around the webhook policy statements

* Reverted changes in version file

* Removed check for deprecated policy_statements

* Removed deprecated fields and refactored helper functions using those deprecated fields

* Removed ConflictsWith for the webhook ON schema since ENABLED no longer exists in the schema

* Fixed test cases

* Updated changelog, refactored getWebhookOn and updated the docs

* Updated version in example and added default config for webhook ON element

* Imiller/ch119137/make segment clause negate field optional (#136)

* make oiptional and default to false + update test

* add example segment config for 2.0

* this should be v2.0.0

* Do not require fallthrough and off_variation in ff_env data source (#142)

* added version to versions.tf file for webhook

* v2 for custom_role and destination. Update read me

* Change targets schema to set and add 'variation' attribute (#141)

* Revise targets schema

* update docs

* Make target values required

* Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

* Change List to Set in description

* remove debug_bin

Co-authored-by: Isabelle Miller <[email protected]>

* Imiller/ch115572/restructure default flag variations (#146)

* add new defaults to schema

* update tests to expected configs / outcomes

* add default on

* restructure defaultVariationsFromResourceData

* update test cases

* hitting a non-empty plan error in test

* ffs just needed to be Computed

* update tests

* update docs and changelog

* fix test

* lost a brace

* fix variation helper

* fix changelog

* small doc fixes (#147)

* remove enabled from destination docs

* update webhook doc

* update doc on name issue (#151)

* environment and data_source_webhook examples (#149)

* added more examples

* added comments

* Imiller/ch120560/feature flag maintainer id should be removed (#150)

* make computed and update tes

* update doc

* update changelog

* Imiller/ch119620/audit examples (#152)

* make separate v1 and v2 feature flag examples

* ensure v2 ff example works

* move some stuff around

* some more reorg

* more reorg

* update toc in readme

* update v2 feature flag readme

* Bug Fix: Revert optional env attributes to defaults (#148)

* Fixed and tests passing

* improve env update test

* default_ttl default, and create new test

* default_ttl should reset to 0

* update docs and changelog

Co-authored-by: Isabelle Miller <[email protected]>

* remove test examples shouldn't have been checked in

* add terraform version note to changelog

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>

* Fix import of launchdarkly_project nested environments (#153)

* start importing all environments

* Preserve environment order

* Update changelog

* Add ignore_changes to withRandomProject

* update doc (#154)

* Imiller/sc 119920/add boolean archive attribute to launchdarkly (#155)

* add archived to ff env schema

* make it a global property

* put it in the wrong schema doh

* attempt archive before deleting so we can return an error if there are dependencies

* prelim test

* some syntax issues

* gotta figure out error bit

* remove failing test

* forgot to set archived in read function

* actually no need to archive first

* Update index of docs with recommended version (#156)

* Update index of docs with recommended version

* Show how to configure the access token

* Imiller/sc 123568/add approval settings to environment resource (#157)

* prelim schema

* tweak approval schema

* draft conversion functions

* i forgot you can't use conflictswith with nested attributes

* a mess of things

* fixed up patches

* handle patch remove

* okay i think this should handle all cases

* unused transformation function since no setting

* forgot to handle most obvious case

* need to set but only sometimes

* min num approvals cannot exceed 5

* make min num approvals required

* project test

* fix helper function for project - first pass

* make entire approvals schema computed

* projet tests working

* NOW project tests working

* remove dead code

* update docs

* update changelog

* simplify approval helper function

* switch old and new afunc arguments

* Imiller/sc 126337/make can apply declined changes default to (#158)

* update error message

* change default in schema

* update tests

* update docs'

* update changelog

* clarify rollout weights (#159)

* Upgrade Terraform provider to use api-client-go 7 (#160)

* Start updating go client

* Continue updating resources

* feature flag resource

* feature flag resource test

* approval settings and custom role policies

* destination resource

* environment

* feature flag environment

* project

* segment

* team member

* webhook

* rule, segment rule, segments, and team member helpers

* variations helper

* data source tests

* webhooks helper

* resource tests

* variations helper test

* policy helpers and tests probably will all fail

* custom role and access token probably also broken

* policy statements helper update

* instantiate config prior to setting other values on it

* fix 401

* vendor v7

* update all imports to v7

* missed one

* fix nil pointer dereference

* instantiate with var instead of make to fix non-empty slice bu

* custom roles now complains if you try to set more than one of Role, InlineRole, or CustomRoleIds

* fix webhook statemetns

* webhook read check if statements are nil & webhook create only set secret if defined

* update changelog

* fix webhook data source tests

* new pointers in client FeatureFlagConfig breaking ff env data source tests

* fix negative expiry thing (apparently the api no longer handles it so we have to)

* move reset into helper function

* hackily handle token reset requests until client bug is fixed

* fix variation transformation - can no longer point to empty string

* fix notResource and notActions

* fix policy helper tests

* fix the weird empty string value in variations issue

* strip protocol from host if provided

* go mod tidy && vendor

* update all go packages

* clean up commentsg

* clean up comment

* Ffeldberg/sc 130551/add the ability to adjust the sdks using (#161)

* chore: first attempts

* feat: updating flag resources works, reading/creating plan is a bit iffy

* chore: clean up comments a bit

* chore: add TODO as reminder

* chore: add more todos

* chore: use ConflictsWith to ensure users dont use both includeInSnippet and clientSideAvailablity

* chore: pr feedback - update deprecation message, always read both sdk client values

* feat: set both includeInSnippet and clientSideAvailability to computed properties

* wip: attempt to use computed and update/create logic blocks

* add comment

* use getOk instead of getOkExists for nested, rename vars

* wip: use getOk instead of getOkExists for nested, test modified read

* temp: temporary test changes for local debugging

* chore: add some comments

* feat: working apart from switching back to deprecated option in edge case

* chore: remove commented out code

* fix: fix issue with read

* test: reset tests

* fix: fix typo in read

* fix: account for datasources in featureflag read

* test: add tests for clientSideAvailability changes

* docs: update example docs

* docs: add include_in_snippet to website docs and add deprecation notice

* docs: update docs

* chore: update CHANGELOG

* fix: fix most issues caused by go client v7 merge

* fix: fix other merge issues

* chore: update CHANGELOG

* chore: apply codereview keys suggestions

Co-authored-by: Isabelle Miller <[email protected]>

* chore: Update launchdarkly/feature_flags_helper.go

keys

Co-authored-by: Isabelle Miller <[email protected]>

* chore: update keys.go to reflect clientsideavailablity keys

* chore: go fmt

* test: add tests for switching between CSA and IIS, clean up

* chore: go fmt

* test: remove pure create tests

* chore: add TODOs where required

* test: add new test case for reverting to default CSA

* feat: set clientSideAvailability according to project defaults for flags

* test: update tests accordingly and add comments

* chore: fmt

* refactor project default get into its own function

* test: account for default project CSA settings

* feat: basic working implementation of resetting to defaults using customizeDiff

* feat: attempted changes to customdiff to support CSA

* chore: clean up flag resource read

* chore: clean up comments and todos

* docs: update docs to mention project level defaults for flag sdk settings

* chore: remove prints to clean up test logs

* chore: go mod vendor

* chore: Update CHANGELOG.md

Co-authored-by: Isabelle Miller <[email protected]>

* chore: address pr feedback

* docs: update changelog

Co-authored-by: Isabelle Miller <[email protected]>

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Fabian <[email protected]>

* 2.2.0

Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>

Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>

* [SC-135367] Project resource should support default flag SDK values (#166)

* chore: update project resource schema

* chore: add new keys to keys.go

* feat: most situations working for plan/apply

* feat: use customizeDiff to account for resetting default sdk values 

One slight discrepancy left - switching from using defaultClientSideAvailability to not using the attribute applies the correct changes, but ONLY shows changes to includeInSnippetByDefault in the plan, NOT changes to defaultClientSideAvailability (if applicable)

* test: add tests for project changes

* docs: update docs to reflect changes

* docs: update changelog

* chore: account for changes to project dataSource

* fix: only set include_in_snippet for non data source projects

* chore: make default_csa nested fields required

* chore: deprecate data source attr client_side_availability but maintain support

* docs: update docs and changelog

* docs: update project resource docs according to suggestions

Co-authored-by: Henry Barrow <[email protected]>

* chore: only set datasource deprecated attribute on ds reads

* docs: Apply suggestions from code review

Co-authored-by: Henry Barrow <[email protected]>

Co-authored-by: Henry Barrow <[email protected]>

* Fix nil pointer dereference when reading empty approval settings (#169)

* Fix nil approval settings bug and clean up circleci config.yml

* Update Changelog

* Backmerge v2.3.0 (#170)

* Imiller/sc 136707/streamline tests to use key constants where (#172)

* update data source tests

* add a pre-commit to alphabetize the keys

* resources

* changelog

* Added validation to project key length

* Added rate limit and conflict retry logic to LD client (#171)

* Added rate limit and conflicts retry logic to LD client

* Removed occurences of handleRateLimit and handleConflicts from the codebase since both logic has been replaced by go-retyable

* Used retryable client for the fallbackClient, fixed a header bug in the unit tests and added jitter to sleep value for 429s

Co-authored-by: Henry Barrow <[email protected]>

* Add golangci-lint pre-commit hook and run hooks in CI (#175)

* Ffeldberg/sc 136452/use the context aware version of all crud (#174)

* chore: refactor resource CRUD funcs to be ctx aware

* feat: convert validation helpers to context aware funcs

* feat: convert inline validation to diag aware func

* chore: apply ToDiagFunc wrapper to other custom validators

* fix: TypeList validators cant use ToDiagFunc

* fix: TypeSett validators cant use ToDiagFunc

* add integration resource (#164)

* stub integration resource

* dump json of audit log configs to file

* this should theoretically work

* rename to launchdarkly_audit_log_subscription

* add required to policy options - must be true for audit log subs

* actually never mind i have decided on a better way to deal with it

* set default statements and update tests

* ehhh screw it we're making statements required since the api errors if not passed

* ensure error if config is wrongly set

* clean up comments

* refactor for data source and add tests - not sure why failing

* integration key must be required to get duh

* finally fixed that

* add resource doc

* more docs

* handle casing

* handle bool types

* update data source tests to use examples more likely to break

* small docs update

* update changelog

* forgot to mention data source in changelog

* add to the development doc

* add strcase to go.mod

* use const attributes for tests

* update go client

* forgot to update circle config

* add pre commit to run python script for audit log sub configs

* remove old handleRateLimit functions

* udpate doc

* bug fix

* handle optional defaults

* error if error reading json config file

* use go struct

* make on required

* add examples

* use context-aware functions

* update doc to say on is required

* define optional for data source

* fix host issue

* update doc

* small refactor

* add new line

Co-authored-by: Fabian <[email protected]>

* return diag not nil from delete function

* typo

Co-authored-by: Fabian <[email protected]>

* Add relay proxy config resource (#168)

* [sc 137274] add team members data source (#177)

* chore: refactor getTeamMember to actually query instead of list

* refactor: change teamMember schema to function for reusability and add optional ID

* feat: add new data source and related keys

* test: add tests for new datasource

* docs: add documentation and update changelog

* chore: change query logic to filter members in code

* Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

Co-authored-by: Isabelle Miller <[email protected]>

* add flag triggers resource and data source (#163)

* Start updating go client

* Continue updating resources

* feature flag resource

* feature flag resource test

* approval settings and custom role policies

* destination resource

* environment

* feature flag environment

* project

* segment

* team member

* webhook

* rule, segment rule, segments, and team member helpers

* variations helper

* data source tests

* webhooks helper

* resource tests

* variations helper test

* policy helpers and tests probably will all fail

* custom role and access token probably also broken

* policy statements helper update

* instantiate config prior to setting other values on it

* fix 401

* vendor v7

* update all imports to v7

* missed one

* fix nil pointer dereference

* instantiate with var instead of make to fix non-empty slice bu

* custom roles now complains if you try to set more than one of Role, InlineRole, or CustomRoleIds

* fix webhook statemetns

* webhook read check if statements are nil & webhook create only set secret if defined

* update changelog

* fix webhook data source tests

* new pointers in client FeatureFlagConfig breaking ff env data source tests

* fix negative expiry thing (apparently the api no longer handles it so we have to)

* move reset into helper function

* hackily handle token reset requests until client bug is fixed

* fix variation transformation - can no longer point to empty string

* fix notResource and notActions

* fix policy helper tests

* fix the weird empty string value in variations issue

* strip protocol from host if provided

* go mod tidy && vendor

* update all go packages

* clean up commentsg

* stub resource functions

* stub schema

* define instructions

* theoretical create function

* stub update

* stub helper

* update schema

* refactor schema for data source

* not sure if this is the best way to do IDs or not yet

* trying compound IDs

* set proj env flag keys in read

* theoretically handle enabled

* ehhhh useless helper function

* add test, update instructionsFromResourceData

* feat: add enabled update call in create trigger lifecycle

* test works with fixed client

* set url prior to update

* get update working

* iron out some bugs

* update some descriptions

* add flag exist chec to tests

* data source test

* fix if not found error

* failing test

* handle IDs for data source

* clean up comments

* Resource doc

* finalize docs

* update changelog

* typo in changelog

* use consts for test attributes

* make trigger_url sensiive

* update go client

* update circle config

* mae enabled required

* add notes about enterprise feature and sensitive trigger url data to docs

* fix IDs

* add examples

* make context aware

* forgot to add website links

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Fabian Feldberg <[email protected]>

* typo

* [sc 136319] add launchdarkly metric (#167)

* feat: first draft of metrics Schema and crud function stubs

* chore: adjust read to match existing patterns

* chore: add data source metric scaffolding

* chore: first attempt at custom URLs reader for metrics

* feat: first attempts at create

* feat: first attempt at read

* chore: add new resource and ds to provider

* feat: create and read working (with small issues)

* feat: add delete

* feat: basic update working

* test: add basic create test to metric resource

* test: add basic tests for metric data source

* test: simplify error check

* chore: small steps towards success_criteria

* chore: use customizeDiff to validate multiple dependant attributes

* chore: small comments

* chore: clean up validation of attributes

* docs: add starter for metric resource docs and sidebar links

* docs: update data_source docs

* chore: cleanup comments etc

* feat: validate urls blocks for metrics

* fix: fix typo

* chore: remove logs

* chore: move urls validation helper to helpers, adjust logic for successCriteria on create

* chore: tidy up

* test: use KEYS in tests where possible

* test: update test to check two url values

* chore: Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

* chore: remove periods for consintency

* chore: Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

* chore: error consitency

* docs: update link in docs

* test: add extra test for metric update

* chore: update changelog

* feat: bump api client version and start passing successCriteria on creation

* chore: alphabetise keys.go

* chore: alphabetise keys.go

* test: add metric tests to circleci config

* fix: account for changes to client

* docs: add examples for metrics

* docs: correct URL format in example

* chore: remove ID field from data source, make non key fields optional

* chore: make non key fields optional

* docs: fix changelog after merges

* Update CHANGELOG.md

Co-authored-by: Isabelle Miller <[email protected]>

* Update launchdarkly/metrics_helper.go

Co-authored-by: Isabelle Miller <[email protected]>

* chore: use ToDiagFunc helper

* chore: cleaner diag error return

* test: adjust expected error

Co-authored-by: Isabelle Miller <[email protected]>

* [sc 137802] emails need to be url escaped when querying (#178)

* fix: url escape member emails when querying

* test: update tests to ensure we also use an escapable char (+)

* Ffeldberg/sc 136454/use configurecontextfunc instead of configurefunc (#176)

* feat: make providerConfigure context aware

* fix: fix typo

* WIP: attempt to pass in context to NewClient (breaks everything)

* Revert "WIP: attempt to pass in context to NewClient (breaks everything)"

This reverts commit 09a082042bb0fe3e09db62544683b1a559b804e9.

* Imiller/sc 137617/tf doc improvements (#180)

* specfy location of relay proxy id

* integationKey should be forcenew

* specify force new in docs

* add missing notes about enterprise plans

* Ffeldberg/sc 137794/escalation terraform provider throws error (#179)

* chore: bump go client version

* fix: update to account for new go client version

* todo: add debugging comment

* chore: update policy_statement Schema to use conflictswith

* revert schema changes with conflictswith.. not possible hashicorp/terraform-plugin-sdk#71

* fix: add resources/notresources and actions/notactions as required

* test: add not_resource and not_actions tests

* fix: fix the hashing for pointers in subfields

* fix unit tests and update auditlog config through hook

* Clean up policy statements helper functions (#182)

* Clean up policy statements helper functions

* Fix nil return bug

* Add relay proxy config data source (#183)

Co-authored-by: Isabelle Miller <[email protected]>

Co-authored-by: Isabelle Miller <[email protected]>

* Remove unnecessary attributes from  metric data source test config (#184)

* prepare release

Co-authored-by: Sunny <[email protected]>
Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>
Co-authored-by: Fabian <[email protected]>
Co-authored-by: Clifford Tawiah <[email protected]>
Co-authored-by: Fabian Feldberg <[email protected]>
sloloris added a commit to launchdarkly/terraform-provider-launchdarkly that referenced this issue Jan 19, 2022
* Update CHANGELOG.md

fix error in changelog

* Imiller/ch117193/rename flag_fallthrough to fallthrough & user_targets to targets (#131)

* add fallthrough and deprecate message to flag_fallthrough

* update doc

* conflicts with

* handle

* update a test

* update changelog

* fix typos in docs

* add targets attribute

* fix linter complaint

* handle in create

* update

* handle read

* update commetn

* update tests

* hack remove user_targets from plan

* set both computed attributes in read

* update changelog

* always set

* simplify helper

* fix data source test

* add test for deprecated field updates

* fix fromResourceData functions

* check renamed on as well

* Update data source d oc

* update data source tests

* Imiller/ch117375/GitHub issue empty string variation (#135)

* should fix it

* add test case

* update changelog and doc

* Fix duplicate text in CHANGELOG.md

Somehow the changelog test was duplicated. Removing, and we can fix the changelog on our next release.

* V2 main (#128)

* destination on should default to false (v2) (#124)

* remove enabled

* test that on defaults to false when removed

* Imiller/ch115579/fix include in snippet bug (#129)

* all it needed was a default val

* add test to ensure optional attributes get set correctly when removed

* fix test

* use TestCheckNoResourceAttr instead of TestCheckResourceAttr

* update changelog

* Imiller/ch113419/upgrade terraform client to v2 (#114)

* run v2 helper

* replace hashcode.String() with schema.HashString()

* replace terraform.ResourceProvider with *schema.Provider

* fix data source TypeMaps

* bump v2 sdk to latest (#116)

* merge

* Remove versions.tf (#119)

* Imiller/ch114162/upgrade resource launchdarkly environment (#121)

* make project_key required

* update descriptions

* update changelog

* Imiller/ch114165/v1 project audit (#120)

* add descriptions

* update doc dscription

* audit team member for v1 (#122)

* update descriptions

* add import instructions to team member docs

* add team member examples

* ForceNew when email is updated

* update test file structure to better reflect provider pattern

* add AtLeastOneOf for role and custom_roles

* oops wrong doc

* use validation.StringInSlice()

* refactor key conversion functions into helper file

* remove owner

* forgot changelog

* Imiller/ch114163/v1 feature flag env (#112)

* add descriptions for everything

* fix dangling default values

* fix bug where creating a non-bool flag with no variations creates a bool flag

* add bug fixes to changelog

* built in an idiotic bug, fixed now

* see if this fixes all of the tests

* found typo:

* fix broken tests

* add descriptions

* update some descriptions for clarity

* make clauses RequiredWith on variations to preempt api error

* fix error in doc

* fix docs properly

* deprecated targeting_enabled in favor of on

* remove ReuqiredWith because it's causing a bug

* fix plan bug

* hopefully this will fix it

* ughhhhh it was that it needed to be computed

* forgot the doc oops

* forgot the changelog too meep

* destination on should default to false (v2) (#124)

* remove enabled

* test that on defaults to false when removed

* Imiller/ch114160/v1 custom role (#125)

* add descriptions

* reformat tests to match pattern

* check removal of optional attributes removes

* holy crap how did this not break earlier

* not sure how that one stuck around either

* somehow we were not actually setting the flag_id

* fix feature flag read

* fix csa on project read

* apparently errors are different too

* remove lingering merge conflict text from changelog

* fix noMatchReturnsError errors

* remove hash indices on type set

* remove hash function for custom role policy

* fix destination tests

* fix feature flag tests

* fix env tests

* fix project tests

* fix segment tests

* fix segment tests and remove unused testAccTagKey function

* revert computed

* define CSA inline

* update changelog

* remove MaxItems property from data sources

* fix forProject

Co-authored-by: Henry Barrow <[email protected]>

* Imiller/ch115576/revert feature flag env optional attributes (#130)

* remove deprecated attribute targeting_enabled (replaced by on)

* on should default to false when removed

* forgot to fix data source tests

* fix test to handle on reversion

* make rules not computed

* make user_targets not computed

* update comments

* finally got fallthrough working

* fix test

* clarify

* fix more tests

* remove deprecated user_targets and flag_fallthrough from schema

* update read

* revert helpers

* update create

* update tests

* update example

* update doc

* remove deprecated fields from keys

* update changelog

* fix fallthrough and fix test

* update changelog

* missed a bit on the docs'

* make prerequisite not computed

* udate changelog again

* add test case for removing prereqs

* update flag_id description for clarity

* add defaults for optional fields

* update test again

* update changelog again

* handle off_variation defaults

* fix data source test

* have to use GetOkExists instead of GetOk to be able to set 0 off_variation on create

* remove commented-out code

* Imiller/ch115576/make fallthrough off variation required (#134)

* make required in schemas

* fix some test configs

* add required attributes to rest of tests. tests all failing

* always set both on read

* no need to check if fallthrough not set because tf will enforce

* update CRU functions

* fix data source tests

* update changelog and docs for new required attributes

* remove comment no longer applicable

* fix typo

* remove `enabled` on webhooks

* removed `policy_statements` on webhooks

* removed `targeting_enabled` on feature flag environment

* update change log

* Change schema function to use recommended one.

* Imiller/ch119139/make env configs required on project resource (#137)

* make required

* delete envs that were previously in state and have been removed

* remove redundant test & add required envs

* ImportSTateVerifyIgnore envs

* update docs

* move full_config example into v1_full_config

* add v2 full config

* update example

* update test project scaffolding function

* change State to StateContext function

* update comment

* fix destination test bug

* add test case for when we fix env defaults

* add note to import about envs

* update changelog

* remove debug bin

* add debug_bin to gitignore

* address pr comments by adding back stuff to docs

* update all example versions to 1.7

* Added logic to delete remote webhook statements when statements block… (#133)

* Added logic to delete remote webhook statements when statements block is removed

* refactored tests

* Added has changes check around the webhook policy statements

* Reverted changes in version file

* Removed check for deprecated policy_statements

* Removed deprecated fields and refactored helper functions using those deprecated fields

* Removed ConflictsWith for the webhook ON schema since ENABLED no longer exists in the schema

* Fixed test cases

* Updated changelog, refactored getWebhookOn and updated the docs

* Updated version in example and added default config for webhook ON element

* Imiller/ch119137/make segment clause negate field optional (#136)

* make oiptional and default to false + update test

* add example segment config for 2.0

* this should be v2.0.0

* Do not require fallthrough and off_variation in ff_env data source (#142)

* added version to versions.tf file for webhook

* v2 for custom_role and destination. Update read me

* Change targets schema to set and add 'variation' attribute (#141)

* Revise targets schema

* update docs

* Make target values required

* Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

* Change List to Set in description

* remove debug_bin

Co-authored-by: Isabelle Miller <[email protected]>

* Imiller/ch115572/restructure default flag variations (#146)

* add new defaults to schema

* update tests to expected configs / outcomes

* add default on

* restructure defaultVariationsFromResourceData

* update test cases

* hitting a non-empty plan error in test

* ffs just needed to be Computed

* update tests

* update docs and changelog

* fix test

* lost a brace

* fix variation helper

* fix changelog

* small doc fixes (#147)

* remove enabled from destination docs

* update webhook doc

* update doc on name issue (#151)

* environment and data_source_webhook examples (#149)

* added more examples

* added comments

* Imiller/ch120560/feature flag maintainer id should be removed (#150)

* make computed and update tes

* update doc

* update changelog

* Imiller/ch119620/audit examples (#152)

* make separate v1 and v2 feature flag examples

* ensure v2 ff example works

* move some stuff around

* some more reorg

* more reorg

* update toc in readme

* update v2 feature flag readme

* Bug Fix: Revert optional env attributes to defaults (#148)

* Fixed and tests passing

* improve env update test

* default_ttl default, and create new test

* default_ttl should reset to 0

* update docs and changelog

Co-authored-by: Isabelle Miller <[email protected]>

* remove test examples shouldn't have been checked in

* add terraform version note to changelog

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>

* Fix import of launchdarkly_project nested environments (#153)

* start importing all environments

* Preserve environment order

* Update changelog

* Add ignore_changes to withRandomProject

* update doc (#154)

* Imiller/sc 119920/add boolean archive attribute to launchdarkly (#155)

* add archived to ff env schema

* make it a global property

* put it in the wrong schema doh

* attempt archive before deleting so we can return an error if there are dependencies

* prelim test

* some syntax issues

* gotta figure out error bit

* remove failing test

* forgot to set archived in read function

* actually no need to archive first

* Update index of docs with recommended version (#156)

* Update index of docs with recommended version

* Show how to configure the access token

* Imiller/sc 123568/add approval settings to environment resource (#157)

* prelim schema

* tweak approval schema

* draft conversion functions

* i forgot you can't use conflictswith with nested attributes

* a mess of things

* fixed up patches

* handle patch remove

* okay i think this should handle all cases

* unused transformation function since no setting

* forgot to handle most obvious case

* need to set but only sometimes

* min num approvals cannot exceed 5

* make min num approvals required

* project test

* fix helper function for project - first pass

* make entire approvals schema computed

* projet tests working

* NOW project tests working

* remove dead code

* update docs

* update changelog

* simplify approval helper function

* switch old and new afunc arguments

* Imiller/sc 126337/make can apply declined changes default to (#158)

* update error message

* change default in schema

* update tests

* update docs'

* update changelog

* clarify rollout weights (#159)

* Upgrade Terraform provider to use api-client-go 7 (#160)

* Start updating go client

* Continue updating resources

* feature flag resource

* feature flag resource test

* approval settings and custom role policies

* destination resource

* environment

* feature flag environment

* project

* segment

* team member

* webhook

* rule, segment rule, segments, and team member helpers

* variations helper

* data source tests

* webhooks helper

* resource tests

* variations helper test

* policy helpers and tests probably will all fail

* custom role and access token probably also broken

* policy statements helper update

* instantiate config prior to setting other values on it

* fix 401

* vendor v7

* update all imports to v7

* missed one

* fix nil pointer dereference

* instantiate with var instead of make to fix non-empty slice bu

* custom roles now complains if you try to set more than one of Role, InlineRole, or CustomRoleIds

* fix webhook statemetns

* webhook read check if statements are nil & webhook create only set secret if defined

* update changelog

* fix webhook data source tests

* new pointers in client FeatureFlagConfig breaking ff env data source tests

* fix negative expiry thing (apparently the api no longer handles it so we have to)

* move reset into helper function

* hackily handle token reset requests until client bug is fixed

* fix variation transformation - can no longer point to empty string

* fix notResource and notActions

* fix policy helper tests

* fix the weird empty string value in variations issue

* strip protocol from host if provided

* go mod tidy && vendor

* update all go packages

* clean up commentsg

* clean up comment

* Ffeldberg/sc 130551/add the ability to adjust the sdks using (#161)

* chore: first attempts

* feat: updating flag resources works, reading/creating plan is a bit iffy

* chore: clean up comments a bit

* chore: add TODO as reminder

* chore: add more todos

* chore: use ConflictsWith to ensure users dont use both includeInSnippet and clientSideAvailablity

* chore: pr feedback - update deprecation message, always read both sdk client values

* feat: set both includeInSnippet and clientSideAvailability to computed properties

* wip: attempt to use computed and update/create logic blocks

* add comment

* use getOk instead of getOkExists for nested, rename vars

* wip: use getOk instead of getOkExists for nested, test modified read

* temp: temporary test changes for local debugging

* chore: add some comments

* feat: working apart from switching back to deprecated option in edge case

* chore: remove commented out code

* fix: fix issue with read

* test: reset tests

* fix: fix typo in read

* fix: account for datasources in featureflag read

* test: add tests for clientSideAvailability changes

* docs: update example docs

* docs: add include_in_snippet to website docs and add deprecation notice

* docs: update docs

* chore: update CHANGELOG

* fix: fix most issues caused by go client v7 merge

* fix: fix other merge issues

* chore: update CHANGELOG

* chore: apply codereview keys suggestions

Co-authored-by: Isabelle Miller <[email protected]>

* chore: Update launchdarkly/feature_flags_helper.go

keys

Co-authored-by: Isabelle Miller <[email protected]>

* chore: update keys.go to reflect clientsideavailablity keys

* chore: go fmt

* test: add tests for switching between CSA and IIS, clean up

* chore: go fmt

* test: remove pure create tests

* chore: add TODOs where required

* test: add new test case for reverting to default CSA

* feat: set clientSideAvailability according to project defaults for flags

* test: update tests accordingly and add comments

* chore: fmt

* refactor project default get into its own function

* test: account for default project CSA settings

* feat: basic working implementation of resetting to defaults using customizeDiff

* feat: attempted changes to customdiff to support CSA

* chore: clean up flag resource read

* chore: clean up comments and todos

* docs: update docs to mention project level defaults for flag sdk settings

* chore: remove prints to clean up test logs

* chore: go mod vendor

* chore: Update CHANGELOG.md

Co-authored-by: Isabelle Miller <[email protected]>

* chore: address pr feedback

* docs: update changelog

Co-authored-by: Isabelle Miller <[email protected]>

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Fabian <[email protected]>

* prepare 2.2.0 release (#75) (#162)

* Update CHANGELOG.md

fix error in changelog

* Imiller/ch117193/rename flag_fallthrough to fallthrough & user_targets to targets (#131)

* add fallthrough and deprecate message to flag_fallthrough

* update doc

* conflicts with

* handle

* update a test

* update changelog

* fix typos in docs

* add targets attribute

* fix linter complaint

* handle in create

* update

* handle read

* update commetn

* update tests

* hack remove user_targets from plan

* set both computed attributes in read

* update changelog

* always set

* simplify helper

* fix data source test

* add test for deprecated field updates

* fix fromResourceData functions

* check renamed on as well

* Update data source d oc

* update data source tests

* Imiller/ch117375/GitHub issue empty string variation (#135)

* should fix it

* add test case

* update changelog and doc

* Fix duplicate text in CHANGELOG.md

Somehow the changelog test was duplicated. Removing, and we can fix the changelog on our next release.

* V2 main (#128)

* destination on should default to false (v2) (#124)

* remove enabled

* test that on defaults to false when removed

* Imiller/ch115579/fix include in snippet bug (#129)

* all it needed was a default val

* add test to ensure optional attributes get set correctly when removed

* fix test

* use TestCheckNoResourceAttr instead of TestCheckResourceAttr

* update changelog

* Imiller/ch113419/upgrade terraform client to v2 (#114)

* run v2 helper

* replace hashcode.String() with schema.HashString()

* replace terraform.ResourceProvider with *schema.Provider

* fix data source TypeMaps

* bump v2 sdk to latest (#116)

* merge

* Remove versions.tf (#119)

* Imiller/ch114162/upgrade resource launchdarkly environment (#121)

* make project_key required

* update descriptions

* update changelog

* Imiller/ch114165/v1 project audit (#120)

* add descriptions

* update doc dscription

* audit team member for v1 (#122)

* update descriptions

* add import instructions to team member docs

* add team member examples

* ForceNew when email is updated

* update test file structure to better reflect provider pattern

* add AtLeastOneOf for role and custom_roles

* oops wrong doc

* use validation.StringInSlice()

* refactor key conversion functions into helper file

* remove owner

* forgot changelog

* Imiller/ch114163/v1 feature flag env (#112)

* add descriptions for everything

* fix dangling default values

* fix bug where creating a non-bool flag with no variations creates a bool flag

* add bug fixes to changelog

* built in an idiotic bug, fixed now

* see if this fixes all of the tests

* found typo:

* fix broken tests

* add descriptions

* update some descriptions for clarity

* make clauses RequiredWith on variations to preempt api error

* fix error in doc

* fix docs properly

* deprecated targeting_enabled in favor of on

* remove ReuqiredWith because it's causing a bug

* fix plan bug

* hopefully this will fix it

* ughhhhh it was that it needed to be computed

* forgot the doc oops

* forgot the changelog too meep

* destination on should default to false (v2) (#124)

* remove enabled

* test that on defaults to false when removed

* Imiller/ch114160/v1 custom role (#125)

* add descriptions

* reformat tests to match pattern

* check removal of optional attributes removes

* holy crap how did this not break earlier

* not sure how that one stuck around either

* somehow we were not actually setting the flag_id

* fix feature flag read

* fix csa on project read

* apparently errors are different too

* remove lingering merge conflict text from changelog

* fix noMatchReturnsError errors

* remove hash indices on type set

* remove hash function for custom role policy

* fix destination tests

* fix feature flag tests

* fix env tests

* fix project tests

* fix segment tests

* fix segment tests and remove unused testAccTagKey function

* revert computed

* define CSA inline

* update changelog

* remove MaxItems property from data sources

* fix forProject

Co-authored-by: Henry Barrow <[email protected]>

* Imiller/ch115576/revert feature flag env optional attributes (#130)

* remove deprecated attribute targeting_enabled (replaced by on)

* on should default to false when removed

* forgot to fix data source tests

* fix test to handle on reversion

* make rules not computed

* make user_targets not computed

* update comments

* finally got fallthrough working

* fix test

* clarify

* fix more tests

* remove deprecated user_targets and flag_fallthrough from schema

* update read

* revert helpers

* update create

* update tests

* update example

* update doc

* remove deprecated fields from keys

* update changelog

* fix fallthrough and fix test

* update changelog

* missed a bit on the docs'

* make prerequisite not computed

* udate changelog again

* add test case for removing prereqs

* update flag_id description for clarity

* add defaults for optional fields

* update test again

* update changelog again

* handle off_variation defaults

* fix data source test

* have to use GetOkExists instead of GetOk to be able to set 0 off_variation on create

* remove commented-out code

* Imiller/ch115576/make fallthrough off variation required (#134)

* make required in schemas

* fix some test configs

* add required attributes to rest of tests. tests all failing

* always set both on read

* no need to check if fallthrough not set because tf will enforce

* update CRU functions

* fix data source tests

* update changelog and docs for new required attributes

* remove comment no longer applicable

* fix typo

* remove `enabled` on webhooks

* removed `policy_statements` on webhooks

* removed `targeting_enabled` on feature flag environment

* update change log

* Change schema function to use recommended one.

* Imiller/ch119139/make env configs required on project resource (#137)

* make required

* delete envs that were previously in state and have been removed

* remove redundant test & add required envs

* ImportSTateVerifyIgnore envs

* update docs

* move full_config example into v1_full_config

* add v2 full config

* update example

* update test project scaffolding function

* change State to StateContext function

* update comment

* fix destination test bug

* add test case for when we fix env defaults

* add note to import about envs

* update changelog

* remove debug bin

* add debug_bin to gitignore

* address pr comments by adding back stuff to docs

* update all example versions to 1.7

* Added logic to delete remote webhook statements when statements block… (#133)

* Added logic to delete remote webhook statements when statements block is removed

* refactored tests

* Added has changes check around the webhook policy statements

* Reverted changes in version file

* Removed check for deprecated policy_statements

* Removed deprecated fields and refactored helper functions using those deprecated fields

* Removed ConflictsWith for the webhook ON schema since ENABLED no longer exists in the schema

* Fixed test cases

* Updated changelog, refactored getWebhookOn and updated the docs

* Updated version in example and added default config for webhook ON element

* Imiller/ch119137/make segment clause negate field optional (#136)

* make oiptional and default to false + update test

* add example segment config for 2.0

* this should be v2.0.0

* Do not require fallthrough and off_variation in ff_env data source (#142)

* added version to versions.tf file for webhook

* v2 for custom_role and destination. Update read me

* Change targets schema to set and add 'variation' attribute (#141)

* Revise targets schema

* update docs

* Make target values required

* Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

* Change List to Set in description

* remove debug_bin

Co-authored-by: Isabelle Miller <[email protected]>

* Imiller/ch115572/restructure default flag variations (#146)

* add new defaults to schema

* update tests to expected configs / outcomes

* add default on

* restructure defaultVariationsFromResourceData

* update test cases

* hitting a non-empty plan error in test

* ffs just needed to be Computed

* update tests

* update docs and changelog

* fix test

* lost a brace

* fix variation helper

* fix changelog

* small doc fixes (#147)

* remove enabled from destination docs

* update webhook doc

* update doc on name issue (#151)

* environment and data_source_webhook examples (#149)

* added more examples

* added comments

* Imiller/ch120560/feature flag maintainer id should be removed (#150)

* make computed and update tes

* update doc

* update changelog

* Imiller/ch119620/audit examples (#152)

* make separate v1 and v2 feature flag examples

* ensure v2 ff example works

* move some stuff around

* some more reorg

* more reorg

* update toc in readme

* update v2 feature flag readme

* Bug Fix: Revert optional env attributes to defaults (#148)

* Fixed and tests passing

* improve env update test

* default_ttl default, and create new test

* default_ttl should reset to 0

* update docs and changelog

Co-authored-by: Isabelle Miller <[email protected]>

* remove test examples shouldn't have been checked in

* add terraform version note to changelog

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>

* Fix import of launchdarkly_project nested environments (#153)

* start importing all environments

* Preserve environment order

* Update changelog

* Add ignore_changes to withRandomProject

* update doc (#154)

* Imiller/sc 119920/add boolean archive attribute to launchdarkly (#155)

* add archived to ff env schema

* make it a global property

* put it in the wrong schema doh

* attempt archive before deleting so we can return an error if there are dependencies

* prelim test

* some syntax issues

* gotta figure out error bit

* remove failing test

* forgot to set archived in read function

* actually no need to archive first

* Update index of docs with recommended version (#156)

* Update index of docs with recommended version

* Show how to configure the access token

* Imiller/sc 123568/add approval settings to environment resource (#157)

* prelim schema

* tweak approval schema

* draft conversion functions

* i forgot you can't use conflictswith with nested attributes

* a mess of things

* fixed up patches

* handle patch remove

* okay i think this should handle all cases

* unused transformation function since no setting

* forgot to handle most obvious case

* need to set but only sometimes

* min num approvals cannot exceed 5

* make min num approvals required

* project test

* fix helper function for project - first pass

* make entire approvals schema computed

* projet tests working

* NOW project tests working

* remove dead code

* update docs

* update changelog

* simplify approval helper function

* switch old and new afunc arguments

* Imiller/sc 126337/make can apply declined changes default to (#158)

* update error message

* change default in schema

* update tests

* update docs'

* update changelog

* clarify rollout weights (#159)

* Upgrade Terraform provider to use api-client-go 7 (#160)

* Start updating go client

* Continue updating resources

* feature flag resource

* feature flag resource test

* approval settings and custom role policies

* destination resource

* environment

* feature flag environment

* project

* segment

* team member

* webhook

* rule, segment rule, segments, and team member helpers

* variations helper

* data source tests

* webhooks helper

* resource tests

* variations helper test

* policy helpers and tests probably will all fail

* custom role and access token probably also broken

* policy statements helper update

* instantiate config prior to setting other values on it

* fix 401

* vendor v7

* update all imports to v7

* missed one

* fix nil pointer dereference

* instantiate with var instead of make to fix non-empty slice bu

* custom roles now complains if you try to set more than one of Role, InlineRole, or CustomRoleIds

* fix webhook statemetns

* webhook read check if statements are nil & webhook create only set secret if defined

* update changelog

* fix webhook data source tests

* new pointers in client FeatureFlagConfig breaking ff env data source tests

* fix negative expiry thing (apparently the api no longer handles it so we have to)

* move reset into helper function

* hackily handle token reset requests until client bug is fixed

* fix variation transformation - can no longer point to empty string

* fix notResource and notActions

* fix policy helper tests

* fix the weird empty string value in variations issue

* strip protocol from host if provided

* go mod tidy && vendor

* update all go packages

* clean up commentsg

* clean up comment

* Ffeldberg/sc 130551/add the ability to adjust the sdks using (#161)

* chore: first attempts

* feat: updating flag resources works, reading/creating plan is a bit iffy

* chore: clean up comments a bit

* chore: add TODO as reminder

* chore: add more todos

* chore: use ConflictsWith to ensure users dont use both includeInSnippet and clientSideAvailablity

* chore: pr feedback - update deprecation message, always read both sdk client values

* feat: set both includeInSnippet and clientSideAvailability to computed properties

* wip: attempt to use computed and update/create logic blocks

* add comment

* use getOk instead of getOkExists for nested, rename vars

* wip: use getOk instead of getOkExists for nested, test modified read

* temp: temporary test changes for local debugging

* chore: add some comments

* feat: working apart from switching back to deprecated option in edge case

* chore: remove commented out code

* fix: fix issue with read

* test: reset tests

* fix: fix typo in read

* fix: account for datasources in featureflag read

* test: add tests for clientSideAvailability changes

* docs: update example docs

* docs: add include_in_snippet to website docs and add deprecation notice

* docs: update docs

* chore: update CHANGELOG

* fix: fix most issues caused by go client v7 merge

* fix: fix other merge issues

* chore: update CHANGELOG

* chore: apply codereview keys suggestions

Co-authored-by: Isabelle Miller <[email protected]>

* chore: Update launchdarkly/feature_flags_helper.go

keys

Co-authored-by: Isabelle Miller <[email protected]>

* chore: update keys.go to reflect clientsideavailablity keys

* chore: go fmt

* test: add tests for switching between CSA and IIS, clean up

* chore: go fmt

* test: remove pure create tests

* chore: add TODOs where required

* test: add new test case for reverting to default CSA

* feat: set clientSideAvailability according to project defaults for flags

* test: update tests accordingly and add comments

* chore: fmt

* refactor project default get into its own function

* test: account for default project CSA settings

* feat: basic working implementation of resetting to defaults using customizeDiff

* feat: attempted changes to customdiff to support CSA

* chore: clean up flag resource read

* chore: clean up comments and todos

* docs: update docs to mention project level defaults for flag sdk settings

* chore: remove prints to clean up test logs

* chore: go mod vendor

* chore: Update CHANGELOG.md

Co-authored-by: Isabelle Miller <[email protected]>

* chore: address pr feedback

* docs: update changelog

Co-authored-by: Isabelle Miller <[email protected]>

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Fabian <[email protected]>

* 2.2.0

Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>

Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>

* [SC-135367] Project resource should support default flag SDK values (#166)

* chore: update project resource schema

* chore: add new keys to keys.go

* feat: most situations working for plan/apply

* feat: use customizeDiff to account for resetting default sdk values 

One slight discrepancy left - switching from using defaultClientSideAvailability to not using the attribute applies the correct changes, but ONLY shows changes to includeInSnippetByDefault in the plan, NOT changes to defaultClientSideAvailability (if applicable)

* test: add tests for project changes

* docs: update docs to reflect changes

* docs: update changelog

* chore: account for changes to project dataSource

* fix: only set include_in_snippet for non data source projects

* chore: make default_csa nested fields required

* chore: deprecate data source attr client_side_availability but maintain support

* docs: update docs and changelog

* docs: update project resource docs according to suggestions

Co-authored-by: Henry Barrow <[email protected]>

* chore: only set datasource deprecated attribute on ds reads

* docs: Apply suggestions from code review

Co-authored-by: Henry Barrow <[email protected]>

Co-authored-by: Henry Barrow <[email protected]>

* Fix nil pointer dereference when reading empty approval settings (#169)

* Fix nil approval settings bug and clean up circleci config.yml

* Update Changelog

* Backmerge v2.3.0 (#170)

* Imiller/sc 136707/streamline tests to use key constants where (#172)

* update data source tests

* add a pre-commit to alphabetize the keys

* resources

* changelog

* Added validation to project key length

* Added rate limit and conflict retry logic to LD client (#171)

* Added rate limit and conflicts retry logic to LD client

* Removed occurences of handleRateLimit and handleConflicts from the codebase since both logic has been replaced by go-retyable

* Used retryable client for the fallbackClient, fixed a header bug in the unit tests and added jitter to sleep value for 429s

Co-authored-by: Henry Barrow <[email protected]>

* Add golangci-lint pre-commit hook and run hooks in CI (#175)

* Ffeldberg/sc 136452/use the context aware version of all crud (#174)

* chore: refactor resource CRUD funcs to be ctx aware

* feat: convert validation helpers to context aware funcs

* feat: convert inline validation to diag aware func

* chore: apply ToDiagFunc wrapper to other custom validators

* fix: TypeList validators cant use ToDiagFunc

* fix: TypeSett validators cant use ToDiagFunc

* add integration resource (#164)

* stub integration resource

* dump json of audit log configs to file

* this should theoretically work

* rename to launchdarkly_audit_log_subscription

* add required to policy options - must be true for audit log subs

* actually never mind i have decided on a better way to deal with it

* set default statements and update tests

* ehhh screw it we're making statements required since the api errors if not passed

* ensure error if config is wrongly set

* clean up comments

* refactor for data source and add tests - not sure why failing

* integration key must be required to get duh

* finally fixed that

* add resource doc

* more docs

* handle casing

* handle bool types

* update data source tests to use examples more likely to break

* small docs update

* update changelog

* forgot to mention data source in changelog

* add to the development doc

* add strcase to go.mod

* use const attributes for tests

* update go client

* forgot to update circle config

* add pre commit to run python script for audit log sub configs

* remove old handleRateLimit functions

* udpate doc

* bug fix

* handle optional defaults

* error if error reading json config file

* use go struct

* make on required

* add examples

* use context-aware functions

* update doc to say on is required

* define optional for data source

* fix host issue

* update doc

* small refactor

* add new line

Co-authored-by: Fabian <[email protected]>

* return diag not nil from delete function

* typo

Co-authored-by: Fabian <[email protected]>

* Add relay proxy config resource (#168)

* [sc 137274] add team members data source (#177)

* chore: refactor getTeamMember to actually query instead of list

* refactor: change teamMember schema to function for reusability and add optional ID

* feat: add new data source and related keys

* test: add tests for new datasource

* docs: add documentation and update changelog

* chore: change query logic to filter members in code

* Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

Co-authored-by: Isabelle Miller <[email protected]>

* add flag triggers resource and data source (#163)

* Start updating go client

* Continue updating resources

* feature flag resource

* feature flag resource test

* approval settings and custom role policies

* destination resource

* environment

* feature flag environment

* project

* segment

* team member

* webhook

* rule, segment rule, segments, and team member helpers

* variations helper

* data source tests

* webhooks helper

* resource tests

* variations helper test

* policy helpers and tests probably will all fail

* custom role and access token probably also broken

* policy statements helper update

* instantiate config prior to setting other values on it

* fix 401

* vendor v7

* update all imports to v7

* missed one

* fix nil pointer dereference

* instantiate with var instead of make to fix non-empty slice bu

* custom roles now complains if you try to set more than one of Role, InlineRole, or CustomRoleIds

* fix webhook statemetns

* webhook read check if statements are nil & webhook create only set secret if defined

* update changelog

* fix webhook data source tests

* new pointers in client FeatureFlagConfig breaking ff env data source tests

* fix negative expiry thing (apparently the api no longer handles it so we have to)

* move reset into helper function

* hackily handle token reset requests until client bug is fixed

* fix variation transformation - can no longer point to empty string

* fix notResource and notActions

* fix policy helper tests

* fix the weird empty string value in variations issue

* strip protocol from host if provided

* go mod tidy && vendor

* update all go packages

* clean up commentsg

* stub resource functions

* stub schema

* define instructions

* theoretical create function

* stub update

* stub helper

* update schema

* refactor schema for data source

* not sure if this is the best way to do IDs or not yet

* trying compound IDs

* set proj env flag keys in read

* theoretically handle enabled

* ehhhh useless helper function

* add test, update instructionsFromResourceData

* feat: add enabled update call in create trigger lifecycle

* test works with fixed client

* set url prior to update

* get update working

* iron out some bugs

* update some descriptions

* add flag exist chec to tests

* data source test

* fix if not found error

* failing test

* handle IDs for data source

* clean up comments

* Resource doc

* finalize docs

* update changelog

* typo in changelog

* use consts for test attributes

* make trigger_url sensiive

* update go client

* update circle config

* mae enabled required

* add notes about enterprise feature and sensitive trigger url data to docs

* fix IDs

* add examples

* make context aware

* forgot to add website links

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Fabian Feldberg <[email protected]>

* typo

* [sc 136319] add launchdarkly metric (#167)

* feat: first draft of metrics Schema and crud function stubs

* chore: adjust read to match existing patterns

* chore: add data source metric scaffolding

* chore: first attempt at custom URLs reader for metrics

* feat: first attempts at create

* feat: first attempt at read

* chore: add new resource and ds to provider

* feat: create and read working (with small issues)

* feat: add delete

* feat: basic update working

* test: add basic create test to metric resource

* test: add basic tests for metric data source

* test: simplify error check

* chore: small steps towards success_criteria

* chore: use customizeDiff to validate multiple dependant attributes

* chore: small comments

* chore: clean up validation of attributes

* docs: add starter for metric resource docs and sidebar links

* docs: update data_source docs

* chore: cleanup comments etc

* feat: validate urls blocks for metrics

* fix: fix typo

* chore: remove logs

* chore: move urls validation helper to helpers, adjust logic for successCriteria on create

* chore: tidy up

* test: use KEYS in tests where possible

* test: update test to check two url values

* chore: Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

* chore: remove periods for consintency

* chore: Apply suggestions from code review

Co-authored-by: Isabelle Miller <[email protected]>

* chore: error consitency

* docs: update link in docs

* test: add extra test for metric update

* chore: update changelog

* feat: bump api client version and start passing successCriteria on creation

* chore: alphabetise keys.go

* chore: alphabetise keys.go

* test: add metric tests to circleci config

* fix: account for changes to client

* docs: add examples for metrics

* docs: correct URL format in example

* chore: remove ID field from data source, make non key fields optional

* chore: make non key fields optional

* docs: fix changelog after merges

* Update CHANGELOG.md

Co-authored-by: Isabelle Miller <[email protected]>

* Update launchdarkly/metrics_helper.go

Co-authored-by: Isabelle Miller <[email protected]>

* chore: use ToDiagFunc helper

* chore: cleaner diag error return

* test: adjust expected error

Co-authored-by: Isabelle Miller <[email protected]>

* [sc 137802] emails need to be url escaped when querying (#178)

* fix: url escape member emails when querying

* test: update tests to ensure we also use an escapable char (+)

* Ffeldberg/sc 136454/use configurecontextfunc instead of configurefunc (#176)

* feat: make providerConfigure context aware

* fix: fix typo

* WIP: attempt to pass in context to NewClient (breaks everything)

* Revert "WIP: attempt to pass in context to NewClient (breaks everything)"

This reverts commit 09a082042bb0fe3e09db62544683b1a559b804e9.

* Imiller/sc 137617/tf doc improvements (#180)

* specfy location of relay proxy id

* integationKey should be forcenew

* specify force new in docs

* add missing notes about enterprise plans

* Ffeldberg/sc 137794/escalation terraform provider throws error (#179)

* chore: bump go client version

* fix: update to account for new go client version

* todo: add debugging comment

* chore: update policy_statement Schema to use conflictswith

* revert schema changes with conflictswith.. not possible hashicorp/terraform-plugin-sdk#71

* fix: add resources/notresources and actions/notactions as required

* test: add not_resource and not_actions tests

* fix: fix the hashing for pointers in subfields

* fix unit tests and update auditlog config through hook

* Clean up policy statements helper functions (#182)

* Clean up policy statements helper functions

* Fix nil return bug

* Add relay proxy config data source (#183)

Co-authored-by: Isabelle Miller <[email protected]>

Co-authored-by: Isabelle Miller <[email protected]>

* Remove unnecessary attributes from  metric data source test config (#184)

* merge issues

* weird merge issue

* include in snippet getting set twice

Co-authored-by: Sunny <[email protected]>
Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>
Co-authored-by: Fabian <[email protected]>
Co-authored-by: Clifford Tawiah <[email protected]>
Co-authored-by: Fabian Feldberg <[email protected]>
@bflad bflad added the terraform-plugin-framework Resolved in terraform-plugin-framework label Jul 14, 2022
@acwest
Copy link

acwest commented Sep 10, 2024

Hi folks 👋 Non-SDK team member providing some additional information here.

We tightened up the validation of the AtLeastOneOf/ConflictsWith/ExactlyOneOf/RequiredWhen fields so the references can be checked via unit testing. As of the upcoming v2, the SDK should return errors if you attempt a reference of config_block_attr.child_attr instead of something like config_block_attr.0.child_attr. This validation should also be ensuring that the configuration block attributes are Type: TypeList and MaxItems: 1, to match the only supported behaviors at the moment.

As for the enhancement request, it seems like the ConflictsWith fields (and friends) could benefit from supporting relative references so that they could handle TypeList and TypeSet attributes, e.g.

Schema: map[string]*schema.Schema{
	"config_block_attr": {
		Type:     schema.TypeSet,
		Optional: true,
		Elem: &schema.Resource{
			Schema: map[string]*schema.Schema{
				"child_attr1": {
					Type:     schema.TypeString,
					Optional: true,
					ConflictsWith: []string{".child_attr2"},
				},
				"child_attr2": {
					Type:     schema.TypeString,
					Optional: true,
					ConflictsWith: []string{".child_attr1"},
				},
			},
		},
	},
},

Where the configuration validation could occur at the same parent-children and level of schema. It would probably need to be restricted to this specific setup rather than allowing arbitrary schema decisions. Attributes cannot begin with a period, so this new syntax should not conflict with (😅 ) existing syntax.

This is just a personal design opinion though that the SDK maintainers would need to validate if its possible and review/approve the design.

This issue has been around a long time... Is there any possibility of getting relative paths in attribute validation working??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request subsystem/types Issues and feature requests related to the type system of Terraform and our shims around it. terraform-plugin-framework Resolved in terraform-plugin-framework
Projects
None yet
Development

No branches or pull requests

7 participants