-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Move Steps and Sidecars validation to container_validation.go
.
#8685
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
Move Steps and Sidecars validation to container_validation.go
.
#8685
Conversation
container_validation.go
.
The following is the coverage report on the affected files.
|
container_validation.go
.container_validation.go
.
|
||
// Validate ensures that a supplied Ref field is populated | ||
// correctly. No errors are returned for a nil Ref. | ||
func (ref *Ref) 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.
do the tests have to be moved as well ?
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.
Great that you bring it up! I checked the tests before opening the PR and wanted to move them but kept them where there are. So here why.
Ref.Validate
tests are already in container_valitation_test.go, so nothing to move here.validateSteps
does not have a "direct" test, it's private, it's called inTaskSpec.Validate
in task_validation.go:91 and is tested viaTaskSpec.Validate
here and here and here and in more test functions. That would be a lot of moving and we would either have to changevalidationSteps
to a public function or the container_validation_tests.go to package scoped tests, which are changes I assumed you probably don't want in this PR and not without more thinking.- I proposed in the working group to do a refactoring of
validationSteps
to the same style you have in Task and Pipeline by implementingapis.Validatable
and add aValidate
method onStep
and create a new typeTaskStepList
, similar toPipelineTaskList
with its ownValidate
method, in short to align thevalidateSteps
implementation with Task and Pipeline validation. Then some tests can be moved to container_validation_test.go and run against the publicValidate
method on Step. - My proposal was accepted and @binkkatal was so nice to offer to help and do the review.
- I proposed in the working group to do a refactoring of
- Its very similar with
validateSidecars
just much simpler because there are fewer checks and tests.
Sorry for the long answer. I hope I expressed myself clear. Let me know what you think and if I am on the right track.
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 created an issue #8700 for the refactoring and started working on it. Once this PR is merged I will open a couple small PRs for the migration and a bit of cleanup of the tests.
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.
Sorry for the long answer. I hope I expressed myself clear. Let me know what you think and if I am on the right track.
I appreciated it. Thank you.
I created an issue #8700 for the refactoring and started working on it. Once this PR is merged I will open a couple small PRs for the migration and a bit of cleanup of the tests.
noted.
refactor season 🌴 |
It is on 🌴 😎 🌴 . |
d8104b6
to
2f83d73
Compare
The following is the coverage report on the affected files.
|
2f83d73
to
71aaff7
Compare
The following is the coverage report on the affected files.
|
71aaff7
to
a7e984e
Compare
The following is the coverage report on the affected files.
|
Hi @waveywaves, hi @binkkatal! I did some minor improvements to this PR. I describe the changes better in the commit message and in the PR message on top. You can take another look when you find the time. Thank you! |
@twoGiants , do we need to worry about the delta in the test cases ? |
The issue #8700 satisfies my question |
Hi @waveywaves ! Do you have a little time to take a look at the PR? I can break it down in two if its to big. Let me know. Thank you! |
Move step and sidecar validation functions with their call chain to `container_validation.go` and fix small typos. Create `validateSidecar` and move to `container_validation.go` to be consistent with the `validateStep` function location. Inline `validateSidecarName` function into `validateSidecar` to keep consistency because the fields `sc.Image` and `sc.Script` are validated in the caller. Keep `validationSteps` and `validateSidecars` in `task_validation.go`. Issue tektoncd#7442. Signed-off-by: Stanislav Jakuschevskij <[email protected]>
a7e984e
to
1624848
Compare
The following is the coverage report on the affected files.
|
@waveywaves should be good now. New changes integrated, tests pass. |
|
||
// Validate ensures that a supplied Ref field is populated | ||
// correctly. No errors are returned for a nil Ref. | ||
func (ref *Ref) 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.
Sorry for the long answer. I hope I expressed myself clear. Let me know what you think and if I am on the right track.
I appreciated it. Thank you.
I created an issue #8700 for the refactoring and started working on it. Once this PR is merged I will open a couple small PRs for the migration and a bit of cleanup of the tests.
noted.
return nil | ||
} | ||
|
||
func validateStep(ctx context.Context, s Step, names sets.String) (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.
+1 for colocating step and sidecar related functions in the container validation instead of task validation.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: binkkatal, 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 |
@twoGiants this looks good to me, going forward and hitting that lgtm considering that similar code is being colocated and this doesn't introduce or break any existing functionality and recorganizes existing code a little better /lgtm |
Changes
Move step and sidecar validation functions with their call chain to
container_validation.go
and fix small typos.Create
validateSidecar
and move tocontainer_validation.go
to be consistent with thevalidateStep
function location. InlinevalidateSidecarName
function intovalidateSidecar
to keep consistency because the fieldssc.Image
andsc.Script
are validated in the caller.Keep
validationSteps
andvalidateSidecars
intask_validation.go
.Closes #7442.
/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