File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
templates/tgc_next/cai2hcl Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ mutex: 'customMetric/{{project}}'
3232import_format :
3333 - ' {{name}}'
3434 - ' {{project}} {{name}}'
35+ include_in_tgc_next_DO_NOT_USE : true
36+ tgc_include_handwritten_tests : true
3537timeouts :
3638 insert_minutes : 20
3739 update_minutes : 20
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import (
2121 " reflect"
2222 " regexp"
2323 " strings"
24+ " crypto/sha256"
25+ " encoding/hex"
2426
2527{{/* We list all the v2 imports here and unstable imports, because we run 'goimports' to guess the correct
2628 set of imports, which will never guess the major version correctly. */ -}}
@@ -111,8 +113,12 @@ func (c *{{ $.ResourceName -}}Cai2hclConverter) convertResourceData(asset caiass
111113
112114 hclBlockName := assetNameParts[len (assetNameParts)-1]
113115 digitRegex := regexp.MustCompile (` ^\d+$` )
114- if digitRegex.MatchString (hclBlockName) {
115- hclBlockName = fmt.Sprintf (" resource%s " , utils.RandString (8))
116+ nameValidator := regexp.MustCompile (" ^[a-zA-Z_][a-zA-Z0-9_-]*$" )
117+ if digitRegex.MatchString (hclBlockName) || !nameValidator.MatchString (hclBlockName) {
118+ hasher := sha256.New ()
119+ hasher.Write ([]byte(hclBlockName))
120+ fullHash := hex.EncodeToString (hasher.Sum (nil ))
121+ hclBlockName = fmt.Sprintf (" resource%s " , fullHash[:8])
116122 }
117123 hclData := make(map[string]interface{})
118124
You can’t perform that action at this time.
0 commit comments