@@ -3898,7 +3898,7 @@ resource "test_resource" "test" {
38983898
38993899 tfdiags .AssertDiagnosticsMatch (t , diags , tfdiags.Diagnostics {}.Append (& hcl.Diagnostic {
39003900 Severity : hcl .DiagWarning ,
3901- Summary : "Deprecated value used as for_each argument " ,
3901+ Summary : "Deprecated value used" ,
39023902 Detail : "Please stop using this" ,
39033903 Subject : & hcl.Range {
39043904 Filename : filepath .Join (m .Module .SourceDir , "main.tf" ),
@@ -3907,7 +3907,7 @@ resource "test_resource" "test" {
39073907 },
39083908 }).Append (& hcl.Diagnostic {
39093909 Severity : hcl .DiagWarning ,
3910- Summary : "Deprecated value used as for_each argument " ,
3910+ Summary : "Deprecated value used" ,
39113911 Detail : "Please stop using this" ,
39123912 Subject : & hcl.Range {
39133913 Filename : filepath .Join (m .Module .SourceDir , "main.tf" ),
@@ -3968,7 +3968,7 @@ resource "test_resource" "test" {
39683968
39693969 tfdiags .AssertDiagnosticsMatch (t , diags , tfdiags.Diagnostics {}.Append (& hcl.Diagnostic {
39703970 Severity : hcl .DiagWarning ,
3971- Summary : "Deprecated value used as count argument " ,
3971+ Summary : "Deprecated value used" ,
39723972 Detail : "Please stop using this" ,
39733973 Subject : & hcl.Range {
39743974 Filename : filepath .Join (m .Module .SourceDir , "main.tf" ),
@@ -3977,7 +3977,7 @@ resource "test_resource" "test" {
39773977 },
39783978 }).Append (& hcl.Diagnostic {
39793979 Severity : hcl .DiagWarning ,
3980- Summary : "Deprecated value used as count argument " ,
3980+ Summary : "Deprecated value used" ,
39813981 Detail : "Please stop using this" ,
39823982 Subject : & hcl.Range {
39833983 Filename : filepath .Join (m .Module .SourceDir , "main.tf" ),
@@ -4522,3 +4522,132 @@ output "test_output" {
45224522 },
45234523 }))
45244524}
4525+
4526+ func TestContext2Validate_ignoring_nested_module_deprecations (t * testing.T ) {
4527+ m := testModuleInline (t , map [string ]string {
4528+ "mod/main.tf" : `
4529+ output "old" {
4530+ deprecated = "Please stop using this"
4531+ value = "old"
4532+ }
4533+
4534+ module "nested" {
4535+ source = "./nested"
4536+ }
4537+
4538+ locals {
4539+ foo = module.nested.old # WARNING (if not muted)
4540+ }
4541+ ` ,
4542+ "mod/nested/main.tf" : `
4543+ output "old" {
4544+ deprecated = "Please stop using this nested output"
4545+ value = "old"
4546+ }
4547+
4548+ module "deeper" {
4549+ source = "./deeper"
4550+ }
4551+
4552+ locals {
4553+ bar = module.deeper.old # WARNING (if not muted)
4554+ }
4555+ ` ,
4556+ "mod/nested/deeper/main.tf" : `
4557+ output "old" {
4558+ deprecated = "Please stop using this deeply nested output"
4559+ value = "old"
4560+ }
4561+ ` ,
4562+ "main.tf" : `
4563+ module "normal" {
4564+ source = "./mod"
4565+ }
4566+
4567+ module "silenced" {
4568+ source = "./mod"
4569+
4570+ # We don't want deprecations within this module call
4571+ ignore_nested_deprecations = true
4572+ }
4573+
4574+ # We want to still have deprecation warnings within our control surface
4575+ locals {
4576+ using_normal_old = module.normal.old # WARNING
4577+ using_silenced_old = module.silenced.old # WARNING
4578+ }
4579+ ` ,
4580+ })
4581+
4582+ p := new (testing_provider.MockProvider )
4583+ p .GetProviderSchemaResponse = getProviderSchemaResponseFromProviderSchema (& providerSchema {
4584+ ResourceTypes : map [string ]* configschema.Block {
4585+ "test_resource" : {
4586+ Attributes : map [string ]* configschema.Attribute {
4587+ "attr" : {
4588+ Type : cty .String ,
4589+ Computed : true ,
4590+ },
4591+ },
4592+ },
4593+ },
4594+ Actions : map [string ]* providers.ActionSchema {
4595+ "test_action" : {
4596+ ConfigSchema : & configschema.Block {
4597+ Attributes : map [string ]* configschema.Attribute {
4598+ "attr" : {
4599+ Type : cty .String ,
4600+ Required : true ,
4601+ },
4602+ },
4603+ },
4604+ },
4605+ },
4606+ })
4607+
4608+ ctx := testContext2 (t , & ContextOpts {
4609+ Providers : map [addrs.Provider ]providers.Factory {
4610+ addrs .NewDefaultProvider ("test" ): testProviderFuncFixed (p ),
4611+ },
4612+ })
4613+
4614+ diags := ctx .Validate (m , & ValidateOpts {})
4615+
4616+ tfdiags .AssertDiagnosticsMatch (t , diags , tfdiags.Diagnostics {}.Append (& hcl.Diagnostic {
4617+ Severity : hcl .DiagWarning ,
4618+ Summary : "Deprecated value used" ,
4619+ Detail : "Please stop using this" ,
4620+ Subject : & hcl.Range {
4621+ Filename : filepath .Join (m .Module .SourceDir , "main.tf" ),
4622+ Start : hcl.Pos {Line : 15 , Column : 22 , Byte : 285 },
4623+ End : hcl.Pos {Line : 15 , Column : 39 , Byte : 302 },
4624+ },
4625+ }).Append (& hcl.Diagnostic {
4626+ Severity : hcl .DiagWarning ,
4627+ Summary : "Deprecated value used" ,
4628+ Detail : "Please stop using this" ,
4629+ Subject : & hcl.Range {
4630+ Filename : filepath .Join (m .Module .SourceDir , "main.tf" ),
4631+ Start : hcl.Pos {Line : 16 , Column : 24 , Byte : 336 },
4632+ End : hcl.Pos {Line : 16 , Column : 43 , Byte : 355 },
4633+ },
4634+ }).Append (& hcl.Diagnostic {
4635+ Severity : hcl .DiagWarning ,
4636+ Summary : "Deprecated value used" ,
4637+ Detail : "Please stop using this nested output" ,
4638+ Subject : & hcl.Range {
4639+ Filename : filepath .Join (m .Module .SourceDir , "mod" , "main.tf" ),
4640+ Start : hcl.Pos {Line : 12 , Column : 9 , Byte : 141 },
4641+ End : hcl.Pos {Line : 12 , Column : 26 , Byte : 158 },
4642+ },
4643+ }).Append (& hcl.Diagnostic {
4644+ Severity : hcl .DiagWarning ,
4645+ Summary : "Deprecated value used" ,
4646+ Detail : "Please stop using this deeply nested output" ,
4647+ Subject : & hcl.Range {
4648+ Filename : filepath .Join (m .Module .SourceDir , "mod" , "nested" , "main.tf" ),
4649+ Start : hcl.Pos {Line : 12 , Column : 9 , Byte : 155 },
4650+ End : hcl.Pos {Line : 12 , Column : 26 , Byte : 172 },
4651+ },
4652+ }))
4653+ }
0 commit comments