Skip to content

Commit 283b9bb

Browse files
authored
tflint: Add IncludeNotCreated option to GetModuleContent (#160)
1 parent 200b0a9 commit 283b9bb

File tree

6 files changed

+262
-240
lines changed

6 files changed

+262
-240
lines changed

plugin/fromproto/fromproto.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ func GetModuleContentOption(opts *proto.GetModuleContent_Option) tflint.GetModul
190190
}
191191

192192
return tflint.GetModuleContentOption{
193-
ModuleCtx: ModuleCtxType(opts.ModuleCtx),
194-
Hint: GetModuleContentHint(opts.Hint),
193+
ModuleCtx: ModuleCtxType(opts.ModuleCtx),
194+
IncludeNotCreated: opts.IncludeNotCreated,
195+
Hint: GetModuleContentHint(opts.Hint),
195196
}
196197
}
197198

plugin/plugin2host/plugin2host_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,9 @@ resource "aws_instance" "foo" {
388388
Name: "get content with options",
389389
Args: func() (*hclext.BodySchema, *tflint.GetModuleContentOption) {
390390
return &hclext.BodySchema{}, &tflint.GetModuleContentOption{
391-
ModuleCtx: tflint.RootModuleCtxType,
392-
Hint: tflint.GetModuleContentHint{ResourceType: "aws_instance"},
391+
ModuleCtx: tflint.RootModuleCtxType,
392+
IncludeNotCreated: true,
393+
Hint: tflint.GetModuleContentHint{ResourceType: "aws_instance"},
393394
}
394395
},
395396
ServerImpl: func(schema *hclext.BodySchema, opts tflint.GetModuleContentOption) (*hclext.BodyContent, hcl.Diagnostics) {
@@ -398,6 +399,11 @@ resource "aws_instance" "foo" {
398399
&hcl.Diagnostic{Severity: hcl.DiagError, Summary: "unexpected moduleCtx options"},
399400
}
400401
}
402+
if !opts.IncludeNotCreated {
403+
return &hclext.BodyContent{}, hcl.Diagnostics{
404+
&hcl.Diagnostic{Severity: hcl.DiagError, Summary: "unexpected includeNotCreatedResources options"},
405+
}
406+
}
401407
if opts.Hint.ResourceType != "aws_instance" {
402408
return &hclext.BodyContent{}, hcl.Diagnostics{
403409
&hcl.Diagnostic{Severity: hcl.DiagError, Summary: "unexpected hint options"},

0 commit comments

Comments
 (0)