Skip to content

Commit 603a5aa

Browse files
committed
Rephrase the documentation
Rename scopped setting to scoped And update it with missing directives. Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent a3ff410 commit 603a5aa

File tree

9 files changed

+163
-88
lines changed

9 files changed

+163
-88
lines changed

config/302-pac-configmap.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ data:
2020
# Whether to automatically create a secret with the token to be use by git-clone
2121
secret-auto-create: "true"
2222

23-
# By default we only generate token scopped to the repository from where the
23+
# By default we only generate token scoped to the repository from where the
2424
# payload come from.
2525
# We do this because if the github apps is installed on an github organisation
2626
#
@@ -30,9 +30,9 @@ data:
3030
# If you trust every users on your orgnisations to access any repos there or
3131
# not planning to install your github application globally on a Github Organisation
3232
# then you can safely set this option to false.
33-
secret-github-app-token-scopped: "true"
33+
secret-github-app-token-scoped: "true"
3434

35-
# If you don't want to completely disable the scopping of the token, but still
35+
# If you don't want to completely disable the scoping of the token, but still
3636
# wants some other repos (on the same installation id) available from the
3737
# token, then you can add an extra owner/repo here.
3838
#
@@ -71,8 +71,8 @@ data:
7171
error-detection-from-container-logs: "false"
7272

7373
# How many lines to grab from the container when inspecting the
74-
# logs. Increasing this value may increase the watcher memory usage.
75-
# Use -1 for unlimited lines.
74+
# logs for error-detection. Increasing this value may increase the watcher
75+
# memory usage. Use -1 for unlimited lines.
7676
error-detection-max-number-of-lines: "50"
7777

7878
# The default regexp used when we use the simple error detection

docs/content/docs/guide/authoringprs.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ PullRequest from any repositories.
207207
{{< hint info >}}
208208

