-
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
Change type of TaskSpec.Steps to a Step type that embeds Container #1060
Conversation
f34f993
to
0471664
Compare
/hold cancel |
/lgtm |
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.
Thank you for this, I think it makes very much sense, it's a nice extension and cleanup.
I have a few minor questions, but nothing blocking really.
|
||
// SetDestinationDirectory sets the destination for the resource |
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.
Just curious, did you drop the comments here because it's not actually implemented?
Command: []string{"/ko-app/pullrequest-init"}, | ||
Args: []string{"-url", "https://example.com", "-path", "/workspace", "-mode", mode}, | ||
Env: []corev1.EnvVar{}, | ||
func testCases(mode string) []testcase { |
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.
Perhaps we should add a go fmt check to our CI, so we wouldn't need formatting fixes anymore - they make code review a bit harder when they mix with actual changes 👼
@@ -63,6 +63,10 @@ type TaskSpec struct { | |||
ContainerTemplate *corev1.Container `json:"containerTemplate,omitempty"` | |||
} | |||
|
|||
type Step struct { |
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.
Some comments here would be nice, so the reason for this is not only in the commit message :)
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.
My comment is still valid, but it's ok to add this in a follow-up.
@@ -237,3 +238,66 @@ func validateResourceType(r TaskResource, path string) *apis.FieldError { | |||
} | |||
return apis.ErrInvalidValue(string(r.Type), path) | |||
} | |||
|
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.
Uhm, I wonder why you dropped the merge module and moved CombineStepsWithStepTemplate
in here.
@@ -69,41 +68,35 @@ func TestTaskRun_Validate(t *testing.T) { | |||
} | |||
|
|||
func TestTaskRunSpec_Invalidate(t *testing.T) { | |||
tests := []struct { | |||
for _, ts := range []struct { |
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.
Heh, dropping the extra tests var does not necessarily belong to this PR, but it's innocuous enough :)
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
var storageVol []corev1.Volume | ||
mountedSecrets := map[string]string{} | ||
mountedSecrets := map[string]struct{}{} |
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 is struct{}{} better than string{} here?
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.
@afrittoli as we don't put anything in the value part of the map, using struct{}{}
takes less memory space than string
😝
func makeWorkingDirInitializer(steps []corev1.Container) *corev1.Container { | ||
workingDirs := make(map[string]bool) | ||
func makeWorkingDirInitializer(steps []v1alpha1.Step) *v1alpha1.Step { | ||
workingDirs := map[string]struct{}{} |
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 is struct{}{}
better than bool
here?
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.
Same as above, memory space
@@ -406,11 +409,6 @@ func TestReconcile(t *testing.T) { | |||
tb.VolumeMount("downward", "/builder/downward"), | |||
tb.VolumeMount("workspace", workspaceDir), | |||
tb.VolumeMount("home", "/builder/home"), | |||
tb.Resources(tb.Requests( |
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 did you drop tb.Resources
here (and below)?
) | ||
|
||
// StepOp is an operation which modifies a Container struct. | ||
type StepOp func(*v1alpha1.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.
Nice, dedicated test builder module :) 👍
That matches my understanding as well! I think if we eventually start publishing go libs officially (I think @vdemeester was suggesting this earlier today...) we might want to revisit this but at the moment it should be fine. Also we mentioned this at last week's working group meeting and there was no major outcry (possible folks didn't realize the implications tho? + @skaegi @mnuttall for visibility if you are depending on the libs) |
Just pinging this - looks like it won't make it in for 0.6 probably but maybe we can do it for 0.7 @imjasonh ? |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: afrittoli, ImJasonH 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 |
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
- move pkg/merge into v1alpha1 to avoid circular dependency - move pkg/substitution into v1alpha1 to avoid circular dependency - change resource interface from Get*ContainerSpec -> *Steps - change artifact storage interface from GetCopy*Storage*ContainerSpec -> *Steps - removed some unnecessarily table-driven tests - squashed whitespace and brackets where possible
The following is the coverage report on pkg/.
|
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.
Nice, thank you!
Perhaps as a follow-up you could add some comments about the reason for Step struct.
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and | |||
limitations under the License. | |||
*/ | |||
|
|||
package merge | |||
package v1alpha1 |
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.
Does this make this module now part of our (not yet stable) api surface?
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.
My understanding of the API surface guarantee was that (once we commit to it) users' YAML must continue to be accepted. I don't think library or generated client APIs are in scope. @bobcatfish please correct me if that's not the case!
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 |
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.
It sounds like a good idea to have the same and only place where this is used.
In case in future we extend Steps via duck typing, it's nice to have this in the API :)
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.
<soapbox>
I'd actually like to see if we can move some of these things out of this package, so that v1alpha1
only contains structs, and no validation, merging, substitution, etc.
It's useful to have a low-dependency structs-only package for integrators to use only to send requests to a Tekton-enabled cluster, without having to import all the code Tekton uses to deal with those requests.
Future change though. 😄
</soapbox>
@@ -63,6 +63,10 @@ type TaskSpec struct { | |||
ContainerTemplate *corev1.Container `json:"containerTemplate,omitempty"` | |||
} | |||
|
|||
type Step struct { |
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.
My comment is still valid, but it's ok to add this in a follow-up.
cn := v1alpha1.CreateDirContainer("default-image-output", fmt.Sprintf("%s/%s", v1alpha1.TaskOutputImageDefaultDir, r.Name)) | ||
cn.VolumeMounts = append(cn.VolumeMounts, implicitVolumeMounts...) | ||
makeDirSteps = append(makeDirSteps, cn) | ||
s := v1alpha1.CreateDirStep("default-image-output", fmt.Sprintf("%s/%s", v1alpha1.TaskOutputImageDefaultDir, r.Name)) |
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.
oh, this is very thorough :D
I'm ready to LGTM on this patch, but holding off since it's not targeted for 0.6 as far as I can see - perhaps this could be merged once 0.6 is done |
/lgtm |
Step was added in tektoncd#1060
Changes
Changes the type of the
Steps
field of theTaskSpec
type to be a newtype Step
that embedscorev1.Container
, rather than being acorev1.Container
directly.This opens up the option to add fields to our
Step
type that aren't present incorev1.Container
(e.g.,Script []string
), and even to eventually not wrap thecorev1.Container
type at all, and instead define our own type that only includes the fields ofcorev1.Container
we want the Tekton API to support.YAML configs should not require any changes in response to this change, but users of generated API clients will need to change how they specify the
Steps
field to use the new type. My understanding of our backward-compatibility requirements means that this change doesn't qualify as "backward-incompatible" since YAMLs are not broken, but either way I think a.) this change and the options it opens up are worth the pain, and b.) it's better to make this kind of breaking change earlier rather than later, before too many more users come to depend on the generated API clients.Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide
for more details.
Release Notes
cc @abayer
/hold
This change should go in after #1015 (@vdemeester) to avoid inflicting merge conflicts on that change.