-
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
initial implementation for git resource for pipeline #91
Conversation
[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:
Approvers can indicate their approval by writing |
/hold |
ba1aaa4
to
8221983
Compare
/hold cancel |
@@ -30,6 +34,25 @@ type GitResource struct { | |||
ServiceAccount string `json:"serviceAccount,omitempty"` | |||
} | |||
|
|||
// NewGitResource create a new git resource to pass to Knativve Build |
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.
nit: s/Knativve/Knative
}, | ||
}, | ||
} | ||
pipelineResourceInformer.Informer().GetIndexer().Add(res) |
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! 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", |
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.
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 { | ||
|
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.
remove empty line
ResourceRef: v1alpha1.PipelineResourceRef{ | ||
Name: "workspace", | ||
}, | ||
Version: "master", |
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.
can you specify something other than master as default is master
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.
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?
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.
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.
ok, I get what you are saying, will add another test
} | ||
} | ||
// default revision to master is nothing is provided | ||
if gitResource.Revision == "" { |
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.
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.
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.
the revision comes from the taskRun which happens after the constructor is called
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.
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
.
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.
ok, makes sense
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.
but please note that the TaskRun validation should ensure it has a version, this is a required field
- add resource to Build as an input source
8221983
to
e2ce7ba
Compare
@tejal29 ready for another look, thanks |
/lgtm |
@@ -0,0 +1,83 @@ | |||
### Pipeline Resources | |||
|
|||
## Git 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.
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. |
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.
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 | ||
``` |
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 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) | ||
} |
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.
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
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'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( |
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.
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.
yes, I'm just working on it today as part of #62 :)
feat: adapt for tekton 0.56
fixes #58
Proposed changes
AddInputResource
funcstill in progress, but wanted to get your initial thoughts
/cc @bobcatfish @tejal29 @aaron-prindle