209209
* On GitHub apps the generated installation token [will be available for 8 hours](https://docs.github.com/en/developers/apps/building-github-apps/refreshing-user-to-server-access-tokens)
210-
* The token is scopped to the repository it target. On PullRequest it has the
211-
scope of the forked and target repository.
210+
* On GitHub apps the token is scoped to the repository the event (payload) come
211+
from unless [configured](/docs/install/settings#pipelines-as-code-configuration-settings) it differently on cluster.
212+
212213
{{< /hint >}}
213214

214215
## Example

docs/content/docs/guide/repositorycrd.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ spec:
6666
concurrency_limit: <number>
6767
```
6868

69+
If there is multiple PipelineRuns matching the event, the PipelineRuns
70+
that match the event will always be started in alphabetical order.
71+
6972
Example:
70-
Lets say you have 3 pipelines in `.tekton` directory, and you create a pull request with `concurrency_limit` defined as 1 in
71-
Repository CR. Then all the pipelineruns will run one after the another, at any time only one pipelinerun would be in running
72-
state and rest of them will be queued.
73+
74+
If you have three pipelineruns in a .tekton directory, and you create a pull
75+
request with a `concurrency_limit` of 1 in the repository configuration, then all
76+
of the pipelineruns will be executed in alphabetical order, one after the
77+
other. At any given time, only one pipeline run will be in the running state,
78+
while the rest will be queued.

docs/content/docs/install/settings.md

Lines changed: 113 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,54 +19,62 @@ There is a few things you can configure through the config map
1919
application to be used with private repositories. This feature is enabled by
2020
default.
2121

22-
* `secret-github-app-token-scopped`
22+
* `secret-github-app-token-scoped`
2323

24-
When using a Github app, we generate a temporary installation token, we scope it
25-
to the repository from where the payload comes. We do this when the Github app
26-
is configured globally on a Github organization.
24+
When using a Github app, `Pipelines as Code` will generate a temporary
25+
installation token for every allowed event coming through the controller.
2726

28-
If the organization has a mix of public and private repositories and not every
29-
user in the organization is trusted to have access to every repository, then the
30-
scoped token would not allow them to access those.
27+
The generated token will be scoped to the repository from the repository where
28+
the payload come from and not to every repositories the app installation has
29+
access to.
3130

32-
If you trust every user on your organization to access any repository or you are
33-
not planning to install your Github app globally on a Github organization, then
34-
you can safely set this option to false.
31+
Having access to every repositories the app has access to is a problem when
32+
you install the `Pipelines as Code` application into an organization that has
33+
a mixed between public and private repositories where every users in the
34+
organization is not trusted to have access to the private repositores. Since
35+
the scoping of the token only allow the user do operations and access on the
36+
repository where the payload come from, it will not be able to access the private repos.
37+
38+
However, if you trust every users of your organization to access any repositories or
39+
you are not planning to install your GitHub app globally on a GitHub
40+
organization, then you can safely set this option to false.
3541

3642
* `secret-github-app-scope-extra-repos`
3743

38-
If you don't want to completely disable the scopping of the token, but still
39-
wants some other repos available, then you can add an extra owner/repo here.
44+
If you don't want to completely disable the scoping of the token, but still
45+
wants some other repos available (as long you have installed the github app on
46+
it), then you can add an extra owner/repo here.
4047

4148
This let you able fetch remote url on github from extra private repositories
4249
in an organisation if you need it.
4350

4451
This only works when all the repos are added from the same installation IDs.
45-
52+
4653
You can have multiple owner/repository separated by commas:
47-
54+
4855
```yaml
49-
secret-github-app-token-scopped: "owner/private-repo1, org/repo2"
56+
secret-github-app-token-scoped: "owner/private-repo1, org/repo2"
5057
```
5158
5259
* `remote-tasks`
5360

54-
Let allows remote tasks from pipelinerun annotations. This feature is enabled by
55-
default.
61+
This allows fetching remote tasks on pipelinerun annotations. This feature is
62+
enabled by default.
5663

5764
* `hub-url`
5865

5966
The base URL for the [tekton hub](https://github.com/tektoncd/hub/)
60-
API. default to the [public hub](https://hub.tekton.dev/): <https://api.hub.tekton.dev/v1>
67+
API. This default to the [public hub](https://hub.tekton.dev/): <https://api.hub.tekton.dev/v1>
6168

6269
* `hub-catalog-name`
6370

64-
The [tekton hub](https://github.com/tektoncd/hub/) catalog name. default to tekton
71+
The [tekton hub](https://github.com/tektoncd/hub/) catalog name. default to `tekton`
6572

6673
* `tekton-dashboard-url`
6774

68-
Using the URL of the Tekton dashboard, Pipelines-as-Code generates a URL to the PipelineRun on the Tekton dashboard.
69-
If you are an OpenShift user, then OpenShift console URL is auto-detected.
75+
When you are not running on Openshift using the [tekton
76+
dashboard](https://github.com/tektoncd/dashboard/) you will need to specify a
77+
dashboard url to have the logs tnd the pipelinerun details linked.
7078

7179
* `bitbucket-cloud-check-source-ip`
7280

@@ -83,69 +91,127 @@ There is a few things you can configure through the config map
8391

8492
* `bitbucket-cloud-additional-source-ip`
8593

86-
This will provide us to give extra IPS (ie: 127.0.0.1) or networks (127.0.0.0/16)
94+
Let you add extra IPS to allow bitbucket clouds, you can do a specific IP:
95+
`127.0.0.1` or a networks `127.0.0.0/16`. Multile of them can be specified
8796
separated by commas.
8897

8998
* `max-keep-run-upper-limit`
9099

91-
This let the user define a max limit for the max-keep-run value. When the user has defined a max-keep-run annotation
92-
on a pipelineRun then its value should be less than or equal to the upper limit, otherwise upper limit will be used for cleanup.
100+
This let the user define a max limit for the max-keep-run value. When the user
101+
has defined a max-keep-run annotation on a pipelineRun then its value should
102+
be less than or equal to the upper limit, otherwise upper limit will be used
103+
for cleanup.
93104

94105
* `default-max-keep-runs`
95106

96-
This allows user to define a default limit for max-keep-run value. If defined then it's applied to all the pipelineRun
97-
which do not have `max-keep-runs` annotation.
107+
This let the user define a default limit for the `max-keep-run` value.
108+
When defined it will applied to all the pipelineRun without a `max-keep-runs`
109+
annotation.
98110

99111
* `auto-configure-new-github-repo`
100112

101-
This setting let you autoconfigure newly created GitHub repositories. On creation of a new repository, Pipelines As Code will set up a namespace
102-
for your repository and create a Repository CR.
113+
This setting let you autoconfigure newly created GitHub repositories. When
114+
Pipelines as Code sees a new repository URL from a payload, It Code will set
115+
up a namespace for your repository and create a Repository CR.
103116

104117
This feature is disabled by default and is only supported with GitHub App.
105118

106-
{< hint info >}
107-
If you have a GitHub App already setup then verify if `Repository` event is subscribed.
108-
{< /hint >}
119+
{{< hint info >}}
120+
If you have a GitHub App already setup then verify if the `repository` event is
121+
subscribed into your Github App setting.
122+
{{< /hint >}}
109123

110124
* `auto-configure-repo-namespace-template`
111125

112-
If `auto-configure-new-github-repo` is enabled then you can provide a template for generating the namespace for your new repository.
113-
By default, the namespace will be generated using this format `{{repo_name}}-pipelines`.
126+
If `auto-configure-new-github-repo` is enabled then you can provide a template
127+
for generating the namespace for your new repository. By default, the
128+
namespace will be generated using this format `{{repo_name}}-pipelines`.
114129

115130
You can override the default using the following variables
116131

117132
* `{{repo_owner}}`: The repository owner.
118133
* `{{repo_name}}`: The repository name.
119134

120-
for example. if the template is defined as `{{repo_owner}}-{{repo_name}}-ci`, then the namespace generated for repository
135+
For example. if the template is defined as `{{repo_owner}}-{{repo_name}}-ci`,
136+
then the namespace generated for repository
137+
121138
`https://github.com/owner/repo` will be `owner-repo-ci`
122139

123140
* `error-log-snippet`
124141

125-
Enable or disable the feature to show a log snippet of the failed task when there is
126-
an error in a Pipeline
142+
Enable or disable the feature to show a log snippet of the failed task when
143+
there is an error in a PipelineRun.
144+
145+
Due of the constraint of the different GIT provider API, It will show the last
146+
3 lines of the first container from the first task that has exited with an
147+
error in the PipelineRun.
148+
149+
If it find any strings matching the values of secrets attached to the
150+
PipelineRun it will replace it with the placeholder `******`
151+
152+
* `error-log-snippet`
153+
154+
{{ hint danger }}
155+
alpha feature: may change at any time
156+
{{ /hint danger }}
157+
158+
Enable or disable the inspection of container logs to detect error message
159+
and expose them as annotations on Pull Request. Only Github apps is supported.
127160

128-
It will show the last 3 lines of the first container of the first task
129-
that has error in the pipeline.
161+
* `error-detection-max-number-of-lines`
130162

131-
If it find any strings matching the values of secrets attached to the PipelineRun it will replace it with the placeholder `******`
163+
{{ hint danger }}
164+
alpha feature: may change at any time
165+
{{ /hint danger }}
166+
167+
How many lines to grab from the container when inspecting the
168+
logs for error detection when using `error-log-snippet`. Increasing this value
169+
may increase the watcher memory usage. The default is 50, increase this value
170+
or use -1 for unlimited.
171+
172+
* `error-detection-simple-regexp`
173+
174+
{{ hint danger }}
175+
alpha feature: may change at any time
176+
{{ /hint danger }}
177+
178+
By default error detection only support the simple outputs, the way GCC or
179+
make will output which is supported by most linters and command line tools.
180+
181+
An example is :
182+
183+
```console
184+
test.js:100:10: an error occurred
185+
```
186+
187+
Pipelines as Code will see this line and show it as an annotation on the pull
188+
request where the error occurred.
189+
190+
You can configure the default regexp used for detection. You will need to
191+
keep the regexp groups: `<filename>`, `<line>`, `<error>` to make it works.
132192

133193
## Pipelines-As-Code Info
134194

135-
There are a settings exposed through a config map which any authenticated user can access to know about
136-
Pipeline as Code.
195+
There are a settings exposed through a config map for which any authenticated
196+
user can access to know about the Pipeline as Code status.
137197

138198
* `version`
139199

140-
The version of Pipelines As Code installed.
200+
The version of Pipelines As Code currently installed.
141201

142202
* `controller-url`
143203

144-
The controller URL as set by the `tkn pac bootstrap` command while setting up the GitHub App or if Pipelines as code is installed
145-
using OpenShift Pipelines Operator then the operator sets the route created for the controller. This field is also used to detect the controller
146-
URL in `webhook add` commands.
204+
The controller URL as set by the `tkn pac bootstrap` command while setting up
205+
the GitHub App or if Pipelines as code is installed
206+
207+
When using OpenShift Pipelines Operator then the operator sets the route created
208+
for the controller.
209+
210+
This field is also used to detect the controller URL when using the `webhook add`
211+
commands.
147212

148213
* `provider`
149214

150-
The provider is set to `GitHub App` by tkn pac bootstrap command and is used to detect if a GitHub App is already configured when a user runs the
151-
bootstrap command a second time or the `webhook add` command.
215+
The provider set to `GitHub App` by tkn pac bootstrap, used to detect if a
216+
GitHub App is already configured when a user runs the bootstrap command a
217+
second time or the `webhook add` command.

pkg/params/settings/config.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ const (
2121
AutoConfigureNewGitHubRepoKey = "auto-configure-new-github-repo"
2222
AutoConfigureRepoNamespaceTemplateKey = "auto-configure-repo-namespace-template"
2323

24-
SecretAutoCreateKey = "secret-auto-create"
25-
secretAutoCreateDefaultValue = "true"
26-
SecretGhAppTokenRepoScoppedKey = "secret-github-app-token-scopped" //nolint: gosec
27-
secretGhAppTokenRepoScoppedDefaultValue = "true"
28-
SecretGhAppTokenScoppedExtraReposKey = "secret-github-app-scope-extra-repos" //nolint: gosec
29-
secretGhAppTokenScoppedExtraReposDefaultValue = "" //nolint: gosec
24+
SecretAutoCreateKey = "secret-auto-create"
25+
secretAutoCreateDefaultValue = "true"
26+
SecretGhAppTokenRepoScopedKey = "secret-github-app-token-scoped" //nolint: gosec
27+
secretGhAppTokenRepoScopedDefaultValue = "true"
28+
SecretGhAppTokenScopedExtraReposKey = "secret-github-app-scope-extra-repos" //nolint: gosec
29+
secretGhAppTokenScopedExtraReposDefaultValue = "" //nolint: gosec
3030

3131
remoteTasksDefaultValue = "true"
3232
bitbucketCloudCheckSourceIPDefaultValue = "true"
@@ -36,15 +36,16 @@ const (
3636
AutoConfigureNewGitHubRepoDefaultValue = "false"
3737

3838
ErrorLogSnippetKey = "error-log-snippet"
39-
errorLogSnippetValue = "false"
40-
41-
ErrorDetectionKey = "error-detection-from-container-logs"
42-
ErrorDetectionNumberOfLinesKey = "error-detection-max-number-of-lines"
43-
ErrorDetectionSimpleFilterTaskKey = "error-detection-simple-filter-to-task-labels"
44-
ErrorDetectionSimpleRegexpKey = "error-detection-simple-regexp"
45-
errorDetectionValue = "false"
46-
errorDetectionNumberOfLinesValue = 50
47-
errorDetectionSimpleRegexpValue = `^(?P<filename>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+):([ ]*)?(?P<error>.*)`
39+
errorLogSnippetValue = "true"
40+
41+
ErrorDetectionKey = "error-detection-from-container-logs"
42+
errorDetectionValue = "false"
43+
44+
ErrorDetectionNumberOfLinesKey = "error-detection-max-number-of-lines"
45+
errorDetectionNumberOfLinesValue = 50
46+
47+
ErrorDetectionSimpleRegexpKey = "error-detection-simple-regexp"
48+
errorDetectionSimpleRegexpValue = `^(?P<filename>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+):([ ]*)?(?P<error>.*)`
4849
)
4950

5051
type Settings struct {
@@ -60,9 +61,9 @@ type Settings struct {
6061
AutoConfigureNewGitHubRepo bool
6162
AutoConfigureRepoNamespaceTemplate string
6263

63-
SecretAutoCreation bool
64-
SecretGHAppRepoScoped bool
65-
SecretGhAppTokenScoppedExtraRepos string
64+
SecretAutoCreation bool
65+
SecretGHAppRepoScoped bool
66+
SecretGhAppTokenScopedExtraRepos string
6667

6768
ErrorLogSnippet bool
6869
ErrorDetection bool
@@ -90,16 +91,16 @@ func ConfigToSettings(logger *zap.SugaredLogger, setting *Settings, config map[s
9091
setting.SecretAutoCreation = secretAutoCreate
9192
}
9293

93-
secretGHAppRepoScoped := StringToBool(config[SecretGhAppTokenRepoScoppedKey])
94+
secretGHAppRepoScoped := StringToBool(config[SecretGhAppTokenRepoScopedKey])
9495
if setting.SecretGHAppRepoScoped != secretGHAppRepoScoped {
95-
logger.Infof("CONFIG: not scopping the token generated from gh %v", secretGHAppRepoScoped)
96+
logger.Infof("CONFIG: not scoping the token generated from gh %v", secretGHAppRepoScoped)
9697
setting.SecretGHAppRepoScoped = secretGHAppRepoScoped
9798
}
9899

99-
secretGHAppScoppedExtraRepos := config[SecretGhAppTokenScoppedExtraReposKey]
100-
if setting.SecretGhAppTokenScoppedExtraRepos != secretGHAppScoppedExtraRepos {
101-
logger.Infof("CONFIG: adding extra repositories for token scopping %v", secretGHAppRepoScoped)
102-
setting.SecretGhAppTokenScoppedExtraRepos = secretGHAppScoppedExtraRepos
100+
secretGHAppScopedExtraRepos := config[SecretGhAppTokenScopedExtraReposKey]
101+
if setting.SecretGhAppTokenScopedExtraRepos != secretGHAppScopedExtraRepos {
102+
logger.Infof("CONFIG: adding extra repositories for github app token scope %v", secretGHAppRepoScoped)
103+
setting.SecretGhAppTokenScopedExtraRepos = secretGHAppScopedExtraRepos
103104
}
104105

105106
if setting.HubURL != config[HubURLKey] {

pkg/params/settings/default.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ func SetDefaults(config map[string]string) {
1111
config[SecretAutoCreateKey] = secretAutoCreateDefaultValue
1212
}
1313

14-
if ghScoppedToken, ok := config[SecretGhAppTokenRepoScoppedKey]; !ok || ghScoppedToken == "" {
15-
config[SecretGhAppTokenRepoScoppedKey] = secretGhAppTokenRepoScoppedDefaultValue
14+
if ghScopedToken, ok := config[SecretGhAppTokenRepoScopedKey]; !ok || ghScopedToken == "" {
15+
config[SecretGhAppTokenRepoScopedKey] = secretGhAppTokenRepoScopedDefaultValue
1616
}
1717

1818
if hubURL, ok := config[HubURLKey]; !ok || hubURL == "" {

0 commit comments

Comments
 (0)