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

chore: Bring latest changes from master into dev branch (includes adopting latest stable SDK version) #2491

Merged
merged 85 commits into from
Aug 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
bfc18aa
doc: Updates `mongodbatlas_global_cluster_config` doc about self-mana…
lantoli Jun 27, 2024
78e6eba
test: Unifies Azure and GCP networking tests (#2371)
lantoli Jun 27, 2024
c647bf2
chore: Updates examples link in index.html.markdown for v1.17.3 release
svc-apix-Bot Jun 27, 2024
1fad9f4
chore: Updates CHANGELOG.md header for v1.17.3 release
svc-apix-Bot Jun 27, 2024
45bc5e5
doc: Updates Terraform Compatibility Matrix documentation (#2370)
svc-apix-Bot Jul 1, 2024
7068f36
use ComposeAggregateTestCheckFunc (#2375)
lantoli Jul 1, 2024
27ca92a
chore: Updates asdf to TF 1.9.0 and compatibility matrix body (#2376)
lantoli Jul 1, 2024
ac3f1fd
fix: stale.yaml gh action (#2379)
andreaangiolillo Jul 1, 2024
31d4381
doc: Updates alert-config examples (#2378)
EspenAlbert Jul 2, 2024
f2078c5
chore: Updates Atlas Go SDK (#2380)
svc-apix-Bot Jul 2, 2024
2b82c1a
chore: Bump github.com/aws/aws-sdk-go from 1.54.8 to 1.54.13 (#2383)
dependabot[bot] Jul 3, 2024
15143f0
chore: Bump amannn/action-semantic-pull-request from 5.5.2 to 5.5.3 (…
dependabot[bot] Jul 3, 2024
d6ac0c8
test: Improves tests for mongodbatlas_search_index (#2384)
lantoli Jul 3, 2024
789f38a
chore: Updates nightly tests to TF 1.9.x (#2386)
lantoli Jul 3, 2024
5dffb29
fix: Emptying cloud_back_schedule "copy_settings" (#2387)
EspenAlbert Jul 4, 2024
7de7e64
chore: Updates CHANGELOG.md for #2387
svc-apix-Bot Jul 4, 2024
2288b94
chore: Updates delete logic for `mongodbatlas_search_deployment` (#2389)
lantoli Jul 4, 2024
76ffb69
refactor: use advanced_cluster instead of cluster (#2392)
EspenAlbert Jul 9, 2024
249a523
fix: Returns error if the analyzers attribute contains unknown fields…
marcosuma Jul 9, 2024
4377ba1
chore: Updates CHANGELOG.md for #2394
svc-apix-Bot Jul 9, 2024
b6cdcbf
chore: Bump github.com/aws/aws-sdk-go from 1.54.13 to 1.54.17 (#2401)
dependabot[bot] Jul 10, 2024
5b551d7
chore: Bump github.com/hashicorp/terraform-plugin-testing (#2400)
dependabot[bot] Jul 10, 2024
6e8a5cd
chore: Bump github.com/hashicorp/terraform-plugin-framework (#2398)
dependabot[bot] Jul 10, 2024
4bc8a07
chore: Bump github.com/hashicorp/terraform-plugin-framework-validator…
dependabot[bot] Jul 10, 2024
ec5424b
test: Uses hclwrite to generate the cluster for GetClusterInfo (#2404)
EspenAlbert Jul 11, 2024
9f78a9e
fix: Fixes `disk_iops` attribute for Azure cloud provider in `mongodb…
lantoli Jul 11, 2024
93733ef
chore: Updates CHANGELOG.md for #2396
svc-apix-Bot Jul 11, 2024
dd7d62b
test: Refactors `mongodbatlas_private_endpoint_regional_mode` to use …
EspenAlbert Jul 12, 2024
c5c5bd7
test: Refactors resource tests to use GetClusterInfo `online_archive`…
EspenAlbert Jul 12, 2024
c2b384b
update .tool-versions (#2417)
lantoli Jul 12, 2024
749292c
feat: Adds `stored_source` attribute to `mongodbatlas_search_index` r…
lantoli Jul 14, 2024
011e6a2
chore: Updates CHANGELOG.md for #2388
svc-apix-Bot Jul 14, 2024
d0c7113
doc: Improves Guides menu (#2408)
lantoli Jul 15, 2024
e2b3a96
test: Refactors resource tests to use GetClusterInfo `ldap_configurat…
EspenAlbert Jul 15, 2024
4c9c392
test: Refactors resource tests to use GetClusterInfo `cloud_backup_sn…
EspenAlbert Jul 15, 2024
c1cb5fd
doc: Clarify usage of maintenance window resource (#2418)
AgustinBettati Jul 15, 2024
3110a52
test: Refactors resource tests to use GetClusterInfo `cloud_backup_sc…
EspenAlbert Jul 15, 2024
6674f82
test: Refactors resource tests to use GetClusterInfo `federated_datab…
EspenAlbert Jul 15, 2024
d1c25f0
doc: Removes docs headers as they are not needed (#2422)
lantoli Jul 15, 2024
35e2a87
test: Refactors resource tests to use GetClusterInfo `backup_complian…
EspenAlbert Jul 16, 2024
3f45cca
test: Refactors resource tests to use GetClusterInfo `cluster_outage_…
EspenAlbert Jul 16, 2024
f9a1809
test: Fixes DUPLICATE_CLUSTER_NAME failures (#2424)
EspenAlbert Jul 16, 2024
fa31ccf
test: Refactors GetClusterInfo (#2426)
EspenAlbert Jul 16, 2024
4e3144c
doc: Updates to new Terraform doc structure (#2425)
lantoli Jul 16, 2024
87ca68d
chore: Bump github.com/zclconf/go-cty from 1.14.4 to 1.15.0 (#2433)
dependabot[bot] Jul 17, 2024
b83c28e
chore: Bump github.com/aws/aws-sdk-go from 1.54.17 to 1.54.19 (#2432)
dependabot[bot] Jul 17, 2024
626a83b
chore: Bump actions/setup-go from 5.0.1 to 5.0.2 (#2431)
dependabot[bot] Jul 17, 2024
fae643d
chore: Bump tj-actions/verify-changed-files (#2430)
dependabot[bot] Jul 17, 2024
bd01af7
refactor: avoid usage of github.com/go-test/deep (use `reflect.DeepEq…
EspenAlbert Jul 17, 2024
214b694
chore: Deletes modules folder (#2435)
lantoli Jul 17, 2024
de0ab51
chore: Makes sure doc generation is up-to-date (#2441)
lantoli Jul 18, 2024
9d5c3ee
chore: Enables GitHub Action linter errors in GitHub (#2440)
lantoli Jul 18, 2024
b4b9109
update version (#2439)
lantoli Jul 18, 2024
5cad7be
doc: Updates examples & docs that use replicaSet clusters (#2428)
lantoli Jul 18, 2024
81ff1eb
fix MongoDB_Atlas (#2445)
lantoli Jul 18, 2024
0163858
chore: Updates examples link in index.md for v1.17.4 release
svc-apix-Bot Jul 19, 2024
b6a562a
chore: Updates CHANGELOG.md header for v1.17.4 release
svc-apix-Bot Jul 19, 2024
27ce0b1
chore: Migrates `mongodbatlas_cloud_backup_snapshot_export_job` to ne…
oarbusi Jul 19, 2024
3de3793
chore: Migrates `mongodbatlas_project_api_key` to new auto-generated …
oarbusi Jul 19, 2024
5578f16
chore: Removes usage of old Admin SDK in tests (#2442)
oarbusi Jul 19, 2024
85d08fc
chore: Updates CHANGELOG.md for #2436
svc-apix-Bot Jul 19, 2024
9831293
chore: Clean up usages of old SDK (#2449)
oarbusi Jul 23, 2024
12433b7
allow 0 (#2456)
lantoli Jul 23, 2024
80dcc2d
fix: Fixes creation of organization (#2462)
oarbusi Jul 29, 2024
7d35739
chore: Updates CHANGELOG.md for #2462
svc-apix-Bot Jul 29, 2024
7fdbae1
fix: Fixes nil pointer dereference in `mongodbatlas_alert_configurati…
oarbusi Jul 30, 2024
8fdf420
chore: Updates CHANGELOG.md for #2463
svc-apix-Bot Jul 30, 2024
b6dadfb
chore: Updates examples link in index.md for v1.17.5 release
svc-apix-Bot Jul 30, 2024
2fe6306
chore: Updates CHANGELOG.md header for v1.17.5 release
svc-apix-Bot Jul 30, 2024
8487a3d
chore: Bump golangci/golangci-lint-action from 6.0.1 to 6.1.0 (#2469)
dependabot[bot] Jul 31, 2024
94371a9
chore: Bump github.com/aws/aws-sdk-go from 1.54.19 to 1.55.5 (#2468)
dependabot[bot] Jul 31, 2024
99e9212
fix: Handles update of `mongodbatlas_backup_compliance_policy` as a c…
oarbusi Aug 7, 2024
8b07220
chore: Updates CHANGELOG.md for #2480
svc-apix-Bot Aug 7, 2024
f9fea40
chore: Updates examples link in index.md for v1.17.6 release
svc-apix-Bot Aug 7, 2024
df074de
chore: Updates CHANGELOG.md header for v1.17.6 release
svc-apix-Bot Aug 7, 2024
f2c7835
feat: Adds azure support for backup snapshot export bucket (#2486)
oarbusi Aug 8, 2024
40a3b9f
chore: Updates CHANGELOG.md for #2486
svc-apix-Bot Aug 8, 2024
2059bf6
chore: Improves backup_compliance_policy test(#2484)
oarbusi Aug 9, 2024
5f715ab
chore: Updates Atlas Go SDK to version 2024-08-05 (#2487)
AgustinBettati Aug 9, 2024
f045058
Merge remote-tracking branch 'origin/master' into CLOUDP-266563
AgustinBettati Aug 9, 2024
1065d78
manual fixes of versions in advanced cluster, cloud backup schedule, …
AgustinBettati Aug 11, 2024
f647db4
fix incorrect merging in cloud backup schedule tests
AgustinBettati Aug 11, 2024
c54da61
using connV2 for import in advanced cluster
AgustinBettati Aug 11, 2024
edb8fbb
use lastest sdk model for tests that require autoscaling model
AgustinBettati Aug 11, 2024
e4a5c2d
avoid using old SDK for delete operation
AgustinBettati Aug 11, 2024
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
Prev Previous commit
Next Next commit
fix: Emptying cloud_back_schedule "copy_settings" (#2387)
* test: add test to reproduce Github Issue

* fix: update copy_settings on changes (even when empty)

* docs: Add changelog entry

* chore: fix changelog entry

* apply review comments
EspenAlbert authored Jul 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5dffb29bce51d777c7b41b9f8198100cdabb033b
3 changes: 3 additions & 0 deletions .changelog/2387.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/mongodbatlas_cloud_backup_schedule: Updates `copy_settings` on changes (even when empty)
```
Original file line number Diff line number Diff line change
@@ -492,9 +492,9 @@ func cloudBackupScheduleCreateOrUpdate(ctx context.Context, connV2 *admin.APICli
}

req := &admin.DiskBackupSnapshotSchedule{}

if v, ok := d.GetOk("copy_settings"); ok && len(v.([]any)) > 0 {
req.CopySettings = expandCopySettings(v.([]any))
copySettings := d.Get("copy_settings")
if copySettings != nil && (conversion.HasElementsSliceOrMap(copySettings) || d.HasChange("copy_settings")) {
req.CopySettings = expandCopySettings(copySettings.([]any))
}

var policiesItem []admin.DiskBackupApiPolicyItem
@@ -642,11 +642,7 @@ func expandCopySetting(tfMap map[string]any) *admin.DiskBackupCopySetting {
}

func expandCopySettings(tfList []any) *[]admin.DiskBackupCopySetting {
if len(tfList) == 0 {
return nil
}

var copySettings []admin.DiskBackupCopySetting
copySettings := make([]admin.DiskBackupCopySetting, 0)

for _, tfMapRaw := range tfList {
tfMap, ok := tfMapRaw.(map[string]any)
Original file line number Diff line number Diff line change
@@ -254,49 +254,66 @@ func TestAccBackupRSCloudBackupSchedule_copySettings(t *testing.T) {
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
checkMap = map[string]string{
"cluster_name": clusterName,
"reference_hour_of_day": "3",
"reference_minute_of_hour": "45",
"restore_window_days": "1",
"policy_item_hourly.#": "1",
"policy_item_daily.#": "1",
"policy_item_weekly.#": "1",
"policy_item_monthly.#": "1",
"policy_item_yearly.#": "1",
"policy_item_hourly.0.frequency_interval": "1",
"policy_item_hourly.0.retention_unit": "days",
"policy_item_hourly.0.retention_value": "1",
"policy_item_daily.0.frequency_interval": "1",
"policy_item_daily.0.retention_unit": "days",
"policy_item_daily.0.retention_value": "2",
"policy_item_weekly.0.frequency_interval": "4",
"policy_item_weekly.0.retention_unit": "weeks",
"policy_item_weekly.0.retention_value": "3",
"policy_item_monthly.0.frequency_interval": "5",
"policy_item_monthly.0.retention_unit": "months",
"policy_item_monthly.0.retention_value": "4",
"policy_item_yearly.0.frequency_interval": "1",
"policy_item_yearly.0.retention_unit": "years",
"policy_item_yearly.0.retention_value": "1",
}
copySettingsChecks = map[string]string{
"copy_settings.#": "1",
"copy_settings.0.cloud_provider": "AWS",
"copy_settings.0.region_name": "US_EAST_1",
"copy_settings.0.should_copy_oplogs": "true",
}
emptyCopySettingsChecks = map[string]string{
"copy_settings.#": "0",
}
)
checksDefault := acc.AddAttrChecks(resourceName, []resource.TestCheckFunc{checkExists(resourceName)}, checkMap)
checksCreate := acc.AddAttrChecks(resourceName, checksDefault, copySettingsChecks)
checksUpdate := acc.AddAttrChecks(resourceName, checksDefault, emptyCopySettingsChecks)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: checkDestroy,
Steps: []resource.TestStep{
{
Config: configCopySettings(projectID, clusterName, &admin.DiskBackupSnapshotSchedule{
Config: configCopySettings(projectID, clusterName, false, &admin.DiskBackupSnapshotSchedule{
ReferenceHourOfDay: conversion.Pointer(3),
ReferenceMinuteOfHour: conversion.Pointer(45),
RestoreWindowDays: conversion.Pointer(1),
}),
Check: resource.ComposeAggregateTestCheckFunc(
checkExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "cluster_name", clusterName),
resource.TestCheckResourceAttr(resourceName, "reference_hour_of_day", "3"),
resource.TestCheckResourceAttr(resourceName, "reference_minute_of_hour", "45"),
resource.TestCheckResourceAttr(resourceName, "restore_window_days", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_hourly.#", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_daily.#", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_weekly.#", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_monthly.#", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_yearly.#", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_hourly.0.frequency_interval", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_hourly.0.retention_unit", "days"),
resource.TestCheckResourceAttr(resourceName, "policy_item_hourly.0.retention_value", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_daily.0.frequency_interval", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_daily.0.retention_unit", "days"),
resource.TestCheckResourceAttr(resourceName, "policy_item_daily.0.retention_value", "2"),
resource.TestCheckResourceAttr(resourceName, "policy_item_weekly.0.frequency_interval", "4"),
resource.TestCheckResourceAttr(resourceName, "policy_item_weekly.0.retention_unit", "weeks"),
resource.TestCheckResourceAttr(resourceName, "policy_item_weekly.0.retention_value", "3"),
resource.TestCheckResourceAttr(resourceName, "policy_item_monthly.0.frequency_interval", "5"),
resource.TestCheckResourceAttr(resourceName, "policy_item_monthly.0.retention_unit", "months"),
resource.TestCheckResourceAttr(resourceName, "policy_item_monthly.0.retention_value", "4"),
resource.TestCheckResourceAttr(resourceName, "policy_item_yearly.0.frequency_interval", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_item_yearly.0.retention_unit", "years"),
resource.TestCheckResourceAttr(resourceName, "policy_item_yearly.0.retention_value", "1"),
resource.TestCheckResourceAttr(resourceName, "copy_settings.0.cloud_provider", "AWS"),
resource.TestCheckResourceAttr(resourceName, "copy_settings.0.region_name", "US_EAST_1"),
resource.TestCheckResourceAttr(resourceName, "copy_settings.0.should_copy_oplogs", "true"),
),
Check: resource.ComposeAggregateTestCheckFunc(checksCreate...),
},
{
Config: configCopySettings(projectID, clusterName, true, &admin.DiskBackupSnapshotSchedule{
ReferenceHourOfDay: conversion.Pointer(3),
ReferenceMinuteOfHour: conversion.Pointer(45),
RestoreWindowDays: conversion.Pointer(1),
}),
Check: resource.ComposeAggregateTestCheckFunc(checksUpdate...),
},
},
})
@@ -507,7 +524,23 @@ func configDefault(info *acc.ClusterInfo, p *admin.DiskBackupSnapshotSchedule) s
`, info.ClusterNameStr, info.ProjectIDStr, p.GetReferenceHourOfDay(), p.GetReferenceMinuteOfHour(), p.GetRestoreWindowDays())
}

func configCopySettings(projectID, clusterName string, p *admin.DiskBackupSnapshotSchedule) string {
func configCopySettings(projectID, clusterName string, emptyCopySettings bool, p *admin.DiskBackupSnapshotSchedule) string {
var copySettings string
if !emptyCopySettings {
copySettings = `
copy_settings {
cloud_provider = "AWS"
frequencies = ["HOURLY",
"DAILY",
"WEEKLY",
"MONTHLY",
"YEARLY",
"ON_DEMAND"]
region_name = "US_EAST_1"
replication_spec_id = mongodbatlas_cluster.my_cluster.replication_specs.*.id[0]
should_copy_oplogs = true
}`
}
return fmt.Sprintf(`
resource "mongodbatlas_cluster" "my_cluster" {
project_id = %[1]q
@@ -564,20 +597,9 @@ func configCopySettings(projectID, clusterName string, p *admin.DiskBackupSnapsh
retention_unit = "years"
retention_value = 1
}
copy_settings {
cloud_provider = "AWS"
frequencies = ["HOURLY",
"DAILY",
"WEEKLY",
"MONTHLY",
"YEARLY",
"ON_DEMAND"]
region_name = "US_EAST_1"
replication_spec_id = mongodbatlas_cluster.my_cluster.replication_specs.*.id[0]
should_copy_oplogs = true
}
%s
}
`, projectID, clusterName, p.GetReferenceHourOfDay(), p.GetReferenceMinuteOfHour(), p.GetRestoreWindowDays())
`, projectID, clusterName, p.GetReferenceHourOfDay(), p.GetReferenceMinuteOfHour(), p.GetRestoreWindowDays(), copySettings)
}

func configOnePolicy(info *acc.ClusterInfo, p *admin.DiskBackupSnapshotSchedule) string {