Skip to content

Commit

Permalink
Use const as blueprint validate message (#1341)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
viveksinghggits and mergify[bot] committed Mar 30, 2022
1 parent 5922089 commit 32b5b30
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/blueprint/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"github.com/pkg/errors"
)

const (
BPValidationErr = "Failed to validate"
)

// Do takes a blueprint and validates if the function names in phases are correct
// and all the required arguments for the kanister functions are provided. This doesn't
// check anything with template params yet.
Expand All @@ -34,14 +38,14 @@ func Do(bp *crv1alpha1.Blueprint, funcVersion string) error {
phases, err := kanister.GetPhases(*bp, name, funcVersion, param.TemplateParams{})
if err != nil {
utils.PrintStage(fmt.Sprintf("validation of action %s", name), utils.Fail)
return errors.Wrapf(err, "Failed to validate action %s", name)
return errors.Wrapf(err, "%s action %s", BPValidationErr, name)
}

for i, phase := range phases {
// validate function's mandatory arguments
if err := phase.Validate(action.Phases[i].Args); err != nil {
utils.PrintStage(fmt.Sprintf("validation of phase %s in action %s", phase.Name(), name), utils.Fail)
return errors.Wrapf(err, "Failed to validate phase %s in action %s", phase.Name(), name)
return errors.Wrapf(err, "%s phase %s in action %s", BPValidationErr, phase.Name(), name)
}
utils.PrintStage(fmt.Sprintf("validation of phase %s in action %s", phase.Name(), name), utils.Pass)
}
Expand Down

0 comments on commit 32b5b30

Please sign in to comment.