Skip to content

Commit

Permalink
prepare 2.3.0 release (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: Isabelle Miller <[email protected]>
Co-authored-by: Sunny <[email protected]>
Co-authored-by: Cliff Tawiah <[email protected]>
Co-authored-by: Fabian <[email protected]>
  • Loading branch information
5 people authored Jan 5, 2022
1 parent c68e914 commit 8c7d0fc
Show file tree
Hide file tree
Showing 14 changed files with 431 additions and 138 deletions.
22 changes: 2 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,11 @@ jobs:
name: go vet
command: make vet
- run:
name: Test Custom Properties
command: TESTARGS="-run TestCustomProperties" make testacc
name: Run unit tests
command: TESTARGS="-v" make test
- 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
Expand Down
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [2.3.0] (January 4, 2022)

FEATURES:

- Added `default_client_side_availability` block to the `launchdarkly_project` resource to specify whether feature flags created under the project should be available to client-side SDKs by default.

BUG FIXES:

- Fixed a bug in the `launchdarkly_project` and `launchdarkly_environment` resources which caused Terraform to crash when environment approvals settings are omitted from the LaunchDarkly API response.

NOTES:

- The `launchdarkly_project` resource's argument `include_in_snippet` has been deprecated in favor of `default_client_side_availability`. Please update your config to use `default_client_side_availability` in order to maintain compatibility with future versions.

- The `launchdarkly_project` data source's attribute `client_side_availability` has been renamed to `default_client_side_availability`. Please update your config to use `default_client_side_availability` in order to maintain compatibility with future versions.

## [2.2.0] (December 23, 2021)

ENHANCEMENTS:
Expand All @@ -7,9 +23,9 @@ ENHANCEMENTS:

FEATURES:

- Added `client_side_availability` block to the `launchdarkly_feature_flag` resource to allow setting whether this flag should be made available to the client-side JavaScript SDK using the client-side ID, mobile key, or both.
- Added `client_side_availability` block to the `launchdarkly_feature_flag` resource to allow setting whether this flag should be made available to the client-side JavaScript SDK using the client-side ID, mobile key, or both.

NOTES:
NOTES:

- The `launchdarkly_feature_flag` resource's argument `include_in_snippet` has been deprecated in favor of `client_side_availability`. Please update your config to use `client_side_availability` in order to maintain compatibility with future versions.

Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require (
github.com/agext/levenshtein v1.2.3 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/hcl/v2 v2.11.1 // indirect
Expand Down
21 changes: 19 additions & 2 deletions launchdarkly/data_source_launchdarkly_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ func dataSourceProject() *schema.Resource {
Computed: true,
},
CLIENT_SIDE_AVAILABILITY: {
Type: schema.TypeList,
Computed: true,
Type: schema.TypeList,
Computed: true,
Deprecated: "'client_side_availability' is now deprecated. Please migrate to 'default_client_side_availability' to maintain future compatability.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"using_environment_id": {
Expand All @@ -33,6 +34,22 @@ func dataSourceProject() *schema.Resource {
},
},
},
DEFAULT_CLIENT_SIDE_AVAILABILITY: {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"using_environment_id": {
Type: schema.TypeBool,
Required: true,
},
"using_mobile_key": {
Type: schema.TypeBool,
Required: true,
},
},
},
},
TAGS: tagsSchema(),
},
}
Expand Down
3 changes: 3 additions & 0 deletions launchdarkly/data_source_launchdarkly_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,11 @@ func TestAccDataSourceProject_exists(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "name", project.Name),
resource.TestCheckResourceAttr(resourceName, "id", project.Id),
resource.TestCheckResourceAttr(resourceName, "tags.#", "1"),
// TODO: remove deprecated client_side_availability attribute tests pending next major release
resource.TestCheckResourceAttr(resourceName, "client_side_availability.0.using_environment_id", "false"),
resource.TestCheckResourceAttr(resourceName, "client_side_availability.0.using_mobile_key", "false"),
resource.TestCheckResourceAttr(resourceName, "default_client_side_availability.0.using_environment_id", "false"),
resource.TestCheckResourceAttr(resourceName, "default_client_side_availability.0.using_mobile_key", "false"),
),
},
},
Expand Down
15 changes: 12 additions & 3 deletions launchdarkly/environments_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func environmentsToResourceDataMap(envs []ldapi.Environment) map[string]envResou
}

