Skip to content

Commit

Permalink
Added nil check for extra tf files
Browse files Browse the repository at this point in the history
  • Loading branch information
juliosueiras committed Sep 18, 2019
1 parent 5ac14b3 commit 0ec230e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tfstructs/diags.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ func GetDiagnostics(fileName string, originalFile string) []lsp.Diagnostic {

resourceTypes := map[string]map[string]cty.Value{}

for _, v := range extra.ManagedResources {
if resourceTypes[v.Type] == nil {
resourceTypes[v.Type] = map[string]cty.Value{}
}
if extra != nil {
for _, v := range extra.ManagedResources {
if resourceTypes[v.Type] == nil {
resourceTypes[v.Type] = map[string]cty.Value{}
}

resourceTypes[v.Type][v.Name] = cty.DynamicVal
resourceTypes[v.Type][v.Name] = cty.DynamicVal
}
}

for _, v := range cfg.ManagedResources {
Expand All @@ -80,12 +82,14 @@ func GetDiagnostics(fileName string, originalFile string) []lsp.Diagnostic {

dataTypes := map[string]map[string]cty.Value{}

for _, v := range extra.DataResources {
if dataTypes[v.Type] == nil {
dataTypes[v.Type] = map[string]cty.Value{}
}
if extra != nil {
for _, v := range extra.DataResources {
if dataTypes[v.Type] == nil {
dataTypes[v.Type] = map[string]cty.Value{}
}

dataTypes[v.Type][v.Name] = cty.DynamicVal
dataTypes[v.Type][v.Name] = cty.DynamicVal
}
}

for _, v := range cfg.DataResources {
Expand Down

0 comments on commit 0ec230e

Please sign in to comment.