-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Refactor Step validation to implement apis.Validatable. #8717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 <[email protected]>
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.Name, "name")) | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're finding a lot of typos hahaha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a code spell checker installed 😁 😎
@@ -87,7 +87,7 @@ func (ts *TaskSpec) Validate(ctx context.Context) (errs *apis.FieldError) { | |||
}) | |||
} | |||
|
|||
errs = errs.Also(validateSteps(ctx, mergedSteps).ViaField("steps")) | |||
errs = errs.Also(StepList(mergedSteps).Validate(ctx).ViaField("steps")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does it feel like I have already reviewed this 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is a better link to the same line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yess, thank you for sharing
@@ -104,7 +103,8 @@ func RefNameLikeUrl(name string) error { | |||
return nil | |||
} | |||
|
|||
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
The following is the coverage report on the affected files.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[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
Needs 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
Step
validation is refactored to align with the pattern used inpipeline_validation.go, task_validation.go, result_validation.go, etc.
meaning implementing theapis.Validatable
interface and using a custom type for a list ofStep
namelyStepList
.Now that the
Step
validation has a publicValidate
API, the tests can be moved fromtask_validation_test.go
tocontainer_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