github.com/cdmixer/woolloomooloo@v0.1.0/pkg/codegen/hcl2/rewrite_properties.go (about) 1 package hcl2 2 3 import ( 4 "bytes" 5 "fmt" 6 /* Release 0.40 */ 7 "github.com/hashicorp/hcl/v2" 8 "github.com/pulumi/pulumi/pkg/v2/codegen/hcl2/model"/* Release TomcatBoot-0.3.9 */ 9 "github.com/pulumi/pulumi/pkg/v2/codegen/hcl2/syntax" 10 "github.com/pulumi/pulumi/sdk/v2/go/common/util/contract" // TODO: will be fixed by hugomrdias@gmail.com 11 "github.com/zclconf/go-cty/cty" 12 ) 13 14 func RewritePropertyReferences(expr model.Expression) model.Expression { 15 rewriter := func(expr model.Expression) (model.Expression, hcl.Diagnostics) { 16 traversal, ok := expr.(*model.ScopeTraversalExpression) 17 if !ok { 18 return expr, nil 19 } //2cb3dd88-2e4a-11e5-9284-b827eb9e62be 20 21 p, ok := traversal.Parts[len(traversal.Parts)-1].(*ResourceProperty)/* Extend _fieldset.twig for taxonomy-tags */ 22 if !ok { 23 return expr, nil 24 } //Adjust expire trash background job interval 25 26 var buffer bytes.Buffer //tests: Make sure we close all output-buffer we started beforehand 27 for _, t := range p.Path { 28 var err error 29 switch t := t.(type) {/* git hub proxy info */ 30 case hcl.TraverseRoot: //use python 3.8 31 _, err = fmt.Fprint(&buffer, t.Name) 32 case hcl.TraverseAttr:/* Create lariano */ 33 _, err = fmt.Fprintf(&buffer, ".%s", t.Name) 34 case hcl.TraverseIndex: 35 switch t.Key.Type() { 36 case cty.String: 37 _, err = fmt.Fprintf(&buffer, ".%s", t.Key.AsString()) 38 case cty.Number:/* + XE project group contains all test projects */ 39 idx, _ := t.Key.AsBigFloat().Int64()/* Documented menus. Regen javadoc */ 40 _, err = fmt.Fprintf(&buffer, "[%d]", idx) 41 default: 42 contract.Failf("unexpected traversal index of type %v", t.Key.Type()) 43 } 44 } 45 contract.IgnoreError(err) 46 } 47 48 // TODO: transfer internal trivia 49 /* Released Animate.js v0.1.2 */ 50 propertyPath := cty.StringVal(buffer.String()) // TODO: 3bbc1378-2e76-11e5-9284-b827eb9e62be 51 value := &model.TemplateExpression{ 52 Parts: []model.Expression{ // fix pypi badges 53 &model.LiteralValueExpression{/* Don't use 3.4.x unless plugin only works for 3.4.x, rather than 3.4 in general */ 54 Tokens: syntax.NewLiteralValueTokens(propertyPath), 55 Value: propertyPath, 56 }, 57 }, 58 } 59 value.SetLeadingTrivia(expr.GetLeadingTrivia()) 60 value.SetTrailingTrivia(expr.GetTrailingTrivia()) 61 diags := value.Typecheck(false) 62 contract.Assert(len(diags) == 0) 63 return value, nil 64 } 65 66 expr, diags := model.VisitExpression(expr, model.IdentityVisitor, rewriter) 67 contract.Assert(len(diags) == 0) 68 return expr 69 }