Skip to content

Commit

Permalink
Print relative variable names for dep variables
Browse files Browse the repository at this point in the history
  • Loading branch information
angrycub committed Oct 24, 2023
1 parent db9f7f8 commit 1880bdf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sdk/pack/variables/variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ func (v *Variable) Equal(ivp *Variable) bool {

func (v *Variable) AsOverrideString(pID pack.ID) string {
var out strings.Builder
out.WriteString(fmt.Sprintf(`# variable "%s"`, v.Name))

fqvn := strings.Join([]string{pID.String(), v.Name.String()}, ".")
b := strings.Split(fqvn, ".")
b = b[1:]
rvn := strings.Join(b, ".")

out.WriteString(fmt.Sprintf(`# variable "%s"`, rvn))
out.WriteByte('\n')
if v.hasDescription {
tmp := "description: " + v.Description
Expand All @@ -100,9 +106,9 @@ func (v *Variable) AsOverrideString(pID pack.ID) string {
}

if v.Value.Equals(v.Default).True() {
out.WriteString(fmt.Sprintf("#\n# %s=%s\n\n", v.Name, printDefault(v.Default)))
out.WriteString(fmt.Sprintf("#\n# %s=%s\n\n", rvn, printDefault(v.Default)))
} else {
out.WriteString(fmt.Sprintf("#\n%s=%s\n\n", v.Name, printDefault(v.Value)))
out.WriteString(fmt.Sprintf("#\n%s=%s\n\n", rvn, printDefault(v.Value)))
}

out.WriteString("\n")
Expand Down

0 comments on commit 1880bdf

Please sign in to comment.