func environmentToResourceData(env ldapi.Environment) envResourceData {
return envResourceData{
envData := envResourceData{
KEY: env.Key,
NAME: env.Name,
API_KEY: env.ApiKey,
Expand All @@ -205,8 +205,11 @@ func environmentToResourceData(env ldapi.Environment) envResourceData {
REQUIRE_COMMENTS: env.RequireComments,
CONFIRM_CHANGES: env.ConfirmChanges,
TAGS: env.Tags,
APPROVAL_SETTINGS: approvalSettingsToResourceData(*env.ApprovalSettings),
}
if env.ApprovalSettings != nil {
envData[APPROVAL_SETTINGS] = approvalSettingsToResourceData(*env.ApprovalSettings)
}
return envData
}

func rawEnvironmentConfigsToKeyList(rawEnvs []interface{}) []string {
Expand Down Expand Up @@ -250,7 +253,13 @@ func environmentRead(d *schema.ResourceData, meta interface{}, isDataSource bool
_ = d.Set(TAGS, env.Tags)
_ = d.Set(REQUIRE_COMMENTS, env.RequireComments)
_ = d.Set(CONFIRM_CHANGES, env.ConfirmChanges)
_ = d.Set(APPROVAL_SETTINGS, approvalSettingsToResourceData(*env.ApprovalSettings))

if env.ApprovalSettings != nil {
err = d.Set(APPROVAL_SETTINGS, approvalSettingsToResourceData(*env.ApprovalSettings))
if err != nil {
return err
}
}

return nil
}
93 changes: 93 additions & 0 deletions launchdarkly/environments_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

ldapi "github.com/launchdarkly/api-client-go/v7"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -49,5 +50,97 @@ func TestEnvironmentPostFromResourceData(t *testing.T) {
require.Equal(t, tc.expected, actual)
})
}
}

func TestEnvironmentToResourceData(t *testing.T) {
testCases := []struct {
name string
input ldapi.Environment
expected envResourceData
}{
{
name: "standard environment",
input: ldapi.Environment{
Key: "test-env",
Name: "Test Env",
ApiKey: "sdk-234123123",
MobileKey: "b1235363456",
Id: "b234234234234",
Color: "FFFFFF",
DefaultTtl: 60,
SecureMode: true,
DefaultTrackEvents: true,
RequireComments: true,
ConfirmChanges: true,
Tags: []string{"test"},
ApprovalSettings: &ldapi.ApprovalSettings{
Required: true,
MinNumApprovals: 3,
CanApplyDeclinedChanges: true,
RequiredApprovalTags: []string{"approval"},
CanReviewOwnRequest: true,
},
},
expected: envResourceData{
KEY: "test-env",
NAME: "Test Env",
API_KEY: "sdk-234123123",
MOBILE_KEY: "b1235363456",
CLIENT_SIDE_ID: "b234234234234",
COLOR: "FFFFFF",
DEFAULT_TTL: 60,
SECURE_MODE: true,
DEFAULT_TRACK_EVENTS: true,
REQUIRE_COMMENTS: true,
CONFIRM_CHANGES: true,
TAGS: []string{"test"},
APPROVAL_SETTINGS: []map[string]interface{}{
{
CAN_REVIEW_OWN_REQUEST: true,
MIN_NUM_APPROVALS: int32(3),
CAN_APPLY_DECLINED_CHANGES: true,
REQUIRED_APPROVAL_TAGS: []string{"approval"},
REQUIRED: true,
},
},
},
},
{
name: "without approval settings",
input: ldapi.Environment{
Key: "test-env",
Name: "Test Env",
ApiKey: "sdk-234123123",
MobileKey: "b1235363456",
Id: "b234234234234",
Color: "FFFFFF",
DefaultTtl: 60,
SecureMode: true,
DefaultTrackEvents: true,
RequireComments: true,
ConfirmChanges: true,
Tags: []string{"test"},
},
expected: envResourceData{
KEY: "test-env",
NAME: "Test Env",
API_KEY: "sdk-234123123",
MOBILE_KEY: "b1235363456",
CLIENT_SIDE_ID: "b234234234234",
COLOR: "FFFFFF",
DEFAULT_TTL: 60,
SECURE_MODE: true,
DEFAULT_TRACK_EVENTS: true,
REQUIRE_COMMENTS: true,
CONFIRM_CHANGES: true,
TAGS: []string{"test"},
},
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
actual := environmentToResourceData(tc.input)
assert.Equal(t, tc.expected, actual)
})
}
}
Loading

0 comments on commit 8c7d0fc

Please sign in to comment.