Skip to content
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

Only have one set of examples and test that they are valid #109

Merged
merged 4 commits into from
Oct 9, 2018

Conversation

bobcatfish
Copy link
Collaborator

We ended up in a state where we had both an examples dir and a
samples dir, and neither were tested, so both were slightly out of
sync with each other and the actual types.

This was b/c:

  • When we used kubebuilder, we generated our types from an original set
    of examples - previously these were in config/samples and they ended
    up in samples. We used the validation tests generated by kubebuilder
    to test these, but when we removed kubebuilder we removed the tests
  • Before presenting the API to the Build CRD working group, we wanted to
    have some more complex, real world examples, which @tejal29 created
    from the kritis project and the k8s guestbook example

This commit makes sure that all of the functionality demonstrated in
samples is in examples, and removes samples. This included:

  • Fixing passedConstraints to be plural as the types expected
  • Including references to the PipelineParams in the TaskRun example
    (removing the duplicated list of result endpoints, since we'll be
    getting this from the references instead)
  • Fixing clusterBindings to refer to the actual names of the clusters
    involved

It also adds a step to the integration tests to deploy the examples,
which will fail if they do not match the expected schema. At this point
they are torn down immediately after creation, but in #108 we can expand
this to actually test that they are working.

Also had to make some tweaks to the types:

Fixes #20

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 8, 2018
@bobcatfish
Copy link
Collaborator Author

bobcatfish commented Oct 8, 2018

W1008 16:45:49.586] pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go:37:40: task.Spec.Inputs.Sources undefined (type *"github.com/knative/build-pipeline/pkg/apis/pipeline/v1alpha1".Inputs has no field or method Sources)

oo i broke building!

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comments, but looks good :)
/approve

Needs a rebase though 👼


```bash
kubectl apply -f examples/pipelines
kubectl apply -f examples/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use ko here ? (like on some other knative projects ?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vdemeester we could but I'm not sure we need to since there's nothing to build - even ko under the hood I think still calls out to kubectl (i think?) - but maybe there are some other benefits I'm missing?

@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bobcatfish, vdemeester

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

resourcesVersion:
- resourceRef:
name: kritis-resources-git
version: 4da79b91e8e37ea441cfe4972565e2184c1a127f
params:
- name: 'makeTarget'
type: 'string'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type does not exist here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops, thanks for catching that!

@@ -57,27 +57,14 @@ type Task struct {
// Inputs are the requirements that a task needs to run a Build.
type Inputs struct {
// +optional
Sources []Source `json:"resources,omitempty"`
Resources []TaskResource `json:"resources,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Member

@nader-ziada nader-ziada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also fix:

examples/pipeline_params.yaml

  • has a field token that doesn't exist in the type definition

examples/invocations/kritis-pipeline-run.yaml

  • using prevTask and nextTask that are no longer part of the type definition

@bobcatfish
Copy link
Collaborator Author

I think now that #86 is merged I should probably fix the conditions as well 🤔

@bobcatfish
Copy link
Collaborator Author

has a field token that doesn't exist in the type definition

good call!

using prevTask and nextTask that are no longer part of the type definition

ah yeah that's right - I think we're still going to need something to represent the order the tasks executed in 🤔 but i'll remove this till we figure it out!

We ended up in a state where we had both an `examples` dir and a
`samples` dir, and neither were tested, so both were slightly out of
sync with each other and the actual types.

This was b/c:
- When we used kubebuilder, we generated our types from an original set
  of examples - previously these were in `config/samples` and they ended
  up in `samples`. We used the validation tests generated by kubebuilder
  to test these, but when we removed kubebuilder we removed the tests
- Before presenting the API to the Build CRD working group, we wanted to
  have some more complex, real world examples, which @tejal29 created
  from the `kritis` project and the k8s guestbook example

This commit makes sure that all of the functionality demonstrated in
`samples` is in `examples`, and removes `samples`. This included:
- Fixing `passedConstraints` to be plural as the types expected
- Including references to the `PipelineParams` in the `TaskRun` example
  (removing the duplicated list of result endpoints, since we'll be
  getting this from the references instead)
- Fixing clusterBindings to refer to the actual names of the clusters
  involved

It also adds a step to the integration tests to deploy the examples,
which will fail if they do not match the expected schema. At this point
they are torn down immediately after creation, but in #108 we can expand
this to actually test that they are working.

Also had to make some tweaks to the types:
- actually including `ClusterBindings` in the `Pipeline`
- Using names which include `Resource` instead of `Source`, which we
  moved away from in #39

Fixes #20
None of these fields are in our current spec, so let's remove them for
now.

As far as `nextTask` and `prevTask` are concerned, we're still going to
need some way to represent the order the Tasks actually executed in
while the Pipeline was running (maybe? or would we infer this from the
Pipeline?) but we can remove them for now.
Now that #95 has gone in, we have better valiation and it revealed a few
more issues in our examples. Now the volume mounting example is probably
almost right, not sure until we actually try to use it (and implement
templating)
We don't yet have validation implemented for our Runs, but as of #86 we
are using the same Conditions as Knative Build: just `Succeeded` (where
unknown means running, true means it finished successfully and false
means it finished but failed)
@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 9, 2018
@bobcatfish
Copy link
Collaborator Author

Should be ready for another look @pivotal-nader-ziada @vdemeester !


kubectl delete -f examples/invocations
kubectl delete -f examples/pipelines
kubectl delete -f examples/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one advantage of using IDE, it adds new line :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder if i need to turn an extension on or something 🤔

Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm /hold

// the Task definition, and when provided as an Input, the Name will be the
// path to the volume mounted containing this Resource as an input (e.g.
// an input Resource named `workspace` will be mounted at `/workspace`).
type TaskResource struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 9, 2018
@knative-prow-robot knative-prow-robot merged commit 9177893 into tektoncd:master Oct 9, 2018
l-qing added a commit to l-qing/pipeline that referenced this pull request Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants