Refactor Step validation to implement apis.Validatable.#8717
Conversation
|
The following is the coverage report on the affected files.
|
|
@twoGiants: PR needs rebase :p |
Yes sir! Is in the works and will open a couple more soon 😸 |
Add `StepList` with a `Validate` method and implement a `Validate` method on `Step`. Move up check for duplicated Step names into `StepList.Validate` to be consistent with the check for duplicated Task names in `pipeline_validation.go`. Issue tektoncd#8700. Signed-off-by: Stanislav Jakuschevskij <stas@two-giants.com>
70c4547 to
b88b80f
Compare
|
/kind cleanup You can take a look, it's ready @waveywaves. Thank you 😸 Next will be PRs with batches of moved and renamed tests. |
| errs = errs.Also(errorIfStepResultReferencedInField(s.Image, "image")) | ||
| errs = errs.Also(errorIfStepResultReferencedInField(s.Script, "script")) | ||
| errs = errs.Also(errorIfStepResultReferencedInField(string(s.ImagePullPolicy), "imagePullPoliicy")) | ||
| errs = errs.Also(errorIfStepResultReferencedInField(string(s.ImagePullPolicy), "imagePullPolicy")) |
There was a problem hiding this comment.
you're finding a lot of typos hahaha
| } | ||
|
|
||
| errs = errs.Also(validateSteps(ctx, mergedSteps).ViaField("steps")) | ||
| errs = errs.Also(StepList(mergedSteps).Validate(ctx).ViaField("steps")) |
There was a problem hiding this comment.
why does it feel like I have already reviewed this 🤔
There was a problem hiding this comment.
Probably because its similar to the sidecar Validatable refactoring in #8710. It's basically the same but for the Step :).
There was a problem hiding this comment.
ah yess, thank you for sharing
|
|
||
| func validateStep(ctx context.Context, s Step, names sets.String) (errs *apis.FieldError) { | ||
| // Validate implements apis.Validatable | ||
| func (s *Step) Validate(ctx context.Context) (errs *apis.FieldError) { |
|
The following is the coverage report on the affected files.
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vdemeester, waveywaves The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changes
As a follow up to #8685 in this small PR the
Stepvalidation is refactored to align with the pattern used inpipeline_validation.go, task_validation.go, result_validation.go, etc.meaning implementing theapis.Validatableinterface and using a custom type for a list ofStepnamelyStepList.Now that the
Stepvalidation has a publicValidateAPI, the tests can be moved fromtask_validation_test.gotocontainer_validation_test.go.Issue #8700.
/kind cleanup
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
/kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes