Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit ffb214a

Browse files
authored
Merge pull request #3 from gitops-tools/bump-tekton-dependencies
Bump to newest version of tektoncd/pipeline.
2 parents b90df42 + f407ece commit ffb214a

19 files changed

+852
-191
lines changed

go.mod

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@ go 1.14
44

55
require (
66
github.com/google/cel-go v0.5.1
7-
github.com/google/go-cmp v0.5.0
8-
github.com/jenkins-x/go-scm v1.5.146
9-
github.com/prometheus/client_golang v1.5.0
10-
github.com/spf13/cobra v0.0.6
11-
github.com/spf13/viper v1.6.2
12-
github.com/tektoncd/pipeline v0.14.1
7+
github.com/google/go-cmp v0.5.2
8+
github.com/jenkins-x/go-scm v1.5.196
9+
github.com/prometheus/client_golang v1.6.0
10+
github.com/spf13/cobra v1.0.0
11+
github.com/spf13/viper v1.7.0
12+
github.com/tektoncd/pipeline v0.18.1
1313
go.uber.org/zap v1.15.0
14-
k8s.io/api v0.17.6
15-
k8s.io/apimachinery v0.17.6
14+
k8s.io/api v0.18.8
15+
k8s.io/apimachinery v0.19.0
1616
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
17-
knative.dev/pkg v0.0.0-20200528142800-1c6815d7e4c9
17+
knative.dev/pkg v0.0.0-20200922164940-4bf40ad82aab
1818
sigs.k8s.io/yaml v1.2.0
1919
)
2020

21-
// Knative deps (release-0.15)
21+
// Knative deps (release-0.18)
2222
replace (
2323
contrib.go.opencensus.io/exporter/stackdriver => contrib.go.opencensus.io/exporter/stackdriver v0.12.9-0.20191108183826-59d068f8d8ff
2424
github.com/Azure/azure-sdk-for-go => github.com/Azure/azure-sdk-for-go v38.2.0+incompatible
2525
github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.4.0+incompatible
26-
knative.dev/caching => knative.dev/caching v0.0.0-20200521155757-e78d17bc250e
27-
knative.dev/pkg => knative.dev/pkg v0.0.0-20200528142800-1c6815d7e4c9
2826
)
2927

30-
// Pin k8s deps to 1.16.5
28+
// Pin k8s deps to v0.18.8
3129
replace (
32-
k8s.io/api => k8s.io/api v0.16.5
33-
k8s.io/apimachinery => k8s.io/apimachinery v0.16.5
34-
k8s.io/client-go => k8s.io/client-go v0.16.5
35-
k8s.io/code-generator => k8s.io/code-generator v0.16.5
36-
k8s.io/gengo => k8s.io/gengo v0.0.0-20190327210449-e17681d19d3a
30+
k8s.io/api => k8s.io/api v0.18.8
31+
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.8
32+
k8s.io/apimachinery => k8s.io/apimachinery v0.18.8
33+
k8s.io/apiserver => k8s.io/apiserver v0.18.8
34+
k8s.io/client-go => k8s.io/client-go v0.18.8
35+
k8s.io/code-generator => k8s.io/code-generator v0.18.8
36+
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
3737
)

go.sum

Lines changed: 660 additions & 53 deletions
Large diffs are not rendered by default.

pkg/dsl/dsl_handler.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/jenkins-x/go-scm/scm"
1212
pipelinev1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
1313
pipelineclientset "github.com/tektoncd/pipeline/pkg/client/clientset/versioned"
14+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1415

1516
"github.com/gitops-tools/tekton-ci/pkg/cel"
1617
"github.com/gitops-tools/tekton-ci/pkg/ci"
@@ -76,7 +77,12 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
7677
}
7778

