Skip to content

Commit

Permalink
prepare 1.5.0 release (#43)
Browse files Browse the repository at this point in the history
* Prep for migration release (#75)

* add goreleaser.yml

* Update changelog

* fix version number

* Add GH actions for release (#76)

* Add GH actions for release

* Bump travis version

* Update readme

* Automatically add changelog entry to release (#77)

* Update go.mod and automatically set version header (#78)

* Add access tokens (#79)

* prepare 1.2.2 release (#24)

* Fix non-empty plan when creating a team member with a custom role (#63)

* Fix handling of missing user target variation in API response (#64)

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

* v1.2.2

* Cleanup after v1.2.2 release

* [ch85469] first pass at tokens

* Update launchdarkly/resource_launchdarkly_access_token.go

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

* add links to sensitive data callout

* expiry and permission fixes

* update markdown

* use latest openapi client

* keys

* tidy

* fixes

* docs update

* Fix go.mod and vendoring

* Remove henry's fmt.Printf

* Clean up go.mod

* clean up go.mod even further

* address some of review

* custom role keys instead of ids

* remove unused var

* reintroduce removed code

* remove references to deleted key

* Remove fmt.Println

* formatting fixes

* fix tests

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: tf-release-bot <[email protected]>

* Release 1.4.0 (#80)

* update changelog for 1.4.0

* prepare 1.4.0 release (#37)

* Prep for migration release (#75)

* add goreleaser.yml

* Update changelog

* fix version number

* Add GH actions for release (#76)

* Add GH actions for release

* Bump travis version

* Update readme

* Automatically add changelog entry to release (#77)

* Update go.mod and automatically set version header (#78)

* Add access tokens (#79)

* prepare 1.2.2 release (#24)

* Fix non-empty plan when creating a team member with a custom role (#63)

* Fix handling of missing user target variation in API response (#64)

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

* v1.2.2

* Cleanup after v1.2.2 release

* [ch85469] first pass at tokens

* Update launchdarkly/resource_launchdarkly_access_token.go

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

* add links to sensitive data callout

* expiry and permission fixes

* update markdown

* use latest openapi client

* keys

* tidy

* fixes

* docs update

* Fix go.mod and vendoring

* Remove henry's fmt.Printf

* Clean up go.mod

* clean up go.mod even further

* address some of review

* custom role keys instead of ids

* remove unused var

* reintroduce removed code

* remove references to deleted key

* Remove fmt.Println

* formatting fixes

* fix tests

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: tf-release-bot <[email protected]>

* update changelog for 1.4.0

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: tf-release-bot <[email protected]>

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: tf-release-bot <[email protected]>

* Ensure ommitted optional feature_flag_environment properties do not make changes when creating (#82)

* Ensure optional feature flag environment properties really are optional

* Update changelog

* Imiller/ch78293/make terraform project data source (#73)

* add stub schema

* add read function that gets project by key

* fix syntax issues

* add test helper functions

* add dataSourceProject to the provider

* add test for an existing resource
add test for an existing data source

* add getProjectByKey method

* name should be optional

* fix test

* add rate limiting to api hit in test to avoid 429 error

* add include_in_snippet to project resource

* extract projectRead into a helper function

* set id for data source but not resource

* add comment

* remove redundant get function

* fix tests

* add include_in_snippet to project resource update test

* replace travis with circleCI to run full tests (#84)

* Add .circleci/config.yml

* specify working directory

* update run command

* comment out run command to see if it will build

* uncomment run & clean up'
:

* fix formatting

* change go version to 1.14

* add make vet

* fix indentation

* scrap travis

* don't run this test in parallel, see if it works

* that wasn't it

* add a 200ms sleep after creating custom roles to see if it fixes the not found error

* limit to 3 packages at a time

* try running just one package at a time?

* try a sleep of 1 second after custom role creation

* only clean team members that are pending invite

* run only team member tests

* run only create test

* only run update with custom role

* try all the team member tests again with seat limit flag off

* run all team member tests separately

* add test clean account

* remove -p and add custom props

* through test acc access token

* fix test name typo

* add all tests separately

* remove sleep

* don't run cleaner test

* run creates separately

* forgot to commit test name change

* run all four tests separately

* Imiller/ch78864/make environment data source (#83)

* add stub schema

* add read function that gets project by key

* fix syntax issues

* add test helper functions

* add dataSourceProject to the provider

* add test for an existing resource
add test for an existing data source

* add getProjectByKey method

* name should be optional

* fix test

* add rate limiting to api hit in test to avoid 429 error

* add include_in_snippet to project resource

* extract projectRead into a helper function

* set id for data source but not resource

* add comment

* remove redundant get function

* fix tests

* add include_in_snippet to project resource update test

* extract read into helper funciton

* stub data source

* add isDataSource param to env read helper

* actually add data source to provider

* fix schema

* add bad env test + scaffolding

* make a separate schema for env data source because of differing required/optional fields

* add test to check that it can get env

* add id check to test

* fix travis build

* remove unnecessary fields from config

* refactor schemas to use overlapping baes

* scrap redundant config

* Update launchdarkly/environments_helper.go

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

* Update launchdarkly/environments_helper.go

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

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

* Imiller/ch87115/make feature flag data source (#85)

* add stub schema

* add read function that gets project by key

* fix syntax issues

* add test helper functions

* add dataSourceProject to the provider

* add test for an existing resource
add test for an existing data source

* add getProjectByKey method

* name should be optional

* fix test

* add rate limiting to api hit in test to avoid 429 error

* add include_in_snippet to project resource

* extract projectRead into a helper function

* set id for data source but not resource

* add comment

* remove redundant get function

* fix tests

* add include_in_snippet to project resource update test

* extract read into helper funciton

* stub data source

* add isDataSource param to env read helper

* actually add data source to provider

* fix schema

* add bad env test + scaffolding

* make a separate schema for env data source because of differing required/optional fields

* add test to check that it can get env

* add id check to test

* fix travis build

* remove unnecessary fields from config

* stub data source

* extract read from resource into helper & stub data source

* extract test helpers into a test_utils file

* add ff data source to provider

* make variation_type optional

* pass bool through read function to differentiate between resource and data source

* add no match test

* add scaffold helper function

* add exists test

* refactor schemas to use overlapping baes

* refactor to use overlapping base schema b/w resource and data source

* scrap redundant config

* scrap redundant config

* fix merge issue

* fix merge again

* Imiller/ch88747/make feature flag environment a data source (#86)

* add stub schema

* add read function that gets project by key

* fix syntax issues

* add test helper functions

* add dataSourceProject to the provider

* add test for an existing resource
add test for an existing data source

* add getProjectByKey method

* name should be optional

* fix test

* add rate limiting to api hit in test to avoid 429 error

* add include_in_snippet to project resource

* extract projectRead into a helper function

* set id for data source but not resource

* add comment

* remove redundant get function

* fix tests

* add include_in_snippet to project resource update test

* extract read into helper funciton

* stub data source

* add isDataSource param to env read helper

* actually add data source to provider

* fix schema

* add bad env test + scaffolding

* make a separate schema for env data source because of differing required/optional fields

* add test to check that it can get env

* add id check to test

* fix travis build

* remove unnecessary fields from config

* stub data source

* extract read from resource into helper & stub data source

* extract test helpers into a test_utils file

* add ff data source to provider

* make variation_type optional

* pass bool through read function to differentiate between resource and data source

* add no match test

* add scaffold helper function

* add exists test

* refactor schemas to use overlapping baes

* refactor to use overlapping base schema b/w resource and data source

* stub data source file

* extract schema into helper function

* extract read function into helper

* basic data source

* move flagIdToKeys into feature flag helper

* stub test config

* scrap redundant config

* scrap redundant config

* move patchFlagEnvPath() into helper

* add test scaffolding function

* stub nomatch test

* i did a very dumb thing - fix test

* fix test again

* return flag instead of config

* add exists test

* change all read functions to generic featureFlagEnvironmentRead

* move test helper into data source

* clean up test utils

* move helper to correct file and update test to patch everything

* check all the things

* fix assertions

* oops found a bug

* fix error typo (#89)

* Resolve issues with nested environments (#87)

* Imiller/ch87117/make webhook data source (#88)

* add stub schema

* add read function that gets project by key

* fix syntax issues

* add test helper functions

* add dataSourceProject to the provider

* add test for an existing resource
add test for an existing data source

* add getProjectByKey method

* name should be optional

* fix test

* add rate limiting to api hit in test to avoid 429 error

* add include_in_snippet to project resource

* extract projectRead into a helper function

* set id for data source but not resource

* add comment

* remove redundant get function

* fix tests

* add include_in_snippet to project resource update test

* extract read into helper funciton

* stub data source

* add isDataSource param to env read helper

* actually add data source to provider

* fix schema

* add bad env test + scaffolding

* make a separate schema for env data source because of differing required/optional fields

* add test to check that it can get env

* add id check to test

* fix travis build

* remove unnecessary fields from config

* stub data source

* extract read from resource into helper & stub data source

* extract test helpers into a test_utils file

* add ff data source to provider

* make variation_type optional

* pass bool through read function to differentiate between resource and data source

* add no match test

* add scaffold helper function

* add exists test

* refactor schemas to use overlapping baes

* refactor to use overlapping base schema b/w resource and data source

* stub data source file

* extract schema into helper function

* extract read function into helper

* basic data source

* move flagIdToKeys into feature flag helper

* stub test config

* scrap redundant config

* scrap redundant config

* move patchFlagEnvPath() into helper

* add test scaffolding function

* stub nomatch test

* i did a very dumb thing - fix test

* fix test again

* return flag instead of config

* add exists test

* add a webhooks helper file

* extract out base schema from resource

* extract out read function

* fix typo & stub data source

* change all read functions to generic featureFlagEnvironmentRead

* move test helper into data source

* clean up test utils

* move helper to correct file and update test to patch everything

* check all the things

* fix assertions

* oops found a bug

* oops make enabled optional

* refactor read

* forgot to define func param type

* stub tests

* add webhook & ff-env data sources to provider

* no match test

* set id for data source in read

* add webhook exists test

* change webhook_id to id

* add policy to test

* Imiller/ch87116/make segment data source (#91)

* add stub schema

* add read function that gets project by key

* fix syntax issues

* add test helper functions

* add dataSourceProject to the provider

* add test for an existing resource
add test for an existing data source

* add getProjectByKey method

* name should be optional

* fix test

* add rate limiting to api hit in test to avoid 429 error

* add include_in_snippet to project resource

* extract projectRead into a helper function

* set id for data source but not resource

* add comment

* remove redundant get function

* fix tests

* add include_in_snippet to project resource update test

* extract read into helper funciton

* stub data source

* add isDataSource param to env read helper

* actually add data source to provider

* fix schema

* add bad env test + scaffolding

* make a separate schema for env data source because of differing required/optional fields

* add test to check that it can get env

* add id check to test

* fix travis build

* remove unnecessary fields from config

* stub data source

* extract read from resource into helper & stub data source

* extract test helpers into a test_utils file

* add ff data source to provider

* make variation_type optional

* pass bool through read function to differentiate between resource and data source

* add no match test

* add scaffold helper function

* add exists test

* refactor schemas to use overlapping baes

* refactor to use overlapping base schema b/w resource and data source

* stub data source file

* extract schema into helper function

* extract read function into helper

* basic data source

* move flagIdToKeys into feature flag helper

* stub test config

* scrap redundant config

* scrap redundant config

* move patchFlagEnvPath() into helper

* add test scaffolding function

* stub nomatch test

* i did a very dumb thing - fix test

* fix test again

* return flag instead of config

* add exists test

* add a webhooks helper file

* extract out base schema from resource

* extract out read function

* fix typo & stub data source

* change all read functions to generic featureFlagEnvironmentRead

* move test helper into data source

* clean up test utils

* move helper to correct file and update test to patch everything

* check all the things

* fix assertions

* oops found a bug

* oops make enabled optional

* refactor read

* forgot to define func param type

* stub tests

* add webhook & ff-env data sources to provider

* no match test

* set id for data source in read

* add webhook exists test

* extract out resource schema

* extract out hte read function

* add data source to provider

* check accTest in webhook test

* differentiate read for resource & ds

* data source

* add no match test

* set id for data sources in read

* add exists test

* extract out resource schema

* extract out hte read function

* fix merge conflict

* make project key required on segment resource

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

* change webhook_id to id

* add policy to test

* change name from optional to computed

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

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

* Add nested environments documentation (#90)

* Use GetOKExists for off_variation and improve feature_flag_environment read efficiency (#93)

* Use GetOKExists for off_variation and improve read efficiency

* Add a json feature flag example with default variations (#94)

* Imiller/ch90407/write docs for new data sources (#92)

* add stub schema

* add read function that gets project by key

* fix syntax issues

* add test helper functions

* add dataSourceProject to the provider

* add test for an existing resource
add test for an existing data source

* add getProjectByKey method

* name should be optional

* fix test

* add rate limiting to api hit in test to avoid 429 error

* add include_in_snippet to project resource

* extract projectRead into a helper function

* set id for data source but not resource

* add comment

* remove redundant get function

* fix tests

* add include_in_snippet to project resource update test

* extract read into helper funciton

* stub data source

* add isDataSource param to env read helper

* actually add data source to provider

* fix schema

* add bad env test + scaffolding

* make a separate schema for env data source because of differing required/optional fields

* add test to check that it can get env

* add id check to test

* fix travis build

* remove unnecessary fields from config

* stub data source

* extract read from resource into helper & stub data source

* extract test helpers into a test_utils file

* add ff data source to provider

* make variation_type optional

* pass bool through read function to differentiate between resource and data source

* add no match test

* add scaffold helper function

* add exists test

* refactor schemas to use overlapping baes

* refactor to use overlapping base schema b/w resource and data source

* stub data source file

* extract schema into helper function

* extract read function into helper

* basic data source

* move flagIdToKeys into feature flag helper

* stub test config

* scrap redundant config

* scrap redundant config

* move patchFlagEnvPath() into helper

* add test scaffolding function

* stub nomatch test

* i did a very dumb thing - fix test

* fix test again

* return flag instead of config

* add exists test

* add a webhooks helper file

* extract out base schema from resource

* extract out read function

* fix typo & stub data source

* change all read functions to generic featureFlagEnvironmentRead

* move test helper into data source

* clean up test utils

* move helper to correct file and update test to patch everything

* check all the things

* fix assertions

* oops found a bug

* oops make enabled optional

* refactor read

* forgot to define func param type

* stub tests

* add webhook & ff-env data sources to provider

* no match test

* set id for data source in read

* add webhook exists test

* extract out resource schema

* extract out hte read function

* add data source to provider

* check accTest in webhook test

* differentiate read for resource & ds

* data source

* add no match test

* set id for data sources in read

* add exists test

* extract out resource schema

* extract out hte read function

* fix merge conflict

* make project key required on segment resource

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

* change webhook_id to id

* add policy to test

* add new include_in_snippet arg to proj resource doc

* add project ds doc

* project key should be required in env ds

* add env ds doc

* update schema fields in ff ds

* fix typos

* feature flag ds doc

* no validation function on computed schema type

* fix feature_flag_env data source & tests

* add feature_flag_environment data source doc

* remove extra dashes for consistency

* add webhook ds doc

* fix typo

* refactor a bit for conciseness

* fix error in segment resource doc

* add segment doc

* differentiate reads between resource and ds for ff-env

* change name from optional to computed

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

* minor fixes

* fix hcl example formatting

* change resource to data source

* update some wording & add ds links to website sidebar

* go get new api version & go mod vendor

* add client_side_availability ky

* add client side availability to flag data source

* switch out snippet for client side availability in project data source

* convert client side availability struct to appropriate map for data source

* update project test

* update feature flag read to set csa

* update feature flag data source test

* change include_in_snippet to client_side_availability in project & ff ds docs

* set include_in_snippet for feature flag resource instead of csa

* add csa block section to project & ff docs

* fix alignment

* update changelog

* singularize 'block'

* update wording

* update wording

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

* change SDKS to SDKs

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

* change SDKS to SDKs

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

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

* update release version in changelog

Co-authored-by: Henry Barrow <[email protected]>
Co-authored-by: Arnold Trakhtenberg <[email protected]>
Co-authored-by: tf-release-bot <[email protected]>
  • Loading branch information
4 people authored Sep 29, 2020
1 parent 5d96a37 commit ead4135
Show file tree
Hide file tree
Showing 173 changed files with 2,883 additions and 815 deletions.
73 changes: 73 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Golang CircleCI 2.0 configuration file for terraform-provider-launchdarkly-private tests
#
# Check https://circleci.com/docs/2.0/language-go/ for more details
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.14

working_directory: /go/src/github.com/launchdarkly/terraform-provider-launchdarkly-private
steps:
- checkout
- run:
name: go vet
command: make vet
- run:
name: Test Custom Properties
command: TESTARGS="-run TestCustomProperties" make testacc
- run:
name: Test Data Sources
command: TESTARGS="-run TestAccDataSource" make testacc
- run:
name: Test Default Variations
command: TESTARGS="-run TestDefaultVariations" make testacc
- run:
name: Test Environment Helper
command: TESTARGS="-run TestEnvironmentPost" make testacc
- run:
name: Test Target Helper
command: TESTARGS="-run TestTargets" make testacc
- run:
name: Test Variations Helper
command: TESTARGS="-run TestVariations" make testacc
- run:
name: Test Handlers
command: TESTARGS="-run TestHandle" make testacc
- run:
name: Test Policy Statements
command: TESTARGS="-run TestPolicyStatement" make testacc
- run:
name: Test Access Token Resource
command: TESTARGS="-run TestAccAccessToken" make testacc
- run:
name: Test Custom Role Resource
command: TESTARGS="-run TestAccCustomRole" make testacc
- run:
name: Test Destination Resource
command: TESTARGS="-run TestAccDestination" make testacc
- run:
name: Test Environment Resource
command: TESTARGS="-run TestAccEnvironment" make testacc
- run:
name: Test Feature Flag Resource
command: TESTARGS="-run TestAccFeatureFlag" make testacc
- run:
name: Test Feature Flag Environment Resource
command: TESTARGS="-run TestAccFeatureFlagEnvironment" make testacc
- run:
name: Test Project Resource
command: TESTARGS="-run TestAccProject" make testacc
- run:
name: Test Segment Resource
command: TESTARGS="-run TestAccSegment" make testacc
- run:
name: Test Team Members
command: |
TESTARGS="-run TestAccTeamMember_CreateGeneric" make testacc
TESTARGS="-run TestAccTeamMember_UpdateGeneric" make testacc
TESTARGS="-run TestAccTeamMember_CreateWithCustomRole" make testacc
TESTARGS="-run TestAccTeamMember_UpdateWithCustomRole" make testacc
- run:
name: Test Webhook Resource
command: TESTARGS="-run TestAccWebhook" make testacc
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## [1.5.0] (September 29, 2020)

FEATURES:

- Added a `launchdarkly_project` data source.

- Added a `launchdarkly_environment` data source.

- Added a `launchdarkly_feature_flag` data source.

- Added a `launchdarkly_feature_flag_environment` data source.

- Added a `launchdarkly_segment` data source.

- Added a `launchdarkly_webhook` data source.

ENHANCEMENTS:

- Upgraded the LaunchDarkly API version to 3.5.0.

BUG FIXES:

- Resolved issues with the `launchdarkly_project`'s `environments` attribute. This attribute is no longer marked as deprecated and should be used when you wish to override the behavior of creating `Test` and `Production` environments during project creation.

- Fixed a bug where creating a `launchdarkly_feature_flag_environment` with an `off_variation` was not actually setting the off variation.

NOTES:

- The `launchdarkly_project`'s `environments` attribute is no longer marked as `computed`. This means that if you have `launchdarkly_project` resources without nested `environments` that were created before this version, you will see a diff denoting the removal of the computed environments from your state. It is safe to apply this change as no changes be made to your LaunchDarkly resources when applied.

## [1.4.1] (September 8, 2020)

FEATURES:
Expand Down
26 changes: 15 additions & 11 deletions examples/multiple_projects/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
## Example: Configure multiple LaunchDarkly projects

### Introduction

LaunchDarkly projects allow you to manage multiple business objectives from a single LaunchDarkly account. Every project has its own unique set of associated environments and feature flags. For more, please see the [LaunchDarkly official documentation](https://docs.launchdarkly.com/home/managing-flags/projects).

This directory contains an example of how one might configure multiple projects, each with their own environments and feature flags, in one go. Specifically, this example will create the following:

- a "Terraform Example Project 1" with the key `tf-project-1` containing:
- a "Terraform Test Environment" with key `tf-test`
- a "Terraform Production Environment" with key `tf-production`
- (automatically-created "Test" and "Production" environments that come with all new projects)
- a boolean "Basic feature flag" with key "basic-flag"
- a `tf-test`-specific flag configuration attached to the "Basic feature flag"
- a "Terraform Test Environment" with key `tf-test`
- a "Terraform Production Environment" with key `tf-production`
- a boolean "Basic feature flag" with key "basic-flag"
- a `tf-test`-specific flag configuration attached to the "Basic feature flag"
- a "Terraform Example Project 2" with thte key `tf-project-2` containing:
- an "Example Environment A" with key `tf-example-env-a`
- an "Example Environment B" with key `tf-example-env-b`
- (automatically-created "Test" and "Production" environments that come with all new projects)
- an "Example Environment A" with key `tf-example-env-a`
- an "Example Environment B" with key `tf-example-env-b`
- (automatically-created "Test" and "Production" environments will also be created since this example does not use nested environments in the `launchdarkly_project` resource)

Project 1 also contains an example of a feature flag that is configured differently in different environments using the `launchdarkly_feature_flag_environment` resource. You can see these differences from within the LaunchDarkly UI. When viewing the flag in the `tf_test` environment, the flag will look like this:

Expand All @@ -23,13 +24,14 @@ From all other environments, it will simply look like this:

![basic flag](../assets/images/multiple-proj-basic-flag.png)


### Important notes
- Keep in mind that all new projects will automatically come with 'test' and 'production' environments, so it is redundant to create those!

- Keep in mind that all new projects that don't use nested `environments` blocks will automatically come with 'test' and 'production' environments, so it may be redundant to create those!
- Project keys MUST be unique
- Environment keys must be unique within their given project

### Run

Init your working directory from the CL with `terraform init` and then apply the changes with `terraform apply`. You should see output resembling the following:

```
Expand Down Expand Up @@ -63,11 +65,13 @@ Plan: 8 to add, 0 to change, 0 to destroy.
```

where all of the changes to be made should be described in the format seen above. Terraform will then ask you for your confirmation and then begin applying the changes:

```
launchdarkly_project.tf_project_1: Creating...
launchdarkly_project.tf_project_2: Creating...
launchdarkly_project.tf_project_2: Creation complete after 0s [id=example-project-2]
launchdarkly_environment.tf_env_a: Creating...
launchdarkly_environment.tf_env_b: Creating...
```
etc. Your projects should now be up, running, and accessible from your LaunchDarkly UI.

etc. Your projects should now be up, running, and accessible from your LaunchDarkly UI.
54 changes: 27 additions & 27 deletions examples/multiple_projects/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,35 @@ provider "launchdarkly" {
# ----------------------------------------------------------------------------------- #
# PROJECT 1

# create the project
# create the project with nested environments blocks
resource "launchdarkly_project" "tf_project_1" {
key = "tf-project-1"
name = "Terraform Example Project 1"

tags = [
"terraform-managed",
]
}

# create a terraform-specific test environment within project 1
resource "launchdarkly_environment" "tf_test" {
name = "Terraform Test Environment"
key = "tf-test"
color = "999999"
tags = [
"terraform-managed",
"test"
]

project_key = launchdarkly_project.tf_project_1.key
}

# create a terraform-specific production environment within project 1
resource "launchdarkly_environment" "tf_production" {
name = "Terraform Production Environment"
key = "tf-production"
color = "333333"
tags = [
"terraform-managed",
]
# create a terraform-specific test environment within the project
environments {
name = "Terraform Test Environment"
key = "tf-test"
color = "999999"
tags = [
"terraform-managed",
"test"
]
}

project_key = launchdarkly_project.tf_project_1.key
# create a terraform-specific production environment within the project
environments {
name = "Terraform Production Environment"
key = "tf-production"
color = "333333"
tags = [
"terraform-managed",
]
}
}

# create a basic feature flag within project 1
Expand All @@ -58,7 +54,10 @@ resource "launchdarkly_feature_flag" "basic" {
# the flag will display variation 0 only to users whose country matches "de" or "fr".
resource "launchdarkly_feature_flag_environment" "basic_variation" {
flag_id = launchdarkly_feature_flag.basic.id
env_key = launchdarkly_environment.tf_test.key

# since the environment was specified as a nested block in the project resource, the environment
# key must be retrieved through the `launchdarkly_project` resource.
env_key = launchdarkly_project.tf_project_1.environments.0.key

targeting_enabled = true

Expand All @@ -78,7 +77,8 @@ resource "launchdarkly_feature_flag_environment" "basic_variation" {
}

# ----------------------------------------------------------------------------------- #
# PROJECT 2
# PROJECT 2 - an example of how to use dedicated `launchdarkly_enviromnent` resources instead
# of nested environments in the `launchdarkly_project` resource

resource "launchdarkly_project" "tf_project_2" {
key = "tf-project-2"
Expand Down Expand Up @@ -110,4 +110,4 @@ resource "launchdarkly_environment" "tf_env_b" {
]

project_key = launchdarkly_project.tf_project_2.key
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.14
require (
github.com/antihax/optional v1.0.0
github.com/hashicorp/terraform-plugin-sdk v1.15.0
github.com/launchdarkly/api-client-go v3.2.1-0.20200812163818-441cfcaaa92c+incompatible
github.com/launchdarkly/api-client-go v3.5.0+incompatible
github.com/stretchr/testify v1.6.1
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3v
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/launchdarkly/api-client-go v3.2.1-0.20200812163818-441cfcaaa92c+incompatible h1:xWlvqEclZEIAX4+0k2TQZGxgWA4tElgXy/H1XNsD/cQ=
github.com/launchdarkly/api-client-go v3.2.1-0.20200812163818-441cfcaaa92c+incompatible/go.mod h1:INGa7NUZYSwVozwPV7l6ikgD7pzSOpZvg9I5sqCZIWs=
github.com/launchdarkly/api-client-go v3.5.0+incompatible h1:b2DN5SjdUZu4tf4AwEEt8BmvC1f1DXI/S+SeruNVbGM=
github.com/launchdarkly/api-client-go v3.5.0+incompatible/go.mod h1:INGa7NUZYSwVozwPV7l6ikgD7pzSOpZvg9I5sqCZIWs=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg=
Expand Down
2 changes: 1 addition & 1 deletion launchdarkly/account_cleaner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (c *Client) cleanTeamMembers() error {
return handleLdapiErr(err)
}
for _, m := range members.Items {
if *m.Role != ldapi.OWNER_Role {
if *m.Role != ldapi.OWNER_Role && m.PendingInvite == true {
_, err := c.ld.TeamMembersApi.DeleteMember(c.ctx, m.Id)
if err != nil {
return handleLdapiErr(err)
Expand Down
20 changes: 20 additions & 0 deletions launchdarkly/data_source_launchdarkly_environment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package launchdarkly

import "github.com/hashicorp/terraform-plugin-sdk/helper/schema"

func dataSourceEnvironment() *schema.Resource {
envSchema := dataSourceEnvironmentSchema(false)
envSchema[PROJECT_KEY] = &schema.Schema{
Type: schema.TypeString,
Required: true,
ValidateFunc: validateKey(),
}
return &schema.Resource{
Read: dataSourceEnvironmentRead,
Schema: envSchema,
}
}

func dataSourceEnvironmentRead(d *schema.ResourceData, meta interface{}) error {
return environmentRead(d, meta, true)
}
Loading

0 comments on commit ead4135

Please sign in to comment.