Skip to content

Commit be63033

Browse files
drich10claude
andcommitted
fix(carvel): address PR review comments on structured variable declarations
- Fix indentation of Variables[0] assertions to match surrounding 5-tab style - Add Options assertions (common_name, is_ca) to verify round-trip fidelity of the full variable definition including nested options block - Refactor validateVariables to use errors.Join so all malformed entries are reported in a single error instead of failing on the first one - Fix pre-existing AfterEach indentation so gofmt is clean Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0cbe74e commit be63033

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

internal/carvel/baker.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,16 @@ func (b *baker) progress(message string) {
255255
_, _ = fmt.Fprintln(b.progressWriter, message)
256256
}
257257

258-
// validateVariables checks that each variable declaration has the required name and type fields.
259258
func validateVariables(vars []proofing.Variable) error {
259+
var errs []error
260260
for i, v := range vars {
261261
if v.Name == "" {
262-
return fmt.Errorf("variables[%d]: missing required field 'name'", i)
263-
}
264-
if v.Type == "" {
265-
return fmt.Errorf("variables[%d] (%q): missing required field 'type'", i, v.Name)
262+
errs = append(errs, fmt.Errorf("variables[%d]: missing required field 'name'", i))
263+
} else if v.Type == "" {
264+
errs = append(errs, fmt.Errorf("variables[%d] (%q): missing required field 'type'", i, v.Name))
266265
}
267266
}
268-
return nil
267+
return errors.Join(errs...)
269268
}
270269

271270
func (b *baker) generateBoshReleaseDir() error {

internal/carvel/baker_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ var _ = Describe("Carvel Baker", func() {
141141
subject = NewBaker()
142142
subject.SetWriter(GinkgoWriter)
143143
})
144-
AfterEach(func() {
145-
// Clean up the temp directory
146-
if inputPath != "" {
147-
_ = os.RemoveAll(filepath.Dir(inputPath))
148-
}
149-
})
144+
AfterEach(func() {
145+
// Clean up the temp directory
146+
if inputPath != "" {
147+
_ = os.RemoveAll(filepath.Dir(inputPath))
148+
}
149+
})
150150
JustBeforeEach(func() {
151151
err = subject.Bake(inputPath)
152152
})
@@ -171,8 +171,10 @@ var _ = Describe("Carvel Baker", func() {
171171
Expect(outMeta.PropertyBlueprints).To(HaveLen(2))
172172
Expect(outMeta.FormTypes).To(HaveLen(1))
173173
Expect(outMeta.Variables).To(HaveLen(1))
174-
Expect(outMeta.Variables[0].Name).To(Equal("sample-tile-ca"))
175-
Expect(outMeta.Variables[0].Type).To(Equal("certificate"))
174+
Expect(outMeta.Variables[0].Name).To(Equal("sample-tile-ca"))
175+
Expect(outMeta.Variables[0].Type).To(Equal("certificate"))
176+
Expect(outMeta.Variables[0].Options).To(HaveKeyWithValue("common_name", "Sample Tile CA"))
177+
Expect(outMeta.Variables[0].Options).To(HaveKeyWithValue("is_ca", true))
176178
Expect(outMeta.Releases).To(HaveLen(1))
177179
Expect(outMeta.Releases[0]).To(ContainSubstring("k8s-tile-test"))
178180
Expect(outMeta.InstanceGroups).To(HaveLen(0))

0 commit comments

Comments
 (0)