Skip to content

Commit 9148f7e

Browse files
authored
Merge branch 'main' into report-yaml-error-properly-as-comment
2 parents 1c9584e + dc8c340 commit 9148f7e

File tree

24 files changed

+609
-700
lines changed

24 files changed

+609
-700
lines changed

.tekton/doc.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ spec:
4646
resolver: http
4747
params:
4848
- name: url
49-
value: https://raw.githubusercontent.com/chmouel/tekton-caches/refs/heads/chmouel-images/tekton/cache-fetch.yaml
49+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/tasks/cache-fetch.yaml
5050
params:
5151
- name: patterns
5252
value: ["$(workspaces.source.path)/README.md"]
@@ -113,7 +113,7 @@ spec:
113113
resolver: http
114114
params:
115115
- name: url
116-
value: https://raw.githubusercontent.com/chmouel/tekton-caches/refs/heads/chmouel-images/tekton/cache-upload.yaml
116+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/tasks/cache-upload.yaml
117117
params:
118118
- name: patterns
119119
value: ["$(workspaces.source.path)/README.md"]

.tekton/go.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ spec:
4444
resolver: http
4545
params:
4646
- name: url
47-
value: https://raw.githubusercontent.com/chmouel/tekton-caches/refs/heads/chmouel-images/tekton/cache-fetch.yaml
47+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/tasks/cache-fetch.yaml
4848
params:
4949
- name: patterns
5050
value: ["**go.mod", "**go.sum"]
@@ -116,7 +116,7 @@ spec:
116116
resolver: http
117117
params:
118118
- name: url
119-
value: https://raw.githubusercontent.com/chmouel/tekton-caches/refs/heads/chmouel-images/tekton/cache-upload.yaml
119+
value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/tasks/cache-upload.yaml
120120
params:
121121
- name: patterns
122122
value: ["**go.mod", "**go.sum"]

.tekton/tasks/cache-fetch.yaml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: StepAction
3+
metadata:
4+
name: cache-fetch
5+
annotations:
6+
tekton.dev/pipelines.minVersion: "0.56.0"
7+
tekton.dev/tags: "cache"
8+
spec:
9+
params:
10+
- name: patterns
11+
description: |
12+
Regular expression to select files to include to compute the hash.
13+
For example, in the case of a Go project, you can use `go.mod` for this, so the value would be "**/go.sum" (to work with possible sub go modules as well).
14+
type: array
15+
- name: source
16+
description: |
17+
The source from where the cache should be fetched. It's a URI with the scheme defining the "provider". In addition, one can add a {{hash}} variable to use the computed hash in the reference (oci image tags, path in s3, …)
18+
Currently supported:
19+
- oci:// (e.g. oci://quay.io/vdemeester/go-cache:{{hash}}
20+
- s3:// (e.g. s3://
21+
type: string
22+
- name: cachePath
23+
description: |
24+
Path where to extract the cache content.
25+
It can refer any folder, backed by a workspace or a volume, or nothing.
26+
type: string
27+
- name: workingdir
28+
description: |
29+
The working dir from where the files patterns needs to be taken
30+
type: string
31+
- name: insecure
32+
description: |
33+
Whether to use insecure mode for fetching the cache
34+
type: string
35+
default: "false"
36+
- name: googleCredentialsPath
37+
description: |
38+
The path where to find the google credentials. If left empty, it is ignored.
39+
type: string
40+
default: ""
41+
- name: awsConfigFile
42+
description: |
43+
The path to the aws config file. If left empty, it is ignored.
44+
type: string
45+
default: ""
46+
- name: awsCredentialFile
47+
description: |
48+
The path to find the aws credentials file. If left empty, it is ignored.
49+
type: string
50+
default: ""
51+
- name: blobQueryParams
52+
description: |
53+
Blob Query Params to support configure s3, gcs and azure. This is optional unless some additional features of storage providers are required like s3 acceleration, fips, pathstyle,etc
54+
type: string
55+
default: ""
56+
results:
57+
- name: fetched
58+
description: |
59+
Whether a cache was fetched or not (true/false). This step won't fail if it didn't manage to fetch cache. This results allows the next step to act whether something was fetched or not.
60+
env:
61+
- name: PARAM_SOURCE
62+
value: $(params.source)
63+
- name: PARAM_CACHE_PATH
64+
value: $(params.cachePath)
65+
- name: PARAM_WORKINGDIR
66+
value: $(params.workingdir)
67+
- name: PARAM_INSECURE
68+
value: $(params.insecure)
69+
- name: GOOGLE_APPLICATION_CREDENTIALS
70+
value: $(params.googleCredentialsPath)
71+
- name: AWS_CONFIG_FILE
72+
value: $(params.awsConfigFile)
73+
- name: AWS_SHARED_CREDENTIALS_FILE
74+
value: $(params.awsCredentialFile)
75+
- name: BLOB_QUERY_PARAMS
76+
value: $(params.blobQueryParams)
77+
image: ghcr.io/chmouel/tekton-caches/cache@sha256:7b543966be2c4ef9bc439c0a6d262dd0f284216c7c292ba35c15b9ef5bca84c6
78+
args: ["$(params.patterns[*])"]
79+
script: |
80+
#!/bin/sh
81+
82+
PATTERN_FLAGS=""
83+
echo "Patterns: $*"
84+
for p in $*; do
85+
PATTERN_FLAGS="${PATTERN_FLAGS} --pattern ${p}"
86+
done
87+
88+
set -x
89+
/ko-app/cache fetch ${PATTERN_FLAGS} \
90+
--source ${PARAM_SOURCE} \
91+
--folder ${PARAM_CACHE_PATH} \
92+
--insecure ${PARAM_INSECURE} \
93+
--workingdir ${PARAM_WORKINGDIR}
94+
if [ $? -eq 0 ]; then
95+
echo -n true > $(step.results.fetched.path)
96+
else
97+
echo -n false > $(step.results.fetched.path)
98+
fi
99+
100+
exit 0

