You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added support for authenticated git cloning using `gitToken` and `gitTokenKey`
parameters. Updated documentation to reflect the new parameters and their
usage. Modified resolver functions to handle authentication when cloning
repositories. Added tests to verify the functionality of authenticated git
cloning.
The differences between the two modes are:
- The `git clone` method support anonymous cloning and authenticated cloning.
- Depending of the Git provider `git clone` has a lower rate limit (if none)
than the authenticated API.
- The authenticated API supports private repositories and fetches only the file
at the specified path rather than doing a full clone.
|`url`| URL of the repo to fetch and clone anonymously. Either `url`, or `repo` (with `org`) must be specified, but not both. |`https://github.com/tektoncd/catalog.git`|
19
-
|`repo`| The repository to find the resource in. Either `url`, or `repo` (with `org`) must be specified, but not both. |`pipeline`, `test-infra`|
20
-
|`org`| The organization to find the repository in. Default can be set in [configuration](#configuration). |`tektoncd`, `kubernetes`|
21
-
|`token`| An optional secret name in the `PipelineRun` namespace to fetch the token from. Defaults to empty, meaning it will try to use the configuration from the global configmap. |`secret-name`, (empty) |
22
-
|`tokenKey`| An optional key in the token secret name in the `PipelineRun` namespace to fetch the token from. Defaults to `token`. |`token`|
23
-
|`revision`| Git revision to checkout a file from. This can be commit SHA, branch or tag. |`aeb957601cf41c012be462827053a21a420befca``main``v0.38.2`|
24
-
|`pathInRepo`| Where to find the file in the repo. |`task/golang-build/0.3/golang-build.yaml`|
25
-
|`serverURL`| An optional server URL (that includes the https:// prefix) to connect for API operations |`https:/github.mycompany.com`|
26
-
|`scmType`| An optional SCM type to use for API operations |`github`, `gitlab`, `gitea`|
|`url`| URL of the repo to fetch and clone anonymously. Either `url`, or `repo` (with `org`) must be specified, but not both. |`https://github.com/tektoncd/catalog.git`|
19
+
|`repo`| The repository to find the resource in. Either `url`, or `repo` (with `org`) must be specified, but not both. |`pipeline`, `test-infra`|
20
+
|`org`| The organization to find the repository in. Default can be set in [configuration](#configuration). |`tektoncd`, `kubernetes`|
21
+
|`token`| An optional secret name in the `PipelineRun` namespace to fetch the token from. Defaults to empty, meaning it will try to use the configuration from the global configmap. |`secret-name`, (empty) |
22
+
|`tokenKey`| An optional key in the token secret name in the `PipelineRun` namespace to fetch the token from. Defaults to `token`. |`token`|
23
+
| `gitToken` | An optional secret name in the `PipelineRun` namespace to fetch the token from when doing opration with the `git clone`. When empty it will use anonymous cloning.
24
+
|`gitTokenKey`| An optional key in the token secret name in the `PipelineRun` namespace to fetch the token from when using the `git clone`. Defaults to `token`. |`token`|
25
+
|`revision`| Git revision to checkout a file from. This can be commit SHA, branch or tag. |`aeb957601cf41c012be462827053a21a420befca``main``v0.38.2`|
26
+
|`pathInRepo`| Where to find the file in the repo. |`task/golang-build/0.3/golang-build.yaml`|
27
+
|`serverURL`| An optional server URL (that includes the https:// prefix) to connect for API operations |`https:/github.mycompany.com`|
28
+
|`scmType`| An optional SCM type to use for API operations |`github`, `gitlab`, `gitea`|
27
29
28
30
## Requirements
29
31
@@ -55,11 +57,22 @@ for the name, namespace and defaults that the resolver ships with.
55
57
56
58
## Usage
57
59
58
-
The `git` resolver has two modes: cloning a repository anonymously, or fetching individual files via an SCM provider's API using an API token.
60
+
The `git` resolver has two modes: cloning a repository with `git clone` (with
61
+
the `go-git` library), or fetching individual files via an SCM provider's API
62
+
using an API token.
59
63
60
-
### Anonymous Cloning
64
+
The differences between the two modes are:
61
65
62
-
Anonymous cloning is supported only for public repositories. This mode clones the full git repo.
66
+
- The `git clone` method support anonymous cloning and authenticated cloning.
67
+
- Depending of the Git provider `git clone` has a lower rate limit
68
+
than the authenticated API.
69
+
- The authenticated API supports private repositories and fetches only the file
70
+
at the specified path rather than doing a full clone.
71
+
72
+
### Git Clone with git clone
73
+
74
+
Git clone with `git clone` is supported for anonymous and
75
+
authenticated cloning.
63
76
64
77
#### Task Resolution
65
78
@@ -78,6 +91,11 @@ spec:
78
91
value: main
79
92
- name: pathInRepo
80
93
value: task/git-clone/0.6/git-clone.yaml
94
+
# Uncomment the following lines to use a secret with a token
95
+
# - name: gitToken
96
+
# value: "secret-with-token"
97
+
# - name: gitTokenKey (optional, defaults to "token")
98
+
# value: "token"
81
99
```
82
100
83
101
#### Pipeline resolution
@@ -97,6 +115,11 @@ spec:
97
115
value: main
98
116
- name: pathInRepo
99
117
value: pipeline/simple/0.1/simple.yaml
118
+
# Uncomment the following lines to use a secret with a token
119
+
# - name: gitToken
120
+
# value: "secret-with-token"
121
+
# - name: gitTokenKey (optional, defaults to "token")
122
+
# value: "token"
100
123
params:
101
124
- name: name
102
125
value: Ranni
@@ -193,11 +216,11 @@ spec:
193
216
194
217
### Specifying Configuration for Multiple Git Providers
195
218
196
-
It is possible to specify configurations for multiple providers and even multiple configurations for same provider to use in
219
+
It is possible to specify configurations for multiple providers and even multiple configurations for same provider to use in
197
220
different tekton resources. Firstly, details need to be added in configmap with the unique identifier key prefix.
198
-
To use them in tekton resources, pass the unique key mentioned in configmap as an extra param to resolver with key
199
-
`configKey`and value will be the unique key. If no `configKey` param is passed, `default` will be used. Default
200
-
configuration to be used for git resolver can be specified in configmap by either mentioning no unique identifier or
221
+
To use them in tekton resources, pass the unique key mentioned in configmap as an extra param to resolver with key
222
+
`configKey`and value will be the unique key. If no `configKey` param is passed, `default` will be used. Default
223
+
configuration to be used for git resolver can be specified in configmap by either mentioning no unique identifier or
201
224
using identifier `default`
202
225
203
226
**Note**: `configKey` should not contain `.` while specifying configurations in configmap
0 commit comments