From b426f5bac9ed1514ba0c0d6d2c637ae2056cc6ab Mon Sep 17 00:00:00 2001 From: Charlie Voiselle <464492+angrycub@users.noreply.github.com> Date: Wed, 25 Oct 2023 09:33:09 -0400 Subject: [PATCH] [generate] Print relative variable names for dep variables (#450) * Print relative variable names for dep variables * Use strings.Cut Co-authored-by: Piotr Kazmierczak <470696+pkazmierczak@users.noreply.github.com> --- sdk/pack/variables/variables.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sdk/pack/variables/variables.go b/sdk/pack/variables/variables.go index 07e100e4..b8f81a7c 100644 --- a/sdk/pack/variables/variables.go +++ b/sdk/pack/variables/variables.go @@ -78,7 +78,11 @@ 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()}, ".") + _, rvn, _ := strings.Cut(fqvn, ".") + + out.WriteString(fmt.Sprintf(`# variable "%s"`, rvn)) out.WriteByte('\n') if v.hasDescription { tmp := "description: " + v.Description @@ -100,9 +104,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")