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

prepare 1.5.0 release #43

Merged
merged 25 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dadc281
Prep for migration release (#75)
ldhenry Jul 31, 2020
843e397
Merge branch 'master' of github.com:launchdarkly/terraform-provider-l…
ldhenry Aug 3, 2020
43d9057
Add GH actions for release (#76)
ldhenry Aug 3, 2020
a1e36d5
Automatically add changelog entry to release (#77)
ldhenry Aug 3, 2020
0b33f62
Update go.mod and automatically set version header (#78)
ldhenry Aug 3, 2020
5aae790
Merge branch 'master' of github.com:launchdarkly/terraform-provider-l…
ldhenry Aug 3, 2020
fad8a7b
Add access tokens (#79)
Aug 21, 2020
d3dc2db
Release 1.4.0 (#80)
Aug 21, 2020
e11b96a
Ensure ommitted optional feature_flag_environment properties do not m…
ldhenry Sep 8, 2020
ad47f94
Merge branch 'master' of github.com:launchdarkly/terraform-provider-l…
ldhenry Sep 8, 2020
e2e7496
Merge branch 'master' of github.com:launchdarkly/terraform-provider-l…
ldhenry Sep 8, 2020
b459f74
Imiller/ch78293/make terraform project data source (#73)
sloloris Sep 15, 2020
a06a122
replace travis with circleCI to run full tests (#84)
sloloris Sep 18, 2020
e7c84ce
Imiller/ch78864/make environment data source (#83)
sloloris Sep 21, 2020
0fd4b76
Imiller/ch87115/make feature flag data source (#85)
sloloris Sep 21, 2020
69b6bc8
Imiller/ch88747/make feature flag environment a data source (#86)
sloloris Sep 22, 2020
7ee7355
fix error typo (#89)
sloloris Sep 22, 2020
06c45ef
Resolve issues with nested environments (#87)
ldhenry Sep 22, 2020
ad940f6
Imiller/ch87117/make webhook data source (#88)
sloloris Sep 24, 2020
a7089cf
Imiller/ch87116/make segment data source (#91)
sloloris Sep 24, 2020
e9b12b7
Add nested environments documentation (#90)
ldhenry Sep 28, 2020
f6249d3
Use GetOKExists for off_variation and improve feature_flag_environmen…
ldhenry Sep 28, 2020
ddfeabb
Add a json feature flag example with default variations (#94)
ldhenry Sep 28, 2020
ee4abc3
Imiller/ch90407/write docs for new data sources (#92)
sloloris Sep 29, 2020
c797aed
update release version in changelog
sloloris Sep 29, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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