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 2.12.1 release #149

Merged
merged 141 commits into from
May 15, 2023
Merged
Changes from 3 commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
8fd56bd
prepare release (#80) (#188)
sloloris Jan 20, 2022
aea6005
Do not allow 0% segment rule weights (#189)
ldhenry Jan 21, 2022
f1e972c
Fix flag trigger creation panic (#190)
ldhenry Jan 21, 2022
09a6fa3
Backmerge/release 2.4.1 (#191)
ldhenry Jan 21, 2022
e493b76
Add Slack webhooks to audit_log_subscription (#192)
ldhenry Feb 7, 2022
2512cf3
backmerge v2.5.0 (#193)
ldhenry Feb 8, 2022
f4332bc
Use jennifer to generate audit log subscription configs (#194)
ldhenry Feb 8, 2022
de0fe41
Run terraform provider acceptance tests daily and notify of failures …
ldhenry Feb 8, 2022
9a38dde
Update changelog branch (#195)
ldhenry Feb 9, 2022
d285706
[ sc-143291] update autogenerated audit_log_subscription configs (#197)
monsagri Mar 14, 2022
42d99ac
Increase checkpoint-api.harhicorp.com timeout to 10s (#198)
ldhenry Mar 17, 2022
04b73ff
Updated destination tests to use random env keys to avoid env conflic…
ctawiah Apr 6, 2022
b6bc3f2
Merge pull request #199 from launchdarkly/ctawiah/sc-148136/randomize…
ctawiah Apr 6, 2022
e722f06
[sc 148065] add approvals bypass to terraform docs (#200)
monsagri Apr 7, 2022
b88452a
Backmerge/release 2.6.0 (#201)
monsagri Apr 7, 2022
ae41bdb
fix doc issues (#202)
sloloris Apr 14, 2022
a402d11
[sc-149869] roll back documentation changes regarding (#203)
monsagri Apr 14, 2022
66d55a1
backmerge 2.6.1 (#204)
monsagri Apr 14, 2022
494df8f
Imiller/sc 151834/add base permissions to custom role resource (#205)
sloloris May 4, 2022
38d70bc
Backmerge/release 2.7.0 (#206)
sloloris May 5, 2022
6559f71
(bug-fix) Update modules to accept new API header
May 11, 2022
4795ea3
Merge pull request #207 from launchdarkly/fix-ci
lucywyman May 13, 2022
626aaae
Update circleci test timeout to 15 seconds
May 19, 2022
2c88570
Merge pull request #208 from launchdarkly/sunny/sc-153482/increase-ti…
lucywyman May 20, 2022
9084524
Regenerate auditlog configs to resolve CI failures (#211)
ldhenry Jun 30, 2022
54dbc29
Run make generate to supress CI failures (#212)
ldhenry Jul 11, 2022
b9a3419
added a check for environment and warning
Jul 12, 2022
c073a3b
fix go lint error
Jul 12, 2022
822f9d8
Merge branch 'main' into sunny/sc-158595/leftover-resources-cannot-be…
Jul 12, 2022
2ba884b
use environmentExists function
Jul 12, 2022
dd21dac
remove grafana
Jul 13, 2022
66c862c
fix: [sc-158595] leftover resources cannot be cleared out after launc…
Jul 13, 2022
88840f0
Update changelog with bug fix for datasource feature flag environment
Jul 13, 2022
33a1f9f
Merge pull request #215 from launchdarkly/sunny/update-changelog-data…
lucywyman Jul 14, 2022
7b218fe
added changes
Jul 26, 2022
c1a3b89
Merge pull request #216 from launchdarkly/backmerge/release-2.7.1
Jul 26, 2022
70c9c34
upgrade go version 1.18.1 (#217)
sloloris Jul 27, 2022
8bee33e
Backmerge public/release v2.7.1 3 (#219)
ldhenry Jul 27, 2022
402b508
Remove invalid integration configurations (#221)
ldhenry Jul 28, 2022
db398b8
Add blacklist to manifest codegen and remove Zapier. (#222)
ldhenry Jul 28, 2022
b9e966d
Backmerge release 2.7.2 (#223)
ldhenry Jul 28, 2022
e7d7f77
Update Go api client to 10.0.1
Jun 28, 2022
6a6345e
Fix up v10 migration PR
Jul 28, 2022
11e3b82
Merge pull request #225 from launchdarkly/migrate-terraform-to-v10
lucywyman Jul 28, 2022
e9c8d43
[SC-160359] Create Teams resource and datasource
Jun 28, 2022
1d1e3d3
Fix up documentation
Aug 3, 2022
70e838e
Make lists unsorted to avoid unnecessary change detection
Aug 3, 2022
8fb4544
Update website/docs/d/team.html.markdown
lucywyman Aug 3, 2022
a97b4ae
Make lists unsorted to avoid unnecessary change detection
Aug 3, 2022
1cd0737
Merge pull request #224 from launchdarkly/dominickagnello/sc-160359/u…
lucywyman Aug 4, 2022
da5dacd
prepare 2.6.0 release (#91)
monsagri Apr 7, 2022
43ee03b
prepare 2.6.1 release (#94)
monsagri Apr 14, 2022
519707a
Prepare 2.7.1 release (#103)
Jul 25, 2022
1d371d9
Prepare release 2.7.1 2 (#104)
sloloris Jul 27, 2022
6276ea6
fix merge issue in Circle config (#105)
ldhenry Jul 27, 2022
76f1bcf
Release 2.7.2 (#106)
ldhenry Jul 28, 2022
416ec8b
prepare 2.8.0 release
Aug 4, 2022
8569589
Merge pull request #227 from launchdarkly/backmerge/release-2.8.0
lucywyman Aug 4, 2022
f21dd2c
[SC-163244] Add no-access role for team member resource
Aug 5, 2022
aded53f
Merge pull request #228 from launchdarkly/lucyvoigt/sc-163244/add-no-…
lucywyman Aug 5, 2022
f8caaea
Backmerge 2.9.0 release
Aug 5, 2022
72236a5
[sc-147722] add codeowners file (#230)
monsagri Aug 9, 2022
fd4a7de
Merge pull request #229 from launchdarkly/backmerge/release-2.9.0
lucywyman Aug 10, 2022
c60959a
Dominickagnello/sc 163883/open a pr against the terraform provider (#…
Blugil Aug 10, 2022
8ceb94b
add conditional so that new action only runs in private repo
Aug 10, 2022
229b5b9
Remove example.com email addresses from acceptance tests (#234)
ldhenry Aug 10, 2022
d459813
Retry failed acceptance tests once
Aug 10, 2022
e23033f
Merge pull request #235 from launchdarkly/retry-failed-tests-once
lucywyman Aug 10, 2022
124c1da
Merge pull request #233 from launchdarkly/dominickagnello/sc-163883/o…
lucywyman Aug 11, 2022
362669f
[SC-163262] Suppress diff when value_type doesn't change
Aug 5, 2022
c1ff182
Update launchdarkly/clause_helper.go
lucywyman Aug 23, 2022
a83f848
Merge pull request #236 from launchdarkly/lucyvoigt/sc-163262/don-t-s…
lucywyman Aug 24, 2022
e7affce
[bot] Regenerate integration configs (#237)
github-actions[bot] Aug 24, 2022
b8c9085
Update feature_flag_environmewnt to only create patch statements when…
ldhenry Aug 24, 2022
07e3cc0
merge public/main (#239)
ldhenry Aug 24, 2022
8311a3a
Imiller/sc 166499/defaults for boolean flags do not apply to existing…
sloloris Sep 1, 2022
9e135b6
Backmerge public (#241)
ldhenry Sep 1, 2022
c65030c
Imiller/sc 168660/terraform issue importing project with environments…
sloloris Sep 13, 2022
628672e
[SC-169876] Correctly set bucketBy to nil when empty
Sep 20, 2022
a438dfa
[SC-168865] Print error message with API errors
Sep 13, 2022
c7c9269
Merge pull request #242 from launchdarkly/lucyvoigt/sc-168865/hi-team…
lucywyman Sep 26, 2022
3dcf1bc
Merge pull request #244 from launchdarkly/lucyvoigt/sc-169876/launchd…
lucywyman Sep 26, 2022
3a6f10e
[SC-170290] Add ignore_changes guide to Terraform docs
Sep 28, 2022
8134e76
Merge pull request #245 from launchdarkly/lucyvoigt/sc-170290/update-…
lucywyman Sep 30, 2022
5f2984c
Backmerge 2.9.3 release
Oct 3, 2022
384cfb9
Merge pull request #246 from launchdarkly/backmerge/release-2.9.3
lucywyman Oct 3, 2022
259ab96
[SC-174121] Docs bug fixes
Oct 26, 2022
f8d6a58
Merge pull request #247 from launchdarkly/lucyvoigt/sc-174121/fix-gui…
lucywyman Oct 26, 2022
fae2eba
Imiller/sc 162868/update documentation on using feature flag env sett…
sloloris Oct 31, 2022
94298b1
update links to docs.launchdarkly
mmrj Jan 9, 2023
0940048
Apply some additional copy suggestions from code review
mmrj Jan 9, 2023
b88eb72
add changelog entry
mmrj Jan 10, 2023
5eb15a1
Update CHANGELOG.md
sloloris Jan 10, 2023
7342d64
Merge pull request #251 from launchdarkly/mollyjones2723/sc-182866/in…
mmrj Jan 10, 2023
dfafc3b
should not be able to set targets with empty values (#252)
sloloris Jan 10, 2023
15ee255
fix test (#255)
sloloris Jan 10, 2023
33de477
fix retry command (#254)
sloloris Jan 10, 2023
3d214ef
Update generated audit log config (#267)
sloloris Jan 27, 2023
76a985f
merge main from public?
sloloris Jan 27, 2023
f792697
backmerge (#268)
sloloris Jan 30, 2023
a2b4c4a
[bot] Regenerate integration configs (#269)
github-actions[bot] Feb 1, 2023
2289644
Add optional targeting rule descriptions (#270)
ldhenry Feb 1, 2023
f240372
[bot] Regenerate integration configs
Blugil Feb 8, 2023
143d6d0
Merge pull request #272 from launchdarkly/regenerate-integration-conf…
lucywyman Feb 9, 2023
0d4a2e5
[bot] Regenerate integration configs
Blugil Feb 9, 2023
f6b2ccd
Merge pull request #273 from launchdarkly/regenerate-integration-conf…
lucywyman Feb 9, 2023
8d57914
add ldrelease metadata (#275)
monsagri Feb 16, 2023
4fd103c
[sc 189042] update project releaser config (#276)
monsagri Feb 21, 2023
30edd7c
Releasing version 2.9.6
Feb 21, 2023
98b5c1a
[sc 189042] update project releaser config permissions (#277)
monsagri Feb 21, 2023
a9cee2a
Releasing version 2.9.6
Feb 21, 2023
562f945
[sc 189042] update project releaser artifacts (#278)
monsagri Feb 21, 2023
81b0692
Releasing version 2.9.6
Feb 21, 2023
8233722
add update-version back in (#279)
monsagri Feb 21, 2023
7f383af
Releasing version 2.9.7
Feb 21, 2023
db1bbff
fix changelog (#280)
monsagri Feb 21, 2023
e3061c6
Releasing version 2.9.7
Feb 21, 2023
66c0c5b
(maint) Document 'archived' attribute of feature_flag
Feb 21, 2023
a834b44
[sc 189042] automate terraform provider releases 2 (#282)
monsagri Feb 22, 2023
23dcf51
Merge pull request #281 from launchdarkly/add-archive-docs
lucywyman Feb 22, 2023
0d0a853
Imiller/sc 189789/investigate workarounds for default CSA issue (#283)
sloloris Feb 27, 2023
f567041
Remove tests (#284)
sloloris Feb 27, 2023
8203c0a
Maint/fix backlog conflict (#285)
monsagri Feb 27, 2023
8cb1cee
merge from public after release
Feb 27, 2023
584b69d
Add support for Custom Contexts (#249)
sloloris Feb 28, 2023
d2c3bd8
merge from public after release
Feb 28, 2023
1e3785e
[bot] Regenerate integration configs (#286)
github-actions[bot] Mar 6, 2023
47f57b1
Bump golang.org/x/net from 0.1.0 to 0.7.0 (#288)
dependabot[bot] Mar 9, 2023
d3eb324
Update CODEOWNERS (#289)
ldhenry Mar 9, 2023
5131b70
Upgrade to Go 1.19 and bump golangci-lint in pre-commit (#290)
ldhenry Mar 9, 2023
bced6a8
[sc-190487] add randomization_units (optional) to metric resource (#287)
goldfrapp04 Mar 10, 2023
1529d77
merge from public after release
Mar 10, 2023
a957055
Bump go to v1.19 in remaining places (#291)
ldhenry Mar 10, 2023
f8f1326
merge from public after release
Mar 10, 2023
6d65531
Add pull request template (#292)
sloloris Mar 15, 2023
86eb3b7
[bot] Regenerate integration configs (#293)
github-actions[bot] Apr 4, 2023
3eab336
[bot] Regenerate integration configs (#294)
github-actions[bot] Apr 18, 2023
0c44fb7
[bot] Regenerate integration configs (#295)
github-actions[bot] May 10, 2023
b53545c
Imiller/sc 202319/terraform provider panics if empty fallthrough (#296)
sloloris May 11, 2023
745ed90
update changelog version (#297)
sloloris May 15, 2023
62111b9
update changelog
sloloris May 15, 2023
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ require (
github.com/hashicorp/terraform-registry-address v0.0.0-20220510144317-d78f4a47ae27 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
github.com/launchdarkly/api-client-go/v10 v10.0.1
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -226,8 +226,9 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/launchdarkly/api-client-go/v7 v7.1.1 h1:3VBkFt9xHljMw5KDlVFDUogxfH78Y7GLVu8irBC8Gy8=
github.com/launchdarkly/api-client-go/v7 v7.1.1/go.mod h1:GVl1inKsWoKX3yLgdqrjxWw8k4ih0HlSmdnrhi5NNDs=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/launchdarkly/api-client-go/v10 v10.0.1 h1:9uJ5Uf7FsSwFjSP648Ii9qG6O22ZUrw0RFIMtIkPWkY=
github.com/launchdarkly/api-client-go/v10 v10.0.1/go.mod h1:LeQ6lizPnybCGvNfKpnnVxMMG2a2hFF5Lnz+jBBgxqQ=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
2 changes: 1 addition & 1 deletion launchdarkly/approvals_helper.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func approvalSchema() *schema.Schema {
4 changes: 2 additions & 2 deletions launchdarkly/audit_log_subscription_helper.go
Original file line number Diff line number Diff line change
@@ -214,15 +214,15 @@ func auditLogSubscriptionRead(ctx context.Context, d *schema.ResourceData, metaR

_ = d.Set(NAME, sub.Name)
_ = d.Set(ON, sub.On)
cfg, err := configToResourceData(d, *sub.Config, isDataSource)
cfg, err := configToResourceData(d, sub.Config, isDataSource)
if err != nil {
return diag.Errorf("failed to set config on integration with id %q: %v", *sub.Id, err)
}
err = d.Set(CONFIG, cfg)
if err != nil {
return diag.Errorf("failed to set config on integration with id %q: %v", *sub.Id, err)
}
err = d.Set(STATEMENTS, policyStatementsToResourceData(*sub.Statements))
err = d.Set(STATEMENTS, policyStatementsToResourceData(sub.Statements))
if err != nil {
return diag.Errorf("failed to set statements on integration with id %q: %v", *sub.Id, err)
}
2 changes: 1 addition & 1 deletion launchdarkly/clause_helper.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

const (
2 changes: 1 addition & 1 deletion launchdarkly/clause_helper_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
4 changes: 2 additions & 2 deletions launchdarkly/config.go
Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@ import (
"time"

retryablehttp "github.com/hashicorp/go-retryablehttp"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

//nolint:staticcheck // The version string gets updated at build time using -ldflags
var version = "unreleased"

const (
APIVersion = "20191212"
APIVersion = "20220603"
MAX_RETRIES = 8
RETRY_WAIT_MIN = 200 * time.Millisecond
RETRY_WAIT_MAX = 2000 * time.Millisecond
2 changes: 1 addition & 1 deletion launchdarkly/custom_properties_helper.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

// https://docs.launchdarkly.com/docs/custom-properties
2 changes: 1 addition & 1 deletion launchdarkly/custom_properties_helper_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -32,16 +32,16 @@ func testAccDataSourceAuditLogSubscriptionCreate(client *Client, integrationKey
statementActions := []string{"*"}
statements := []ldapi.StatementPost{{
Effect: "allow",
Resources: &statementResources,
Actions: &statementActions,
Resources: statementResources,
Actions: statementActions,
}}
subscriptionBody.Statements = &statements
subscriptionBody.Statements = statements

sub, _, err := client.ld.IntegrationAuditLogSubscriptionsApi.CreateSubscription(client.ctx, integrationKey).SubscriptionPost(subscriptionBody).Execute()
if err != nil {
return nil, fmt.Errorf("failed to create integration subscription for test: %v", handleLdapiErr(err))
}
return &sub, nil
return sub, nil
}

func testAccDataSourceAuditLogSubscriptionDelete(client *Client, integrationKey, id string) error {
8 changes: 4 additions & 4 deletions launchdarkly/data_source_launchdarkly_environment_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -28,13 +28,13 @@ func testAccDataSourceEnvironmentScaffold(client *Client, projectKey string, env
projectBody := ldapi.ProjectPost{
Name: "Env Test Project",
Key: projectKey,
Environments: &[]ldapi.EnvironmentPost{envBody},
Environments: []ldapi.EnvironmentPost{envBody},
}
project, err := testAccDataSourceProjectCreate(client, projectBody)
if err != nil {
return nil, err
}
for _, env := range project.Environments {
for _, env := range project.Environments.Items {
if env.Key == envBody.Key {
return &env, nil
}
@@ -95,7 +95,7 @@ func TestAccDataSourceEnv_exists(t *testing.T) {
Key: envKey,
Color: envColor,
SecureMode: ldapi.PtrBool(true),
Tags: &[]string{
Tags: []string{
"some", "tag",
},
}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -26,7 +26,7 @@ func testAccDataSourceFeatureFlagEnvironmentScaffold(client *Client, projectKey,
flagBody := ldapi.FeatureFlagBody{
Name: "Feature Flag Env Data Source Test",
Key: flagKey,
Variations: &[]ldapi.Variation{
Variations: []ldapi.Variation{
{Value: intfPtr(true)},
{Value: intfPtr(false)},
},
@@ -55,7 +55,7 @@ func testAccDataSourceFeatureFlagEnvironmentScaffold(client *Client, projectKey,
return nil, fmt.Errorf("failed to get feature flag: %s", err.Error())
}

return &flag, nil
return flag, nil
}

func TestAccDataSourceFeatureFlagEnvironment_noMatchReturnsError(t *testing.T) {
4 changes: 2 additions & 2 deletions launchdarkly/data_source_launchdarkly_feature_flag_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -71,7 +71,7 @@ func TestAccDataSourceFeatureFlag_exists(t *testing.T) {
flagBody := ldapi.FeatureFlagBody{
Name: flagName,
Key: flagKey,
Variations: &[]ldapi.Variation{
Variations: []ldapi.Variation{
{Value: intfPtr(true)},
{Value: intfPtr(false)},
},
6 changes: 3 additions & 3 deletions launchdarkly/data_source_launchdarkly_flag_trigger_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -32,7 +32,7 @@ func testAccDataSourceFlagTriggerScaffold(client *Client, projectKey, flagKey st
if err != nil {
return nil, err
}
return &trigger, nil
return trigger, nil
}

func TestAccDataSourceFlagTrigger_noMatchReturnsError(t *testing.T) {
@@ -80,7 +80,7 @@ func TestAccDataSourceFlagTrigger_exists(t *testing.T) {
flagKey := "trigger-test"
instructions := []map[string]interface{}{{"kind": "turnFlagOff"}}
post := ldapi.NewTriggerPost("datadog")
post.Instructions = &instructions
post.Instructions = instructions
trigger, err := testAccDataSourceFlagTriggerScaffold(client, projectKey, flagKey, post)
require.NoError(t, err)

6 changes: 3 additions & 3 deletions launchdarkly/data_source_launchdarkly_metric_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -36,7 +36,7 @@ func testAccDataSourceMetricScaffold(client *Client, projectKey string, metricBo
return nil, err
}

return &metric, nil
return metric, nil
}

func TestAccDataSourceMetric_noMatchReturnsError(t *testing.T) {
@@ -92,7 +92,7 @@ func TestAccDataSourceMetric_exists(t *testing.T) {
Name: &metricName,
Key: metricKey,
Kind: "pageview",
Urls: &[]ldapi.UrlPost{{
Urls: []ldapi.UrlPost{{
Kind: &metricUrlKind,
Substring: &metricUrlSubstring,
}},
8 changes: 4 additions & 4 deletions launchdarkly/data_source_launchdarkly_project_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -64,18 +64,18 @@ func TestAccDataSourceProject_exists(t *testing.T) {
UsingEnvironmentId: false,
UsingMobileKey: false,
},
Tags: &[]string{
Tags: []string{
tag,
},
Environments: &[]ldapi.EnvironmentPost{
Environments: []ldapi.EnvironmentPost{
{
Name: envName,
Key: envKey,
Color: envColor,
SecureMode: ldapi.PtrBool(true),
ConfirmChanges: ldapi.PtrBool(true),
RequireComments: ldapi.PtrBool(true),
Tags: &[]string{
Tags: []string{
tag,
},
},
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -50,9 +50,9 @@ func TestAccDataSourceRelayProxyConfig_exists(t *testing.T) {

name := "test config"
resourceSpec := "proj/*:env/*"
policy := []ldapi.StatementRep{{
Resources: &([]string{resourceSpec}),
Actions: &([]string{"*"}),
policy := []ldapi.Statement{{
Resources: ([]string{resourceSpec}),
Actions: ([]string{"*"}),
Effect: "allow",
}}

@@ -97,9 +97,9 @@ func TestAccDataSourceRelayProxyConfig_NotResource(t *testing.T) {

name := "test config"
resourceSpec := "proj/*:env/*"
policy := []ldapi.StatementRep{{
NotResources: &([]string{resourceSpec}),
Actions: &([]string{"*"}),
policy := []ldapi.Statement{{
NotResources: ([]string{resourceSpec}),
Actions: ([]string{"*"}),
Effect: "allow",
}}

6 changes: 3 additions & 3 deletions launchdarkly/data_source_launchdarkly_segment_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -43,7 +43,7 @@ func testAccDataSourceSegmentCreate(client *Client, projectKey, segmentKey strin
Name: "Data Source Test Segment",
Key: segmentKey,
Description: ldapi.PtrString("test description"),
Tags: &[]string{"terraform"},
Tags: []string{"terraform"},
}
_, _, err = client.ld.SegmentsApi.PostSegment(client.ctx, project.Key, envKey).SegmentBody(segmentBody).Execute()

@@ -64,7 +64,7 @@ func testAccDataSourceSegmentCreate(client *Client, projectKey, segmentKey strin
return nil, fmt.Errorf("failed to update segment %q in project %q: %s", segmentKey, projectKey, handleLdapiErr(err))
}

return &segment, nil
return segment, nil
}

func TestAccDataSourceSegment_noMatchReturnsError(t *testing.T) {
2 changes: 1 addition & 1 deletion launchdarkly/data_source_launchdarkly_team_member.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func memberSchema() map[string]*schema.Schema {
2 changes: 1 addition & 1 deletion launchdarkly/data_source_launchdarkly_team_member_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

2 changes: 1 addition & 1 deletion launchdarkly/data_source_launchdarkly_team_members.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func dataSourceTeamMembers() *schema.Resource {
2 changes: 1 addition & 1 deletion launchdarkly/data_source_launchdarkly_team_members_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

12 changes: 6 additions & 6 deletions launchdarkly/data_source_launchdarkly_webhook_test.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/require"
)

@@ -28,11 +28,11 @@ func testAccDataSourceWebhookCreate(client *Client, webhookName string) (*ldapi.
Sign: false,
On: true,
Name: ldapi.PtrString(webhookName),
Tags: &[]string{"terraform"},
Statements: &[]ldapi.StatementPost{
Tags: []string{"terraform"},
Statements: []ldapi.StatementPost{
{
Resources: &statementResources,
Actions: &statementActions,
Resources: statementResources,
Actions: statementActions,
Effect: "allow",
},
},
@@ -43,7 +43,7 @@ func testAccDataSourceWebhookCreate(client *Client, webhookName string) (*ldapi.
return nil, fmt.Errorf("failed to create webhook with name %q: %s", webhookName, handleLdapiErr(err))
}

return &webhook, nil
return webhook, nil
}

func testAccDataSourceWebhookDelete(client *Client, webhookId string) error {
2 changes: 1 addition & 1 deletion launchdarkly/default_variations_helper.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func defaultVariationsFromResourceData(d *schema.ResourceData) (*ldapi.Defaults, error) {
2 changes: 1 addition & 1 deletion launchdarkly/default_variations_helper_test.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
2 changes: 1 addition & 1 deletion launchdarkly/environments_helper.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

// baseEnvironmentSchema covers the overlap between the data source and resource schemas
2 changes: 1 addition & 1 deletion launchdarkly/environments_helper_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package launchdarkly
import (
"testing"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
2 changes: 1 addition & 1 deletion launchdarkly/fallthrough_helper.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func fallthroughSchema(forDataSource bool) *schema.Schema {
6 changes: 3 additions & 3 deletions launchdarkly/feature_flag_environment_helper.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func baseFeatureFlagEnvironmentSchema(forDataSource bool) map[string]*schema.Schema {
@@ -56,7 +56,7 @@ func baseFeatureFlagEnvironmentSchema(forDataSource bool) map[string]*schema.Sch
}

// get FeatureFlagEnvironment uses a query parameter to get the ldapi.FeatureFlag with only a single environment.
func getFeatureFlagEnvironment(client *Client, projectKey, flagKey, environmentKey string) (ldapi.FeatureFlag, *http.Response, error) {
func getFeatureFlagEnvironment(client *Client, projectKey, flagKey, environmentKey string) (*ldapi.FeatureFlag, *http.Response, error) {
return client.ld.FeatureFlagsApi.GetFeatureFlag(client.ctx, projectKey, flagKey).Env(environmentKey).Execute()
}

@@ -136,7 +136,7 @@ func featureFlagEnvironmentRead(ctx context.Context, d *schema.ResourceData, raw
return diag.Errorf("failed to set targets on flag with key %q: %v", flagKey, err)
}

err = d.Set(FALLTHROUGH, fallthroughToResourceData(environment.Fallthrough))
err = d.Set(FALLTHROUGH, fallthroughToResourceData(*environment.Fallthrough))
if err != nil {
return diag.Errorf("failed to set flag fallthrough on flag with key %q: %v", flagKey, err)
}
2 changes: 1 addition & 1 deletion launchdarkly/feature_flags_helper.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func baseFeatureFlagSchema() map[string]*schema.Schema {
2 changes: 1 addition & 1 deletion launchdarkly/flag_trigger_helper.go
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ func flagTriggerRead(ctx context.Context, d *schema.ResourceData, metaRaw interf
_ = d.Set(ENV_KEY, envKey)
_ = d.Set(FLAG_KEY, flagKey)
_ = d.Set(INTEGRATION_KEY, *trigger.IntegrationKey)
_ = d.Set(INSTRUCTIONS, *trigger.Instructions)
_ = d.Set(INSTRUCTIONS, trigger.Instructions)
_ = d.Set(MAINTAINER_ID, trigger.MaintainerId)
_ = d.Set(ENABLED, trigger.Enabled)
// NOTE: we do not want to set the trigger url at any point past the create as it will always be obscured
4 changes: 2 additions & 2 deletions launchdarkly/helper.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"net/http"
"time"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

var randomRetrySleepSeeded = false
@@ -59,7 +59,7 @@ func handleLdapiErr(err error) error {
if err == nil {
return nil
}
if swaggerErr, ok := err.(ldapi.GenericOpenAPIError); ok {
if swaggerErr, ok := err.(*ldapi.GenericOpenAPIError); ok {
return fmt.Errorf("%s: %s", swaggerErr.Error(), string(swaggerErr.Body()))
}
return err
7 changes: 7 additions & 0 deletions launchdarkly/keys.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ package launchdarkly
const (
//gofmts:sort
ACTIONS = "actions"
ACTION_SET = "action_set"
API_KEY = "api_key"
APPROVAL_SETTINGS = "approval_settings"
ARCHIVED = "archived"
@@ -22,6 +23,7 @@ const (
CREATION_DATE = "creation_date"
CUSTOM_PROPERTIES = "custom_properties"
CUSTOM_ROLES = "custom_roles"
CUSTOM_ROLE_KEYS = "custom_role_keys"
DEFAULTS = "defaults"
DEFAULT_API_VERSION = "default_api_version"
DEFAULT_CLIENT_SIDE_AVAILABILITY = "default_client_side_availability"
@@ -57,7 +59,9 @@ const (
KEY = "key"
KIND = "kind"
LAST_NAME = "last_name"
MAINTAINERS = "maintainers"
MAINTAINER_ID = "maintainer_id"
MEMBER_IDS = "member_ids"
MIN_NUM_APPROVALS = "min_num_approvals"
MOBILE_KEY = "mobile_key"
NAME = "name"
@@ -69,13 +73,16 @@ const (
ON_VARIATION = "on_variation"
OP = "op"
PATTERN = "pattern"
PERMISSION_GRANTS = "permission_grants"
POLICY = "policy"
POLICY_STATEMENTS = "policy_statements"
PREREQUISITES = "prerequisites"
PROJECT_KEY = "project_key"
PROJECT_KEYS = "project_keys"
REQUIRED = "required"
REQUIRED_APPROVAL_TAGS = "required_approval_tags"
REQUIRE_COMMENTS = "require_comments"
RESOURCE = "resource"
RESOURCES = "resources"
ROLE = "role"
ROLLOUT_WEIGHTS = "rollout_weights"
2 changes: 1 addition & 1 deletion launchdarkly/metrics_helper.go
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func baseMetricSchema(isDataSource bool) map[string]*schema.Schema {
10 changes: 5 additions & 5 deletions launchdarkly/policies_helper.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"sort"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func policyArraySchema() *schema.Schema {
@@ -67,8 +67,8 @@ func policyFromResourceData(val interface{}) ldapi.StatementPost {
sort.Strings(statementResources)

p := ldapi.StatementPost{
Resources: &statementResources,
Actions: &statementActions,
Resources: statementResources,
Actions: statementActions,
Effect: policyMap[EFFECT].(string),
}
return p
@@ -101,8 +101,8 @@ func policyHash(val interface{}) int {
// it was creating 3 different hash indices per policy since it was hashing the
// pointer addresses rather than the values themselves
policy := hashStatement{
Resources: *rawPolicy.Resources,
Actions: *rawPolicy.Actions,
Resources: rawPolicy.Resources,
Actions: rawPolicy.Actions,
Effect: rawPolicy.Effect,
}
return schema.HashString(fmt.Sprintf("%v", policy))
32 changes: 16 additions & 16 deletions launchdarkly/policy_statements_helper.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

// policyStatementSchemaOptions is used to help with renaming 'policy_statements' to statements for the launchdarkly_webhook resource.
@@ -137,43 +137,43 @@ func policyStatementFromResourceData(statement map[string]interface{}) (ldapi.St
return ret, nil
}

func policyStatementsToResourceData(statements []ldapi.StatementRep) []interface{} {
func policyStatementsToResourceData(statements []ldapi.Statement) []interface{} {
transformed := make([]interface{}, 0, len(statements))
for _, s := range statements {
t := map[string]interface{}{
EFFECT: s.Effect,
}
if s.Resources != nil && len(*s.Resources) > 0 {
t[RESOURCES] = stringSliceToInterfaceSlice(*s.Resources)
if s.Resources != nil && len(s.Resources) > 0 {
t[RESOURCES] = stringSliceToInterfaceSlice(s.Resources)
}
if s.NotResources != nil && len(*s.NotResources) > 0 {
t[NOT_RESOURCES] = stringSliceToInterfaceSlice(*s.NotResources)
if s.NotResources != nil && len(s.NotResources) > 0 {
t[NOT_RESOURCES] = stringSliceToInterfaceSlice(s.NotResources)
}
if s.Actions != nil && len(*s.Actions) > 0 {
t[ACTIONS] = stringSliceToInterfaceSlice(*s.Actions)
if s.Actions != nil && len(s.Actions) > 0 {
t[ACTIONS] = stringSliceToInterfaceSlice(s.Actions)
}
if s.NotActions != nil && len(*s.NotActions) > 0 {
t[NOT_ACTIONS] = stringSliceToInterfaceSlice(*s.NotActions)
if s.NotActions != nil && len(s.NotActions) > 0 {
t[NOT_ACTIONS] = stringSliceToInterfaceSlice(s.NotActions)
}
transformed = append(transformed, t)
}
return transformed
}

func statementsToStatementReps(policies []ldapi.Statement) []ldapi.StatementRep {
statements := make([]ldapi.StatementRep, 0, len(policies))
func statementsToStatementReps(policies []ldapi.Statement) []ldapi.Statement {
statements := make([]ldapi.Statement, 0, len(policies))
for _, p := range policies {
rep := ldapi.StatementRep(p)
rep := ldapi.Statement(p)
statements = append(statements, rep)
}
return statements
}

// The relay proxy config api requires a statementRep in the POST body
func statementPostsToStatementReps(policies []ldapi.StatementPost) []ldapi.StatementRep {
statements := make([]ldapi.StatementRep, 0, len(policies))
func statementPostsToStatementReps(policies []ldapi.StatementPost) []ldapi.Statement {
statements := make([]ldapi.Statement, 0, len(policies))
for _, p := range policies {
rep := ldapi.StatementRep(p)
rep := ldapi.Statement(p)
statements = append(statements, rep)
}
return statements
22 changes: 11 additions & 11 deletions launchdarkly/policy_statements_helper_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -34,8 +34,8 @@ func TestPolicyStatementsRoundTripConversion(t *testing.T) {
},
expected: []ldapi.StatementPost{
{
Resources: &statementResources,
Actions: &statementActions,
Resources: statementResources,
Actions: statementActions,
Effect: "allow",
},
},
@@ -58,13 +58,13 @@ func TestPolicyStatementsRoundTripConversion(t *testing.T) {
},
expected: []ldapi.StatementPost{
{
Resources: &statementPostResources1,
Actions: &statementPostActions,
Resources: statementPostResources1,
Actions: statementPostActions,
Effect: "allow",
},
{
Resources: &statementPostResources2,
Actions: &statementPostActions,
Resources: statementPostResources2,
Actions: statementPostActions,
Effect: "allow",
},
},
@@ -82,8 +82,8 @@ func TestPolicyStatementsRoundTripConversion(t *testing.T) {
},
expected: []ldapi.StatementPost{
{
NotResources: strArrayPtr([]string{"proj/*:env/production:flag/*"}),
Actions: &statementPostActions,
NotResources: *strArrayPtr([]string{"proj/*:env/production:flag/*"}),
Actions: statementPostActions,
Effect: "allow",
},
},
@@ -101,8 +101,8 @@ func TestPolicyStatementsRoundTripConversion(t *testing.T) {
},
expected: []ldapi.StatementPost{
{
Resources: strArrayPtr([]string{"proj/*:env/production:flag/*"}),
NotActions: &statementPostActions,
Resources: *strArrayPtr([]string{"proj/*:env/production:flag/*"}),
NotActions: statementPostActions,
Effect: "allow",
},
},
2 changes: 1 addition & 1 deletion launchdarkly/prerequisite_helper.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func prerequisitesSchema() *schema.Schema {
14 changes: 10 additions & 4 deletions launchdarkly/project_helper.go
Original file line number Diff line number Diff line change
@@ -4,17 +4,19 @@ import (
"context"
"fmt"
"log"
"net/http"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func projectRead(ctx context.Context, d *schema.ResourceData, meta interface{}, isDataSource bool) diag.Diagnostics {
var diags diag.Diagnostics
client := meta.(*Client)
projectKey := d.Get(KEY).(string)

project, res, err := client.ld.ProjectsApi.GetProject(client.ctx, projectKey).Execute()
project, res, err := getFullProject(client, projectKey)

// return nil error for resource reads but 404 for data source reads
if isStatusNotFound(res) && !isDataSource {
@@ -51,14 +53,14 @@ func projectRead(ctx context.Context, d *schema.ResourceData, meta interface{},
if !isDataSource {
// Convert the returned environment list to a map so we can lookup each environment by key while preserving the
// order defined in the config
envMap := environmentsToResourceDataMap(project.Environments)
envMap := environmentsToResourceDataMap(project.Environments.Items)

// iterate over the environment keys in the order defined by the config and look up the environment returned by
// LD's API
rawEnvs := d.Get(ENVIRONMENTS).([]interface{})

envConfigKeys := rawEnvironmentConfigsToKeyList(rawEnvs)
envAddedMap := make(map[string]bool, len(project.Environments))
envAddedMap := make(map[string]bool, len(project.Environments.Items))
environments := make([]interface{}, 0, len(envConfigKeys))
for _, envKey := range envConfigKeys {
environments = append(environments, envMap[envKey])
@@ -68,7 +70,7 @@ func projectRead(ctx context.Context, d *schema.ResourceData, meta interface{},
// Now add all environments that are not specified in the config.
// This is required in order to successfully import nested environments because rawEnvs is always an empty slice
// durning import, even if nested environments are defined in the config.
for _, env := range project.Environments {
for _, env := range project.Environments.Items {
alreadyAdded := envAddedMap[env.Key]
if !alreadyAdded {
environments = append(environments, envMap[env.Key])
@@ -99,3 +101,7 @@ func projectRead(ctx context.Context, d *schema.ResourceData, meta interface{},

return diags
}

func getFullProject(client *Client, projectKey string) (*ldapi.Project, *http.Response, error) {
return client.ld.ProjectsApi.GetProject(client.ctx, projectKey).Expand("environments").Execute()
}
16 changes: 8 additions & 8 deletions launchdarkly/resource_launchdarkly_access_token.go
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceAccessToken() *schema.Resource {
@@ -151,9 +151,9 @@ func resourceAccessTokenCreate(ctx context.Context, d *schema.ResourceData, meta
for i, cr := range customRolesRaw {
customRoles[i] = cr.(string)
}
accessTokenBody.CustomRoleIds = &customRoles
accessTokenBody.CustomRoleIds = customRoles
} else if len(inlineRoles) > 0 {
accessTokenBody.InlineRole = &inlineRoles
accessTokenBody.InlineRole = inlineRoles
} else if accessTokenRole, ok := d.GetOk(ROLE); ok {
accessTokenBody.Role = ldapi.PtrString(accessTokenRole.(string))
}
@@ -194,8 +194,8 @@ func resourceAccessTokenRead(ctx context.Context, d *schema.ResourceData, metaRa
if accessToken.Role != nil {
_ = d.Set(ROLE, *accessToken.Role)
}
if accessToken.CustomRoleIds != nil && len(*accessToken.CustomRoleIds) > 0 {
customRoleKeys, err := customRoleIDsToKeys(client, *accessToken.CustomRoleIds)
if accessToken.CustomRoleIds != nil && len(accessToken.CustomRoleIds) > 0 {
customRoleKeys, err := customRoleIDsToKeys(client, accessToken.CustomRoleIds)
if err != nil {
return diag.FromErr(err)
}
@@ -205,12 +205,12 @@ func resourceAccessTokenRead(ctx context.Context, d *schema.ResourceData, metaRa
_ = d.Set(DEFAULT_API_VERSION, accessToken.DefaultApiVersion)

policies := accessToken.InlineRole
if policies != nil && len(*policies) > 0 {
if len(policies) > 0 {
policyStatements, _ := policyStatementsFromResourceData(d.Get(POLICY_STATEMENTS).([]interface{}))
if len(policyStatements) > 0 {
err = d.Set(POLICY_STATEMENTS, policyStatementsToResourceData(*policies))
err = d.Set(POLICY_STATEMENTS, policyStatementsToResourceData(policies))
} else {
err = d.Set(INLINE_ROLES, policyStatementsToResourceData(*policies))
err = d.Set(INLINE_ROLES, policyStatementsToResourceData(policies))
}
if err != nil {
return diag.Errorf("could not set policy on access token with id %q: %v", accessTokenID, err)
6 changes: 3 additions & 3 deletions launchdarkly/resource_launchdarkly_audit_log_subscription.go
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceAuditLogSubscription() *schema.Resource {
@@ -46,9 +46,9 @@ func resourceAuditLogSubscriptionCreate(ctx context.Context, d *schema.ResourceD
subscriptionBody := ldapi.SubscriptionPost{
Name: name,
On: &on,
Tags: &tags,
Tags: tags,
Config: config,
Statements: &statements,
Statements: statements,
}

sub, _, err := client.ld.IntegrationAuditLogSubscriptionsApi.CreateSubscription(client.ctx, integrationKey).SubscriptionPost(subscriptionBody).Execute()
2 changes: 1 addition & 1 deletion launchdarkly/resource_launchdarkly_custom_role.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceCustomRole() *schema.Resource {
2 changes: 1 addition & 1 deletion launchdarkly/resource_launchdarkly_destination.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceDestination() *schema.Resource {
6 changes: 3 additions & 3 deletions launchdarkly/resource_launchdarkly_environment.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceEnvironment() *schema.Resource {
@@ -54,7 +54,7 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta
DefaultTtl: &defaultTTL,
SecureMode: &secureMode,
DefaultTrackEvents: &defaultTrackEvents,
Tags: &tags,
Tags: tags,
RequireComments: &requireComments,
ConfirmChanges: &confirmChanges,
}
@@ -157,7 +157,7 @@ func environmentExists(projectKey string, key string, meta *Client) (bool, error
}

func environmentExistsInProject(project ldapi.Project, envKey string) bool {
for _, env := range project.Environments {
for _, env := range project.Environments.Items {
if env.Key == envKey {
return true
}
6 changes: 3 additions & 3 deletions launchdarkly/resource_launchdarkly_feature_flag.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

// We assign a custom diff in cases where the customer has not assigned CSA or IIS in config for a flag in order to respect project level defaults
@@ -121,9 +121,9 @@ func resourceFeatureFlagCreate(ctx context.Context, d *schema.ResourceData, meta
Name: flagName,
Key: key,
Description: &description,
Variations: &variations,
Variations: variations,
Temporary: &temporary,
Tags: &tags,
Tags: tags,
Defaults: defaults,
}

Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceFeatureFlagEnvironment() *schema.Resource {
8 changes: 4 additions & 4 deletions launchdarkly/resource_launchdarkly_flag_trigger.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceFlagTrigger() *schema.Resource {
@@ -36,7 +36,7 @@ func resourceFlagTriggerCreate(ctx context.Context, d *schema.ResourceData, meta
enabled := d.Get(ENABLED).(bool)

triggerBody := ldapi.NewTriggerPost(integrationKey)
triggerBody.Instructions = &instructions
triggerBody.Instructions = instructions

createdTrigger, _, err := client.ld.FlagTriggersApi.CreateTriggerWorkflow(client.ctx, projectKey, envKey, flagKey).TriggerPost(*triggerBody).Execute()
if err != nil {
@@ -56,7 +56,7 @@ func resourceFlagTriggerCreate(ctx context.Context, d *schema.ResourceData, meta
KIND: "disableTrigger",
}}
input := ldapi.FlagTriggerInput{
Instructions: &instructions,
Instructions: instructions,
}

_, _, err = client.ld.FlagTriggersApi.PatchTriggerWorkflow(client.ctx, projectKey, envKey, flagKey, *createdTrigger.Id).FlagTriggerInput(input).Execute()
@@ -94,7 +94,7 @@ func resourceFlagTriggerUpdate(ctx context.Context, d *schema.ResourceData, meta
}
}
input := ldapi.FlagTriggerInput{
Instructions: &instructions,
Instructions: instructions,
}

_, _, err := client.ld.FlagTriggersApi.PatchTriggerWorkflow(client.ctx, projectKey, envKey, flagKey, triggerId).FlagTriggerInput(input).Execute()
6 changes: 3 additions & 3 deletions launchdarkly/resource_launchdarkly_metric.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

// Our required fields for metrics depend on the value of the 'kind' enum.
@@ -152,12 +152,12 @@ func resourceMetricCreate(ctx context.Context, d *schema.ResourceData, metaRaw i
Name: &name,
Key: key,
Description: &description,
Tags: &tags,
Tags: tags,
Kind: kind,
IsActive: &isActive,
IsNumeric: &isNumeric,
Selector: &selector,
Urls: &urls,
Urls: urls,
Unit: &unit,
EventKey: &eventKey,
}
8 changes: 4 additions & 4 deletions launchdarkly/resource_launchdarkly_project.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

// We assign a custom diff in cases where the customer has not assigned a default for CSA or IIS in config
@@ -136,7 +136,7 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, metaRaw
}

if len(envs) > 0 {
projectBody.Environments = &envs
projectBody.Environments = envs
}

_, _, err := client.ld.ProjectsApi.PostProject(client.ctx).ProjectPost(projectBody).Execute()
@@ -207,7 +207,7 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, metaRaw
// Update environments if necessary
oldSchemaEnvList, newSchemaEnvList := d.GetChange(ENVIRONMENTS)
// Get the project so we can see if we need to create any environments or just update existing environments
project, _, err := client.ld.ProjectsApi.GetProject(client.ctx, projectKey).Execute()
project, _, err := getFullProject(client, projectKey)
if err != nil {
return diag.Errorf("failed to load project %q before updating environments: %s", projectKey, handleLdapiErr(err))
}
@@ -228,7 +228,7 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, metaRaw
envKey := envConfig[KEY].(string)
envConfigsForCompare[envKey] = envConfig
// Check if the environment already exists. If it does not exist, create it
exists := environmentExistsInProject(project, envKey)
exists := environmentExistsInProject(*project, envKey)
if !exists {
envPost := environmentPostFromResourceData(env)
_, _, err := client.ld.EnvironmentsApi.PostEnvironment(client.ctx, projectKey).EnvironmentPost(envPost).Execute()
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceRelayProxyConfig() *schema.Resource {
4 changes: 2 additions & 2 deletions launchdarkly/resource_launchdarkly_segment.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceSegment() *schema.Resource {
@@ -67,7 +67,7 @@ func resourceSegmentCreate(ctx context.Context, d *schema.ResourceData, metaRaw
Name: segmentName,
Key: key,
Description: &description,
Tags: &tags,
Tags: tags,
}

_, _, err := client.ld.SegmentsApi.PostSegment(client.ctx, projectKey, envKey).SegmentBody(segment).Execute()
4 changes: 2 additions & 2 deletions launchdarkly/resource_launchdarkly_team_member.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceTeamMember() *schema.Resource {
@@ -79,7 +79,7 @@ func resourceTeamMemberCreate(ctx context.Context, d *schema.ResourceData, metaR
FirstName: &firstName,
LastName: &lastName,
Role: &memberRole,
CustomRoles: &customRoles,
CustomRoles: customRoles,
}

members, _, err := client.ld.AccountMembersApi.PostMembers(client.ctx).NewMemberForm([]ldapi.NewMemberForm{membersBody}).Execute()
4 changes: 2 additions & 2 deletions launchdarkly/resource_launchdarkly_webhook.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func resourceWebhook() *schema.Resource {
@@ -56,7 +56,7 @@ func resourceWebhookCreate(ctx context.Context, d *schema.ResourceData, metaRaw
if err != nil {
return diag.FromErr(err)
}
webhookBody.Statements = &statements
webhookBody.Statements = statements
}

// The sign field isn't returned when GETting a webhook so terraform can't import it properly.
2 changes: 1 addition & 1 deletion launchdarkly/rollout_helper.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func rolloutSchema() *schema.Schema {
2 changes: 1 addition & 1 deletion launchdarkly/rule_helper.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func rulesSchema() *schema.Schema {
2 changes: 1 addition & 1 deletion launchdarkly/segment_rule_helper.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package launchdarkly
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func segmentRulesSchema() *schema.Schema {
2 changes: 1 addition & 1 deletion launchdarkly/segment_rule_helper_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package launchdarkly
import (
"testing"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
2 changes: 1 addition & 1 deletion launchdarkly/target_helper.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"

ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

func targetsSchema() *schema.Schema {
2 changes: 1 addition & 1 deletion launchdarkly/target_helper_test.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package launchdarkly
import (
"testing"

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

10 changes: 6 additions & 4 deletions launchdarkly/test_utils.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package launchdarkly

import (
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

// testAccDataSourceProjectCreate creates a project with the given project parameters
func testAccDataSourceProjectCreate(client *Client, projectBody ldapi.ProjectPost) (*ldapi.Project, error) {
project, _, err := client.ld.ProjectsApi.PostProject(client.ctx).ProjectPost(projectBody).Execute()
_, _, err := client.ld.ProjectsApi.PostProject(client.ctx).ProjectPost(projectBody).Execute()
if err != nil {
return nil, err
}
return &project, nil
project, _, err := client.ld.ProjectsApi.GetProject(client.ctx, projectBody.Key).Expand("environments").Execute()

return project, nil
}

func testAccDataSourceProjectDelete(client *Client, projectKey string) error {
@@ -35,7 +37,7 @@ func testAccDataSourceFeatureFlagScaffold(client *Client, projectKey string, fla
if err != nil {
return nil, err
}
return &flag, nil
return flag, nil

}

2 changes: 1 addition & 1 deletion launchdarkly/variations_helper.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/structure"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
)

const (
2 changes: 1 addition & 1 deletion launchdarkly/variations_helper_test.go
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
ldapi "github.com/launchdarkly/api-client-go/v7"
ldapi "github.com/launchdarkly/api-client-go/v10"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
2 changes: 1 addition & 1 deletion launchdarkly/webhooks_helper.go
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ func webhookRead(ctx context.Context, d *schema.ResourceData, meta interface{},
return diag.Errorf("failed to get webhook with id %q: %s", webhookID, handleLdapiErr(err))
}
if webhook.Statements != nil {
statements := policyStatementsToResourceData(*webhook.Statements)
statements := policyStatementsToResourceData(webhook.Statements)
err = d.Set(STATEMENTS, statements)
if err != nil {
return diag.Errorf("failed to set statements on webhook with id %q: %v", webhookID, err)