7879
// NewDSLConverter creates and returns a converter.
79-
func NewDSLConverter(scmClient git.SCM, pipelineClient pipelineclientset.Interface, volumeCreator volumes.Creator, m metrics.Interface, cfg *Configuration, namespace string, l logger.Logger) *DSLConverter {
80+
func NewDSLConverter(
81+
scmClient git.SCM,
82+
pipelineClient pipelineclientset.Interface,
83+
volumeCreator volumes.Creator,
84+
m metrics.Interface, cfg *Configuration,
85+
namespace string, l logger.Logger) *DSLConverter {
8086
return &DSLConverter{
8187
pipelineClient: pipelineClient,
8288
volumeCreator: volumeCreator,
@@ -129,7 +135,7 @@ func (d *DSLConverter) convert(ctx context.Context, evt *scm.PushHook) (*pipelin
129135
return nil, nil
130136
}
131137

132-
vc, err := d.volumeCreator.Create(d.namespace, d.config.VolumeSize)
138+
vc, err := d.volumeCreator.Create(ctx, d.namespace, d.config.VolumeSize)
133139
if err != nil {
134140
d.log.Errorf("error creating volume: %s", err)
135141
return nil, nil
@@ -142,7 +148,7 @@ func (d *DSLConverter) convert(ctx context.Context, evt *scm.PushHook) (*pipelin
142148
if pr == nil {
143149
return nil, nil
144150
}
145-
created, err := d.pipelineClient.TektonV1beta1().PipelineRuns(d.namespace).Create(pr)
151+
created, err := d.pipelineClient.TektonV1beta1().PipelineRuns(d.namespace).Create(ctx, pr, metav1.CreateOptions{})
146152
if err != nil {
147153
d.log.Errorf("error creating pipelinerun file: %s", err)
148154
return nil, nil

pkg/dsl/dsl_handler_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dsl
22

33
import (
4+
"context"
45
"io/ioutil"
56
"net/http"
67
"net/http/httptest"
@@ -51,7 +52,7 @@ func TestHandlePushEvent(t *testing.T) {
5152
if w.StatusCode != http.StatusOK {
5253
t.Fatalf("got %d, want %d: %s", w.StatusCode, http.StatusNotFound, mustReadBody(t, w))
5354
}
54-
claim, err := fakeClient.CoreV1().PersistentVolumeClaims(testNS).Get("", metav1.GetOptions{})
55+
claim, err := fakeClient.CoreV1().PersistentVolumeClaims(testNS).Get(context.TODO(), "", metav1.GetOptions{})
5556
if err != nil {
5657
t.Fatal(err)
5758
}
@@ -77,7 +78,8 @@ func TestHandlePushEvent(t *testing.T) {
7778
if diff := cmp.Diff(wantClaim, claim, cmpopts.IgnoreFields(corev1.PersistentVolumeClaim{}, "TypeMeta")); diff != "" {
7879
t.Fatalf("persistent volume claim incorrect, diff\n%s", diff)
7980
}
80-
pr, err := fakeTektonClient.TektonV1beta1().PipelineRuns(testNS).Get("", metav1.GetOptions{})
81+
pr, err := fakeTektonClient.TektonV1beta1().PipelineRuns(testNS).Get(
82+
context.TODO(), "", metav1.GetOptions{})
8183
if err != nil {
8284
t.Fatal(err)
8385
}
@@ -125,7 +127,7 @@ func TestHandlePushEventNoPipeline(t *testing.T) {
125127
if w.StatusCode != http.StatusOK {
126128
t.Fatalf("got %d, want %d: %s", w.StatusCode, http.StatusOK, mustReadBody(t, w))
127129
}
128-
_, err = fakeTektonClient.TektonV1beta1().PipelineRuns(testNS).Get("", metav1.GetOptions{})
130+
_, err = fakeTektonClient.TektonV1beta1().PipelineRuns(testNS).Get(context.TODO(), "", metav1.GetOptions{})
129131
if !errors.IsNotFound(err) {
130132
t.Fatal("pipelinerun was created when no pipeline definition exists")
131133
}
@@ -154,7 +156,7 @@ func TestHandlePushEventNoMatchingRules(t *testing.T) {
154156
if w.StatusCode != http.StatusOK {
155157
t.Fatalf("got %d, want %d: %s", w.StatusCode, http.StatusOK, mustReadBody(t, w))
156158
}
157-
_, err = fakeTektonClient.TektonV1beta1().PipelineRuns(testNS).Get("", metav1.GetOptions{})
159+
_, err = fakeTektonClient.TektonV1beta1().PipelineRuns(testNS).Get(context.TODO(), "", metav1.GetOptions{})
158160
if !errors.IsNotFound(err) {
159161
t.Fatal("pipelinerun was created with no matching rules")
160162
}
@@ -185,7 +187,7 @@ func TestHandlePushEventWithSkippableMessage(t *testing.T) {
185187
if w.StatusCode != http.StatusOK {
186188
t.Fatalf("got %d, want %d: %s", w.StatusCode, http.StatusOK, mustReadBody(t, w))
187189
}
188-
_, err = fakeTektonClient.TektonV1beta1().PipelineRuns(testNS).Get("", metav1.GetOptions{})
190+
_, err = fakeTektonClient.TektonV1beta1().PipelineRuns(testNS).Get(context.TODO(), "", metav1.GetOptions{})
189191
if !errors.IsNotFound(err) {
190192
t.Fatalf("pipelinerun was created when the message indicated a skip")
191193
}

pkg/dsl/scripts.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,16 @@ func workspacePipelineTaskBindings() []pipelinev1.WorkspacePipelineTaskBinding {
216216
}
217217
}
218218

219-
func makeTaskSpec(steps ...pipelinev1.Step) *pipelinev1.TaskSpec {
220-
return &pipelinev1.TaskSpec{
221-
Workspaces: []pipelinev1.WorkspaceDeclaration{
222-
{
223-
Name: workspaceBindingName,
219+
func makeTaskSpec(steps ...pipelinev1.Step) *pipelinev1.EmbeddedTask {
220+
return &pipelinev1.EmbeddedTask{
221+
TaskSpec: pipelinev1.TaskSpec{
222+
Workspaces: []pipelinev1.WorkspaceDeclaration{
223+
{
224+
Name: workspaceBindingName,
225+
},
224226
},
227+
Steps: steps,
225228
},
226-
Steps: steps,
227229
}
228230
}
229231

pkg/dsl/scripts_test.go

Lines changed: 81 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,28 @@ func TestMakeGitCloneTask(t *testing.T) {
4040
Workspaces: []pipelinev1.WorkspacePipelineTaskBinding{
4141
{Name: "source", Workspace: workspaceName},
4242
},
43-
TaskSpec: &pipelinev1.TaskSpec{
44-
Workspaces: []pipelinev1.WorkspaceDeclaration{
45-
{
46-
Name: "source",
43+
TaskSpec: &pipelinev1.EmbeddedTask{
44+
TaskSpec: pipelinev1.TaskSpec{
45+
Workspaces: []pipelinev1.WorkspaceDeclaration{
46+
{
47+
Name: "source",
48+
},
4749
},
48-
},
49-
Steps: []pipelinev1.Step{
50-
{
51-
Container: corev1.Container{
52-
Name: "git-clone",
53-
Image: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init",
54-
Command: []string{"/ko-app/git-init", "-url", testRepoURL, "-revision", "master", "-path", workspaceSourcePath},
55-
Env: []corev1.EnvVar{
56-
{
57-
Name: "CI_PROJECT_DIR",
58-
Value: "$(workspaces.source.path)",
59-
},
60-
{
61-
Name: "TEKTON_RESOURCE_NAME",
62-
Value: "tekton-ci-git-clone",
50+
Steps: []pipelinev1.Step{
51+
{
52+
Container: corev1.Container{
53+
Name: "git-clone",
54+
Image: "gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init",
55+
Command: []string{"/ko-app/git-init", "-url", testRepoURL, "-revision", "master", "-path", workspaceSourcePath},
56+
Env: []corev1.EnvVar{
57+
{
58+
Name: "CI_PROJECT_DIR",
59+
Value: "$(workspaces.source.path)",
60+
},
61+
{
62+
Name: "TEKTON_RESOURCE_NAME",
63+
Value: "tekton-ci-git-clone",
64+
},
6365
},
6466
},
6567
},
@@ -91,21 +93,23 @@ func TestMakeScriptTask(t *testing.T) {
9193
Workspaces: []pipelinev1.WorkspacePipelineTaskBinding{
9294
{Name: "source", Workspace: workspaceName},
9395
},
94-
TaskSpec: &pipelinev1.TaskSpec{
95-
Workspaces: []pipelinev1.WorkspaceDeclaration{
96-
{
97-
Name: "source",
98-
},
99-
},
100-
Steps: []pipelinev1.Step{
101-
{
102-
Container: container("", "golang:latest", "sh", []string{"-c", "mkdir -p $GOPATH/src/$(dirname $REPO_NAME)"}, env, workspaceSourcePath),
103-
},
104-
{
105-
Container: container("", "golang:latest", "sh", []string{"-c", "ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME"}, env, workspaceSourcePath),
96+
TaskSpec: &pipelinev1.EmbeddedTask{
97+
TaskSpec: pipelinev1.TaskSpec{
98+
Workspaces: []pipelinev1.WorkspaceDeclaration{
99+
{
100+
Name: "source",
101+
},
106102
},
107-
{
108-
Container: container("", "golang:latest", "sh", []string{"-c", "cd $GOPATH/src/$REPO_NAME"}, env, workspaceSourcePath),
103+
Steps: []pipelinev1.Step{
104+
{
105+
Container: container("", "golang:latest", "sh", []string{"-c", "mkdir -p $GOPATH/src/$(dirname $REPO_NAME)"}, env, workspaceSourcePath),
106+
},
107+
{
108+
Container: container("", "golang:latest", "sh", []string{"-c", "ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME"}, env, workspaceSourcePath),
109+
},
110+
{
111+
Container: container("", "golang:latest", "sh", []string{"-c", "cd $GOPATH/src/$REPO_NAME"}, env, workspaceSourcePath),
112+
},
109113
},
110114
},
111115
},
@@ -182,50 +186,54 @@ func TestConvert(t *testing.T) {
182186
makeScriptTask(beforeStepTaskName, []string{gitCloneTaskName}, testEnv, p.Image, p.BeforeScript),
183187
{
184188
Name: "format-stage-test",
185-
TaskSpec: &pipelinev1.TaskSpec{
186-
Steps: []pipelinev1.Step{
187-
{
188-
Container: corev1.Container{
189-
Image: "golang:latest",
190-
Command: []string{"sh"},
191-
Args: []string{"-c", "go fmt $(go list ./... | grep -v /vendor/)"},
192-
WorkingDir: "$(workspaces.source.path)",
193-
Env: testEnv,
189+
TaskSpec: &pipelinev1.EmbeddedTask{
190+
TaskSpec: pipelinev1.TaskSpec{
191+
Steps: []pipelinev1.Step{
192+
{
193+
Container: corev1.Container{
194+
Image: "golang:latest",
195+
Command: []string{"sh"},
196+
Args: []string{"-c", "go fmt $(go list ./... | grep -v /vendor/)"},
197+
WorkingDir: "$(workspaces.source.path)",
198+
Env: testEnv,
199+
},
194200
},
195-
},
196-
{
197-
Container: corev1.Container{
198-
Image: "golang:latest",
199-
Command: []string{"sh"},
200-
Args: []string{"-c", "go vet $(go list ./... | grep -v /vendor/)"},
201-
WorkingDir: "$(workspaces.source.path)",
202-
Env: testEnv,
201+
{
202+
Container: corev1.Container{
203+
Image: "golang:latest",
204+
Command: []string{"sh"},
205+
Args: []string{"-c", "go vet $(go list ./... | grep -v /vendor/)"},
206+
WorkingDir: "$(workspaces.source.path)",
207+
Env: testEnv,
208+
},
203209
},
204-
},
205-
{
206-
Container: corev1.Container{
207-
Image: "golang:latest",
208-
Command: []string{"sh"},
209-
Args: []string{"-c", "go test -race $(go list ./... | grep -v /vendor/)"},
210-
WorkingDir: "$(workspaces.source.path)",
211-
Env: testEnv,
210+
{
211+
Container: corev1.Container{
212+
Image: "golang:latest",
213+
Command: []string{"sh"},
214+
Args: []string{"-c", "go test -race $(go list ./... | grep -v /vendor/)"},
215+
WorkingDir: "$(workspaces.source.path)",
216+
Env: testEnv,
217+
},
212218
},
213219
},
220+
Workspaces: []pipelinev1.WorkspaceDeclaration{{Name: "source"}},
214221
},
215-
Workspaces: []pipelinev1.WorkspaceDeclaration{{Name: "source"}},
216222
},
217223
RunAfter: []string{beforeStepTaskName},
218224
Workspaces: []pipelinev1.WorkspacePipelineTaskBinding{{Name: "source", Workspace: "git-checkout"}},
219225
},
220226
{
221227
Name: "compile-stage-build",
222-
TaskSpec: &pipelinev1.TaskSpec{
223-
Steps: []pipelinev1.Step{
224-
{
225-
Container: container("", "test-compile-image", "sh", []string{"-c", `go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary`}, testEnv, workspaceSourcePath),
228+
TaskSpec: &pipelinev1.EmbeddedTask{
229+
TaskSpec: pipelinev1.TaskSpec{
230+
Steps: []pipelinev1.Step{
231+
{
232+
Container: container("", "test-compile-image", "sh", []string{"-c", `go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/mybinary`}, testEnv, workspaceSourcePath),
233+
},
226234
},
235+
Workspaces: []pipelinev1.WorkspaceDeclaration{{Name: "source"}},
227236
},
228-
Workspaces: []pipelinev1.WorkspaceDeclaration{{Name: "source"}},
229237
},
230238
RunAfter: []string{"format-stage-test"},
231239
Workspaces: []pipelinev1.WorkspacePipelineTaskBinding{{Name: "source", Workspace: "git-checkout"}},
@@ -234,15 +242,17 @@ func TestConvert(t *testing.T) {
234242
Name: "compile-archiver",
235243
RunAfter: []string{"format-stage-test"},
236244
Workspaces: []pipelinev1.WorkspacePipelineTaskBinding{{Name: "source", Workspace: "git-checkout"}},
237-
TaskSpec: &pipelinev1.TaskSpec{
238-
Steps: []pipelinev1.Step{
239-
{
240-
Container: container("compile-archiver-archiver", testArchiverImage, "",
241-
[]string{"archive", "--bucket-url",
242-
testArchiveURL, "my-test-binary"}, testEnv, workspaceSourcePath),
245+
TaskSpec: &pipelinev1.EmbeddedTask{
246+
TaskSpec: pipelinev1.TaskSpec{
247+
Steps: []pipelinev1.Step{
248+
{
249+
Container: container("compile-archiver-archiver", testArchiverImage, "",
250+
[]string{"archive", "--bucket-url",
251+
testArchiveURL, "my-test-binary"}, testEnv, workspaceSourcePath),
252+
},
243253
},
254+
Workspaces: []pipelinev1.WorkspaceDeclaration{{Name: "source"}},
244255
},
245-
Workspaces: []pipelinev1.WorkspaceDeclaration{{Name: "source"}},
246256
},
247257
},
248258
makeScriptTask(afterStepTaskName, []string{"compile-archiver"}, testEnv, p.Image, p.AfterScript),

pkg/git/client.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ type SCMClient struct {
2525
// ParseWebhookRequest parses an incoming hook request and returns a parsed
2626
// hook response if one can be matched.
2727
func (c *SCMClient) ParseWebhookRequest(req *http.Request) (scm.Webhook, error) {
28-
hook, err := c.client.Webhooks.Parse(req, c.secrets.Secret)
28+
hook, err := c.client.Webhooks.Parse(req, func(hook scm.Webhook) (string, error) {
29+
return c.secrets.Secret(req.Context(), hook)
30+
})
2931
if err != nil {
3032
return nil, err
3133
}

pkg/secrets/interface.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package secrets
22

33
import (
4+
"context"
5+
46
"github.com/jenkins-x/go-scm/scm"
57
)
68

79
// SecretGetter is provided by values that implement Secret, to look up the
810
// correct secret for a Webhook in order to validate the origin of the Webhook.
911
type SecretGetter interface {
10-
Secret(hook scm.Webhook) (string, error)
12+
Secret(ctx context.Context, hook scm.Webhook) (string, error)
1113
}

0 commit comments

Comments
 (0)