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

initial implementation for git resource for pipeline #91

Merged
merged 2 commits into from
Oct 4, 2018

Conversation

nader-ziada
Copy link
Member

fixes #58

Proposed changes

  • add resource to Build as an input source
  • taskRun controller would have to call the AddInputResource func

still in progress, but wanted to get your initial thoughts
/cc @bobcatfish @tejal29 @aaron-prindle

@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pivotal-nader-ziada

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:
  • OWNERS [pivotal-nader-ziada]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@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 3, 2018
@nader-ziada
Copy link
Member Author

/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 3, 2018
@nader-ziada nader-ziada changed the title [WIP] initial implementation for git resource for pipeline initial implementation for git resource for pipeline Oct 4, 2018
@nader-ziada
Copy link
Member Author

/hold cancel
@bobcatfish @tejal29 @aaron-prindle can you take a look when you can. Thanks

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 4, 2018
docs/pipeline-resources.md Show resolved Hide resolved
docs/pipeline-resources.md Show resolved Hide resolved
@@ -30,6 +34,25 @@ type GitResource struct {
ServiceAccount string `json:"serviceAccount,omitempty"`
}

// NewGitResource create a new git resource to pass to Knativve Build
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/Knativve/Knative

pkg/apis/pipeline/v1alpha1/git_resource.go Show resolved Hide resolved
pkg/apis/pipeline/v1alpha1/git_resource.go Show resolved Hide resolved
},
},
}
pipelineResourceInformer.Informer().GetIndexer().Add(res)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice! i will try to add the mock objects here instead of using mocks

Source: &buildv1alpha1.SourceSpec{
Git: &buildv1alpha1.GitSourceSpec{
Url: "https://github.com/grafeas/kritis",
Revision: "master",
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a task run with Revision other than master specified for completeness.

for _, input := range task.Spec.Inputs.Sources {
resource, err := pipelineResourceLister.PipelineResources(task.Namespace).Get(input.Name)
if err != nil {

Copy link
Contributor

Choose a reason for hiding this comment

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

remove empty line

ResourceRef: v1alpha1.PipelineResourceRef{
Name: "workspace",
},
Version: "master",
Copy link
Contributor

Choose a reason for hiding this comment

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

can you specify something other than master as default is master

Copy link
Member Author

Choose a reason for hiding this comment

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

there is a test set revision to default value that doesn't specify any revision and checks it gets back master, is that what you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

no, there is not test where the Version of Taskrun is set correctly in GitResource Revision.
Right now, we can't tell if Version is set in loop L46 or L57

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I get what you are saying, will add another test

}
}
// default revision to master is nothing is provided
if gitResource.Revision == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, i feel the defaults should be set in the GitResource Constructor. The GitResource object decalres the defaults for its fields, so the onus should be on the Constructor rather than on this method.

Copy link
Member Author

Choose a reason for hiding this comment

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

the revision comes from the taskRun which happens after the constructor is called

Copy link
Contributor

Choose a reason for hiding this comment

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

which is fine. We default the revision to master if resource does not revision defined in NewGitResource().
Then in the loop, we override it trInput.Version.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, makes sense

Copy link
Member Author

Choose a reason for hiding this comment

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

but please note that the TaskRun validation should ensure it has a version, this is a required field

@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 4, 2018
@nader-ziada
Copy link
Member Author

@tejal29 ready for another look, thanks

@tejal29
Copy link
Contributor

tejal29 commented Oct 4, 2018

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 4, 2018
@knative-prow-robot knative-prow-robot merged commit 70b951d into tektoncd:master Oct 4, 2018
@@ -0,0 +1,83 @@
### Pipeline Resources

## Git Resource
Copy link
Collaborator

Choose a reason for hiding this comment

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

so cool, thanks for adding docs!

it would be good at add a link from https://github.com/knative/build-pipeline#resources to here as well, since folks won't know this doc exists


1. URL: represents the location of the git repository
1. Revision: Git [revision](https://git-scm.com/docs/gitrevisions#_specifying_revisions ) (branch, tag, commit SHA or ref) to clone. If no revision is specified, the resource will default to `latest` from `master`
1. Service Account: specifies the `name` of a `ServiceAccount` resource object. Add this paramater to run your task with the privileges of the specified service account. If no serviceAccountName field is specified, your task runs using the default service account that is in the namespace of the Pipeline resource object.
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm i wonder if this is a good default - in PipelineParams we currently have a serviceAccount field as well, is there some way we can default to that one?

and/or maybe have an error if there is no serviceaccount?

artifacts:
- name: builtImage
type: image
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

great docs!!

got, err := AddInputResource(c.build, c.task, c.taskRun, pipelineResourceLister, logger)
if (err != nil) != c.wantErr {
t.Errorf("Test: %q; NewControllerConfigFromConfigMap() error = %v, WantErr %v", c.desc, err, c.wantErr)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

im kind of making this comment everywhere, but what are your thoughts about having separate test functions for expected failures and successes? I feel like mixing them and having to handle both here clutters up the test a bit

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm okay with splitting them if you prefer that, big table tests are hard to read for sure

)

// AddInputResource will update the input build with the input resource from the task
func AddInputResource(
Copy link
Collaborator

Choose a reason for hiding this comment

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

ah nice, so I guess this function is waiting to be called by someone implementing #62 or #63 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I'm just working on it today as part of #62 :)

@nader-ziada nader-ziada deleted the git-resource branch October 11, 2018 20:26
l-qing added a commit to l-qing/pipeline that referenced this pull request Feb 10, 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.

Implement the github Resource type
4 participants