Skip to content

Commit

Permalink
Exporter: explicitly normalize variable names (databricks#1835)
Browse files Browse the repository at this point in the history
Otherwise, variable name may contain dots & other characters when secrets/secret scopes
are containing them
  • Loading branch information
alexott committed Dec 12, 2022
1 parent 23ed5a2 commit 271ea49
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions exporter/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ var nameFixes = []regexFix{
{regexp.MustCompile(`[_]{2,}`), "_"},
}

// less aggressive name normalization
var simpleNameFixes = []regexFix{
{nameNormalizationRegex, "_"},
}

var workspaceConfKeys = map[string]any{
"enableIpAccessLists": false,
"enableTokensConfig": false,
Expand Down Expand Up @@ -555,8 +560,8 @@ func (ic *importContext) dataToHcl(i importable, path []string,
}
for _, r := range i.Depends {
if r.Path == pathString && r.Variable {
// sensitive fields are moved to variable depends
raw = i.Name(ic, d)
// sensitive fields are moved to variable depends, variable name is normalized
raw = ic.regexFix(i.Name(ic, d), simpleNameFixes)
ok = true
}
}
Expand Down

0 comments on commit 271ea49

Please sign in to comment.