.tekton/tasks/cache-upload.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: StepAction
3+
metadata:
4+
name: cache-upload
5+
annotations:
6+
tekton.dev/pipelines.minVersion: "0.56.0"
7+
tekton.dev/tags: "cache"
8+
spec:
9+
params:
10+
- name: patterns
11+
description: |
12+
Regular expression to select files to include to compute the hash.
13+
For example, in the case of a Go project, you can use `go.mod` for this, so the value would be "**/go.sum" (to work with possible sub go modules as well).
14+
type: array
15+
- name: target
16+
description: |
17+
The target from where the cache should be uploaded. It's a URI with the scheme defining the "provider". In addition, one can add a {{hash}} variable to use the computed hash in the reference (oci image tags, path in s3, …)
18+
Currently supported:
19+
- oci:// (e.g. oci://quay.io/vdemeester/go-cache:{{hash}}
20+
- s3:// (e.g. s3://
21+
type: string
22+
- name: cachePath
23+
description: |
24+
Path where to extract the cache content.
25+
It can refer any folder, backed by a workspace or a volume, or nothing.
26+
type: string
27+
- name: workingdir
28+
description: |
29+
The working dir from where the files patterns needs to be taken
30+
type: string
31+
- name: insecure
32+
description: |
33+
Whether to use insecure mode for fetching the cache
34+
type: string
35+
default: "false"
36+
- name: fetched
37+
description: |
38+
Wether cache was fetched or not previously
39+
type: string
40+
default: "false"
41+
- name: force-cache-upload
42+
description: |
43+
Whether to force the cache upload even if it was fetched previously
44+
type: string
45+
default: "false"
46+
- name: googleCredentialsPath
47+
description: |
48+
The path where to find the google credentials. If left empty, it is ignored.
49+
type: string
50+
default: ""
51+
- name: awsConfigFile
52+
description: |
53+
The path to the aws config file. If left empty, it is ignored.
54+
type: string
55+
default: ""
56+
- name: awsCredentialFile
57+
description: |
58+
The path to find the aws credentials file. If left empty, it is ignored.
59+
type: string
60+
default: ""
61+
- name: blobQueryParams
62+
description: |
63+
Blob Query Params to support configure s3, gcs and azure. This is optional unless some additional features of storage providers are required like s3 acceleration, fips, pathstyle,etc
64+
type: string
65+
default: ""
66+
env:
67+
- name: PARAM_TARGET
68+
value: $(params.target)
69+
- name: PARAM_CACHE_PATH
70+
value: $(params.cachePath)
71+
- name: PARAM_WORKINGDIR
72+
value: $(params.workingdir)
73+
- name: PARAM_INSECURE
74+
value: $(params.insecure)
75+
- name: RESULT_CACHE_FETCHED
76+
value: $(params.fetched)
77+
- name: PARAM_FORCE_CACHE_UPLOAD
78+
value: $(params.force-cache-upload)
79+
- name: GOOGLE_APPLICATION_CREDENTIALS
80+
value: $(params.googleCredentialsPath)
81+
- name: AWS_CONFIG_FILE
82+
value: $(params.awsConfigFile)
83+
- name: AWS_SHARED_CREDENTIALS_FILE
84+
value: $(params.awsCredentialFile)
85+
- name: BLOB_QUERY_PARAMS
86+
value: $(params.blobQueryParams)
87+
image: ghcr.io/chmouel/tekton-caches/cache@sha256:7b543966be2c4ef9bc439c0a6d262dd0f284216c7c292ba35c15b9ef5bca84c6
88+
args: ["$(params.patterns[*])"]
89+
script: |
90+
#!/usr/bin/env sh
91+
set -x
92+
if [[ ${PARAM_FORCE_CACHE_UPLOAD} == "false" && ${RESULT_CACHE_FETCHED} == "true" ]]; then
93+
echo "no need to upload cache"
94+
exit 0
95+
fi
96+
97+
PATTERN_FLAGS=""
98+
echo "Patterns: $*"
99+
for p in $*; do
100+
PATTERN_FLAGS="${PATTERN_FLAGS} --pattern ${p}"
101+
done
102+
103+
# Try three times
104+
for i in {1..3};do
105+
/ko-app/cache upload ${PATTERN_FLAGS} \
106+
--target ${PARAM_TARGET} \
107+
--folder ${PARAM_CACHE_PATH} \
108+
--insecure ${PARAM_INSECURE} \
109+
--workingdir ${PARAM_WORKINGDIR}
110+
ret=$?
111+
if [[ ${ret} == 0 ]];then
112+
exit 0
113+
fi
114+
done
115+
exit 1

docs/content/docs/install/getting-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ This will let your git platform provider (e.g., GitHub) reach the controller wit
7878

7979
### Tekton Dashboard
8080

