-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Deprecate and remove test builders #3178
Comments
/kind cleanup |
It will be great to break this down one test file or one Go struct (Task/PipelineTask/Pipeline) at a time and would make a good |
Here's a little oneliner to find the top 10 files by occurrences of
And a count of total
I'd probably start with just replacing references to With enough of those changes you'd be able to delete some unused test builder methods, until eventually you have all of them and you can delete whole files/packages 🎉 (We can probably also delete |
😱
|
I've found a truly disgusting mis-feature of test builders! 😱 Pop quiz: What does this method do? tb.PipelineTaskParam("foo", "bar", "baz", "hello") Hint: godoc for Pencils down! It results in an object equivalent to: v1beta1.Param{
Name: "foo",
Value: *v1beta1.NewArrayOrString("bar", "baz", "hello"),
} That's right! The first arg is the parameter name, and subsequent values are the parameter values -- possibly-array-typed, if there are 2+ variadic values given. The raw Go struct is unarguably more verbose to write and read, but that's because it names the fields it's filling and makes it clearer what each string value is stating. |
Another one-liner to find most used test builder methods:
And one to find unused test builder methods we can probably just delete any time:
|
Note that this is an API design (the |
Oh definitely, the builder could have been something like: tb.PipelineTaskParam("foo",
tb.PipelineTaskParamValues("bar", "baz", "hello")) ...and if we wanted to keep the builders we could refactor it to that already. But is it more readable than the raw struct declaration, and is it more readable by enough to warrant us maintaining a method to make it possible, when the alternative is already available to us for free? I think we've decided the answer is no 😄 |
@imjasonh yeah agreed, I was just pointing out it's not the "builder" pattern that is wrong "by default" 😛 |
/assign |
It is better to have simple tests with full objects than test builders as of Issue tektoncd#3178. Since, they are easier to maintain and are easier to read.
It is better to have simple tests with full objects than test builders as of Issue #3178. Since, they are easier to maintain and are easier to read.
It is better to have simple tests with full objects than test builders as of Issue #3178. Since, they are easier to maintain and are easier to read.
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
Stale issues rot after 30d of inactivity. /lifecycle rotten Send feedback to tektoncd/plumbing. |
/lifecycle frozen |
Part of tektoncd#3178. `internal/builder/v1beta1` is still there - I did remove it from some of the files under `pkg/reconciler` where I was removing `internal/builder/v1alpha1` usage while I was there, but there are still plenty of references left, including _1,487_ in `pkg/reconciler/pipelinerun/pipelinerun_test.go`. Yikes! Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Part of tektoncd#3178. `internal/builder/v1beta1` is still there - I did remove it from some of the files under `pkg/reconciler` where I was removing `internal/builder/v1alpha1` usage while I was there, but there are still plenty of references left, including _1,487_ in `pkg/reconciler/pipelinerun/pipelinerun_test.go`. Yikes! Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Part of tektoncd#3178. `internal/builder/v1beta1` is still there - I did remove it from some of the files under `pkg/reconciler` where I was removing `internal/builder/v1alpha1` usage while I was there, but there are still plenty of references left, including _1,487_ in `pkg/reconciler/pipelinerun/pipelinerun_test.go`. Yikes! Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Part of tektoncd#3178. `internal/builder/v1beta1` is still there - I did remove it from some of the files under `pkg/reconciler` where I was removing `internal/builder/v1alpha1` usage while I was there, but there are still plenty of references left, including _1,487_ in `pkg/reconciler/pipelinerun/pipelinerun_test.go`. Yikes! Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Part of tektoncd#3178. `internal/builder/v1beta1` is still there - I did remove it from some of the files under `pkg/reconciler` where I was removing `internal/builder/v1alpha1` usage while I was there, but there are still plenty of references left, including _1,487_ in `pkg/reconciler/pipelinerun/pipelinerun_test.go`. Yikes! Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Part of tektoncd#3178. `internal/builder/v1beta1` is still there - I did remove it from some of the files under `pkg/reconciler` where I was removing `internal/builder/v1alpha1` usage while I was there, but there are still plenty of references left, including _1,487_ in `pkg/reconciler/pipelinerun/pipelinerun_test.go`. Yikes! Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
Part of #3178. `internal/builder/v1beta1` is still there - I did remove it from some of the files under `pkg/reconciler` where I was removing `internal/builder/v1alpha1` usage while I was there, but there are still plenty of references left, including _1,487_ in `pkg/reconciler/pipelinerun/pipelinerun_test.go`. Yikes! Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
/assign @abayer |
/close |
@abayer: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Part of tektoncd#3178. `internal/builder/v1beta1` is still there - I did remove it from some of the files under `pkg/reconciler` where I was removing `internal/builder/v1alpha1` usage while I was there, but there are still plenty of references left, including _1,487_ in `pkg/reconciler/pipelinerun/pipelinerun_test.go`. Yikes! Signed-off-by: Andrew Bayer <andrew.bayer@gmail.com>
https://github.com/tektoncd/pipeline/tree/master/internal/builder
New uses of and additions to these packages should be discouraged, and eventually these packages should be phased out entirely.
Hand-maintaining these test builder methods is toilsome and error-prone. They claim to help readability, but instead they introduce a Tekton-specific dialect of Go when users could just write Go-standard struct declarations themselves, which have the advantage of named fields over positional function args.
See #3124 for an example of migrating off of test builders.
/assign @imjasonh
The text was updated successfully, but these errors were encountered: