Skip to content

Commit

Permalink
Rename template class for steps which take values
Browse files Browse the repository at this point in the history
Signed-off-by: Hannes Hörl <[email protected]>
  • Loading branch information
Hannes Hörl committed Mar 15, 2024
1 parent 4950d28 commit 4eed172
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions pkg/packageinstall/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type (

const (
// anything that can take values
stepClassValueable stepClass = "valueable"
stepClassTakesValues stepClass = "takesValues"
// only helm template steps
stepClassHelm stepClass = "helm"
// only ytt template steps
Expand All @@ -150,13 +150,13 @@ func (p *templateStepsPatcher) classifySteps() {
classes := stepClasses{}

if step.HelmTemplate != nil {
classes.Insert(stepClassHelm, stepClassValueable)
classes.Insert(stepClassHelm, stepClassTakesValues)
}
if step.Ytt != nil {
classes.Insert(stepClassYtt, stepClassValueable)
classes.Insert(stepClassYtt, stepClassTakesValues)
}
if step.Cue != nil {
classes.Insert(stepClassCue, stepClassValueable)
classes.Insert(stepClassCue, stepClassTakesValues)
}

p.classifiedSteps[i] = classes
Expand Down Expand Up @@ -213,11 +213,11 @@ func (p *templateStepsPatcher) patch() error {
return nil
}

// patchFromValues patches all 'valueable' template steps with values from the
// packageInstall
// patchFromValues patches all template steps that take values with values from
// the packageInstall
func (p *templateStepsPatcher) patchFromValues() error {
for _, values := range p.values {
stepIdxs, err := p.defaultStepIdxs(values.TemplateSteps, stepClassValueable)
stepIdxs, err := p.defaultStepIdxs(values.TemplateSteps, stepClassTakesValues)
if err != nil {
return err
}
Expand All @@ -226,7 +226,7 @@ func (p *templateStepsPatcher) patchFromValues() error {
if stepIdx < 0 || stepIdx >= len(p.templateSteps) {
return fmt.Errorf("template step %d out of range", stepIdx)
}
if !p.stepHasClass(stepIdx, stepClassValueable) {
if !p.stepHasClass(stepIdx, stepClassTakesValues) {
return fmt.Errorf("template step %d does not support values", stepIdx)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/packageinstall/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func TestAppPackageIntallValuesForTemplateSteps(t *testing.T) {
},
exepectedErrMsg: "does not support values",
},
"some values, but no valueable step": {
"some values, but no steps which takes values": {
values: []pkgingv1alpha1.PackageInstallValues{
{SecretRef: &pkgingv1alpha1.PackageInstallValuesSecretRef{Name: "foo-bar"}},
},
Expand All @@ -412,7 +412,7 @@ func TestAppPackageIntallValuesForTemplateSteps(t *testing.T) {
{Sops: &kcv1alpha1.AppTemplateSops{}},
}
},
exepectedErrMsg: "no template step of class 'valueable' found",
exepectedErrMsg: "no template step of class 'takesValues' found",
},
"values for specific steps": {
values: []pkgingv1alpha1.PackageInstallValues{
Expand Down

0 comments on commit 4eed172

Please sign in to comment.