81-
If you have the [Tekton Dashboard](https://github.com/tekton/dashboard)
81+
If you have the [Tekton Dashboard](https://github.com/tektoncd/dashboard)
8282
installed and if you want to use it for the links to show the logs or
8383
description of the PipelineRun. If you are running on `OpenShift` it will
8484
automatically detect the OpenShift console Route and use it.
@@ -263,7 +263,7 @@ been triggered and run on your Pull Request:
263263
264264
You can click on the "Details" link to see the details of the running of the
265265
PipelineRun. `Pipelines-as-Code` will let you know that you can follow the logs
266-
on your Dashboard like [Tekton Dashboard](https://github.com/tekton/dashboard)
266+
on your Dashboard like [Tekton Dashboard](https://github.com/tektoncd/dashboard)
267267
or the OpenShift Pipelines
268268
[Console](https://docs.openshift.com/container-platform/latest/web_console/web-console.html)
269269
or if you prefer you can use [tekton CLI](https://tekton.dev/docs/cli/) to

docs/content/docs/install/second_controller.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Enterprise).
1313

1414
## Running a second controller with a different GitHub application
1515

16-
Each new installs for different GitHub applications have their own controller
16+
Each new install for different GitHub applications have their own controller
1717
with a Service and a
1818
[Ingress](https://kubernetes.io/docs/concepts/services-networking/ingress/) or
1919
a [OpenShift Route](https://docs.openshift.com/container-platform/latest/networking/routes/route-configuration.html)
@@ -70,7 +70,7 @@ This will output the generated yaml on the standard output, if you are happy
7070
with the output you can apply it on your cluster with `kubectl`:
7171

7272
```shell
73-
python3 ./hack/second-controller.py LABEL|kubectl -f-
73+
python3 ./hack/second-controller.py LABEL|kubectl apply -f -
7474
```
7575

7676
There is multiple flags you can use to fine grain the output of this script, use

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ require (
125125
go.uber.org/automaxprocs v1.6.0 // indirect
126126
go.uber.org/multierr v1.11.0 // indirect
127127
golang.org/x/crypto v0.35.0 // indirect
128-
golang.org/x/net v0.35.0 // indirect
128+
golang.org/x/net v0.36.0 // indirect
129129
golang.org/x/sys v0.30.0 // indirect
130130
golang.org/x/term v0.29.0 // indirect
131131
golang.org/x/time v0.10.0 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
623623
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
624624
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
625625
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
626-
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
627-
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
626+
golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA=
627+
golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I=
628628
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
629629
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
630630
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=

pkg/cmd/tknpac/list/list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ func list(ctx context.Context, cs *params.Run, opts *cli.PacCliOpts, ioStreams *
163163
repoStatuses = append(repoStatuses, rs)
164164
}
165165

166+
if len(repoStatuses) == 0 {
167+
return fmt.Errorf("no repo found")
168+
}
169+
166170
w := ansiterm.NewTabWriter(ioStreams.Out, 0, 5, 3, ' ', tabwriter.TabIndent)
167171
colorScheme := ioStreams.ColorScheme()
168172
data := struct {

pkg/cmd/tknpac/list/list_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
testclient "github.com/openshift-pipelines/pipelines-as-code/pkg/test/clients"
2121
tektontest "github.com/openshift-pipelines/pipelines-as-code/pkg/test/tekton"
2222
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
23+
"gotest.tools/v3/assert"
2324
"gotest.tools/v3/golden"
2425
corev1 "k8s.io/api/core/v1"
2526
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -120,8 +121,17 @@ func TestList(t *testing.T) {
120121
tests := []struct {
121122
name string
122123
args args
123-
wantErr bool
124+
wantErr string
124125
}{
126+
{
127+
name: "Test list when there are no repositories in the namespace",
128+
args: args{
129+
opts: &cli.PacCliOpts{
130+
Namespace: "default",
131+
},
132+
},
133+
wantErr: "no repo found",
134+
},
125135
{
126136
name: "Test list repositories only",
127137
args: args{
@@ -197,8 +207,8 @@ func TestList(t *testing.T) {
197207
cs.Clients.SetConsoleUI(consoleui.FallBackConsole{})
198208
io, out := newIOStream()
199209
if err := list(ctx, cs, tt.args.opts, io,
200-
cw, tt.args.selectors); (err != nil) != tt.wantErr {
201-
t.Errorf("describe() error = %v, wantErr %v", err, tt.wantErr)
210+
cw, tt.args.selectors); err != nil && tt.wantErr != "" {
211+
assert.Equal(t, err.Error(), tt.wantErr)
202212
} else {
203213
golden.Assert(t, out.String(), strings.ReplaceAll(fmt.Sprintf("%s.golden", t.Name()), "/", "-"))
204214
}

0 commit comments

Comments
 (0)