Skip to content

Commit

Permalink
espace "." characters and fix output interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
skarimo committed Apr 5, 2021
1 parent e2c9ecd commit 5ec4747
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions terraformutils/providerwrapper/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (p *ProviderWrapper) GetReadOnlyAttributes(resourceTypes []string) (map[str
for k, v := range obj.Block.Attributes {
if !v.Optional && !v.Required {
if v.Type.IsListType() || v.Type.IsSetType() {
readOnlyAttributes[resourceName] = append(readOnlyAttributes[resourceName], "^"+k+".(.*)")
readOnlyAttributes[resourceName] = append(readOnlyAttributes[resourceName], "^"+k+"\\.(.*)")
} else {
readOnlyAttributes[resourceName] = append(readOnlyAttributes[resourceName], "^"+k+"$")
}
Expand All @@ -124,7 +124,7 @@ func (p *ProviderWrapper) readObjBlocks(block map[string]*configschema.NestedBlo
if parent == "-1" {
readOnlyAttributes = p.readObjBlocks(v.BlockTypes, readOnlyAttributes, k)
} else {
readOnlyAttributes = p.readObjBlocks(v.BlockTypes, readOnlyAttributes, parent+".[0-9]+."+k)
readOnlyAttributes = p.readObjBlocks(v.BlockTypes, readOnlyAttributes, parent+"\\.[0-9]+\\."+k)
}
}
fieldCount := 0
Expand All @@ -134,20 +134,20 @@ func (p *ProviderWrapper) readObjBlocks(block map[string]*configschema.NestedBlo
switch v.Nesting {
case configschema.NestingList:
if parent == "-1" {
readOnlyAttributes = append(readOnlyAttributes, "^"+k+".[0-9]+."+key+"($|\\.[0-9]+|\\.#)")
readOnlyAttributes = append(readOnlyAttributes, "^"+k+"\\.[0-9]+\\."+key+"($|\\.[0-9]+|\\.#)")
} else {
readOnlyAttributes = append(readOnlyAttributes, "^"+parent+".(.*)."+key+"$")
readOnlyAttributes = append(readOnlyAttributes, "^"+parent+"\\.(.*)\\."+key+"$")
}
case configschema.NestingSet:
if parent == "-1" {
readOnlyAttributes = append(readOnlyAttributes, "^"+k+".[0-9]+."+key+"$")
readOnlyAttributes = append(readOnlyAttributes, "^"+k+"\\.[0-9]+\\."+key+"$")
} else {
readOnlyAttributes = append(readOnlyAttributes, "^"+parent+".(.*)."+key+"($|\\.(.*))")
readOnlyAttributes = append(readOnlyAttributes, "^"+parent+"\\.(.*)\\."+key+"($|\\.(.*))")
}
case configschema.NestingMap:
readOnlyAttributes = append(readOnlyAttributes, parent+"."+key)
readOnlyAttributes = append(readOnlyAttributes, parent+"\\."+key)
default:
readOnlyAttributes = append(readOnlyAttributes, parent+"."+key+"$")
readOnlyAttributes = append(readOnlyAttributes, parent+"\\."+key+"$")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions terraformutils/terraformoutput/hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func OutputHclFiles(resources []terraformutils.Resource, provider terraformutils
for i, r := range resources {
outputState := map[string]*terraform.OutputState{}
outputsByResource[r.InstanceInfo.Type+"_"+r.ResourceName+"_"+r.GetIDKey()] = map[string]interface{}{
"value": r.InstanceInfo.Type + "." + r.ResourceName + "." + r.GetIDKey(),
"value": "${" + r.InstanceInfo.Type + "." + r.ResourceName + "." + r.GetIDKey() + "}",
}
outputState[r.InstanceInfo.Type+"_"+r.ResourceName+"_"+r.GetIDKey()] = &terraform.OutputState{
Type: "string",
Expand All @@ -68,7 +68,7 @@ func OutputHclFiles(resources []terraformutils.Resource, provider terraformutils
}
linkKey := r.InstanceInfo.Type + "_" + r.ResourceName + "_" + key
outputsByResource[linkKey] = map[string]interface{}{
"value": r.InstanceInfo.Type + "." + r.ResourceName + "." + key,
"value": "${" + r.InstanceInfo.Type + "." + r.ResourceName + "." + key + "}",
}
outputState[linkKey] = &terraform.OutputState{
Type: "string",
Expand Down

0 comments on commit 5ec4747

Please sign in to comment.