Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f558347122
|
||
|
|
444c13376b
|
||
|
|
6e209bdcef
|
||
|
|
5fb1982930
|
||
|
|
ac3c23e65a | ||
|
|
3f2bdda8cb | ||
|
|
e7eeeefa53 | ||
|
|
a17f6502c0 | ||
|
|
16a39809e4 | ||
|
|
7dd0a9d0ad | ||
|
|
9d682cbe83 | ||
|
|
3ca037411a | ||
|
|
e991b259f2 | ||
|
|
f3b00c46ea | ||
|
|
e4463fe79d | ||
|
|
f18c1fe421 | ||
|
|
3c58d19a88 | ||
|
|
f07c0dc971 | ||
|
|
fd7b22c5ce | ||
|
|
1c082a5e24 | ||
|
|
9ed8905a5c | ||
|
|
8cb28459a0 | ||
|
|
753ad6dd05 | ||
|
|
dd4c20f0a7 | ||
|
|
c04b4e8da5 | ||
|
|
69dd1ba156 | ||
|
|
65c964b329 | ||
|
|
613026b326 | ||
|
|
cd56bb2fe1 |
@@ -14,6 +14,9 @@ spec:
|
|||||||
- name: image-name
|
- name: image-name
|
||||||
description: The name for the built image
|
description: The name for the built image
|
||||||
type: string
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
- name: path-to-image-context
|
- name: path-to-image-context
|
||||||
description: The path to the build context
|
description: The path to the build context
|
||||||
type: string
|
type: string
|
||||||
@@ -58,13 +61,11 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
params:
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: "$(params.JOB_NAME)"
|
value: "$(params.JOB_NAME)"
|
||||||
@@ -85,9 +86,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/git-clone/0.9/git-clone.yaml
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
workspaces:
|
workspaces:
|
||||||
@@ -100,43 +101,74 @@ spec:
|
|||||||
value: $(params.PULL_BASE_SHA)
|
value: $(params.PULL_BASE_SHA)
|
||||||
- name: deleteExisting
|
- name: deleteExisting
|
||||||
value: "true"
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
- name: build-image
|
- name: build-image
|
||||||
taskRef:
|
taskRef:
|
||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/kaniko/0.6//kaniko.yaml
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
params:
|
params:
|
||||||
- name: IMAGE
|
- name: OUTPUT
|
||||||
value: "$(params.image-name):$(tasks.detect-tag.results.tag)"
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.detect-tag.results.tag)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: $(params.path-to-image-context)
|
value: $(params.path-to-image-context)
|
||||||
- name: DOCKERFILE
|
- name: DOCKERFILE
|
||||||
value: $(params.path-to-dockerfile)
|
value: $(params.path-to-dockerfile)
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
- name: EXTRA_ARGS
|
||||||
value:
|
value:
|
||||||
- "--destination=$(params.image-name)" # Also write the :latest image
|
- "--opt"
|
||||||
- --cache=true
|
- "target=$(params.target-name)"
|
||||||
- --cache-copy-layers
|
- --import-cache
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
- --use-new-run # Should result in a speed-up
|
- --export-cache
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
- --snapshot-mode=redo
|
- --opt
|
||||||
- --skip-unused-stages=true
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: source
|
- name: source
|
||||||
workspace: git-source
|
workspace: git-source
|
||||||
- name: dockerconfig
|
- name: dockerconfig
|
||||||
workspace: docker-credentials
|
workspace: docker-credentials
|
||||||
runAfter:
|
runAfter:
|
||||||
- detect-tag
|
- fetch-repository
|
||||||
finally:
|
finally:
|
||||||
- name: report-success
|
- name: report-success
|
||||||
when:
|
when:
|
||||||
@@ -147,9 +179,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -176,9 +208,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -203,7 +235,7 @@ spec:
|
|||||||
- name: git-source
|
- name: git-source
|
||||||
volumeClaimTemplate:
|
volumeClaimTemplate:
|
||||||
spec:
|
spec:
|
||||||
storageClassName: "nfs-client"
|
storageClassName: "local-path"
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
@@ -216,7 +248,9 @@ spec:
|
|||||||
params:
|
params:
|
||||||
- name: image-name
|
- name: image-name
|
||||||
value: "harbor.fizz.buzz/private/webhook-bridge"
|
value: "harbor.fizz.buzz/private/webhook-bridge"
|
||||||
|
- name: target-name
|
||||||
|
value: ""
|
||||||
- name: path-to-image-context
|
- name: path-to-image-context
|
||||||
value: .
|
value: .
|
||||||
- name: path-to-dockerfile
|
- name: path-to-dockerfile
|
||||||
value: docker/webhook_bridge/Dockerfile
|
value: docker/webhook_bridge/
|
||||||
@@ -14,6 +14,9 @@ spec:
|
|||||||
- name: image-name
|
- name: image-name
|
||||||
description: The name for the built image
|
description: The name for the built image
|
||||||
type: string
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
- name: path-to-image-context
|
- name: path-to-image-context
|
||||||
description: The path to the build context
|
description: The path to the build context
|
||||||
type: string
|
type: string
|
||||||
@@ -26,13 +29,11 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
params:
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: "$(params.JOB_NAME)"
|
value: "$(params.JOB_NAME)"
|
||||||
@@ -53,9 +54,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/git-clone/0.9/git-clone.yaml
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
workspaces:
|
workspaces:
|
||||||
@@ -68,35 +69,67 @@ spec:
|
|||||||
value: $(params.PULL_BASE_SHA)
|
value: $(params.PULL_BASE_SHA)
|
||||||
- name: deleteExisting
|
- name: deleteExisting
|
||||||
value: "true"
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
- name: build-image
|
- name: build-image
|
||||||
taskRef:
|
taskRef:
|
||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/kaniko/0.6/kaniko.yaml
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
params:
|
params:
|
||||||
- name: IMAGE
|
- name: OUTPUT
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: $(params.path-to-image-context)
|
value: $(params.path-to-image-context)
|
||||||
- name: DOCKERFILE
|
- name: DOCKERFILE
|
||||||
value: $(params.path-to-dockerfile)
|
value: $(params.path-to-dockerfile)
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
- name: EXTRA_ARGS
|
||||||
value:
|
value:
|
||||||
- --cache=true
|
- "--opt"
|
||||||
- --cache-copy-layers
|
- "target=$(params.target-name)"
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
- --import-cache
|
||||||
- --use-new-run # Should result in a speed-up
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
- --export-cache
|
||||||
- --snapshot-mode=redo
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
- --skip-unused-stages=true
|
- --opt
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: source
|
- name: source
|
||||||
workspace: git-source
|
workspace: git-source
|
||||||
@@ -143,15 +176,15 @@ spec:
|
|||||||
- build-image
|
- build-image
|
||||||
params:
|
params:
|
||||||
- name: docker-image
|
- name: docker-image
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
- name: commit-changes
|
- name: commit-changes
|
||||||
taskRef:
|
taskRef:
|
||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/git-cli/0.4/git-cli.yaml
|
value: task/git-cli/0.4/git-cli.yaml
|
||||||
params:
|
params:
|
||||||
@@ -185,9 +218,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -214,9 +247,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -268,7 +301,7 @@ spec:
|
|||||||
workspace: cargo-cache
|
workspace: cargo-cache
|
||||||
params:
|
params:
|
||||||
- name: docker-image
|
- name: docker-image
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: git-source
|
- name: git-source
|
||||||
- name: docker-credentials
|
- name: docker-credentials
|
||||||
@@ -277,7 +310,7 @@ spec:
|
|||||||
- name: git-source
|
- name: git-source
|
||||||
volumeClaimTemplate:
|
volumeClaimTemplate:
|
||||||
spec:
|
spec:
|
||||||
storageClassName: "nfs-client"
|
storageClassName: "local-path"
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
@@ -292,8 +325,10 @@ spec:
|
|||||||
secretName: harbor-plain
|
secretName: harbor-plain
|
||||||
params:
|
params:
|
||||||
- name: image-name
|
- name: image-name
|
||||||
value: "harbor.fizz.buzz/private/webhook-bridge-development"
|
value: "harbor.fizz.buzz/private/webhook-bridge-development-format"
|
||||||
|
- name: target-name
|
||||||
|
value: ""
|
||||||
- name: path-to-image-context
|
- name: path-to-image-context
|
||||||
value: docker/webhook_bridge_development/
|
value: docker/webhook_bridge_development/
|
||||||
- name: path-to-dockerfile
|
- name: path-to-dockerfile
|
||||||
value: docker/webhook_bridge_development/Dockerfile
|
value: docker/webhook_bridge_development/
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ spec:
|
|||||||
- name: image-name
|
- name: image-name
|
||||||
description: The name for the built image
|
description: The name for the built image
|
||||||
type: string
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
- name: path-to-image-context
|
- name: path-to-image-context
|
||||||
description: The path to the build context
|
description: The path to the build context
|
||||||
type: string
|
type: string
|
||||||
@@ -26,13 +29,11 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
params:
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: "$(params.JOB_NAME)"
|
value: "$(params.JOB_NAME)"
|
||||||
@@ -53,9 +54,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/git-clone/0.9/git-clone.yaml
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
workspaces:
|
workspaces:
|
||||||
@@ -68,35 +69,67 @@ spec:
|
|||||||
value: $(params.PULL_BASE_SHA)
|
value: $(params.PULL_BASE_SHA)
|
||||||
- name: deleteExisting
|
- name: deleteExisting
|
||||||
value: "true"
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
- name: build-image
|
- name: build-image
|
||||||
taskRef:
|
taskRef:
|
||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/kaniko/0.6/kaniko.yaml
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
params:
|
params:
|
||||||
- name: IMAGE
|
- name: OUTPUT
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: $(params.path-to-image-context)
|
value: $(params.path-to-image-context)
|
||||||
- name: DOCKERFILE
|
- name: DOCKERFILE
|
||||||
value: $(params.path-to-dockerfile)
|
value: $(params.path-to-dockerfile)
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
- name: EXTRA_ARGS
|
||||||
value:
|
value:
|
||||||
- --cache=true
|
- "--opt"
|
||||||
- --cache-copy-layers
|
- "target=$(params.target-name)"
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
- --import-cache
|
||||||
- --use-new-run # Should result in a speed-up
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
- --export-cache
|
||||||
- --snapshot-mode=redo
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
- --skip-unused-stages=true
|
- --opt
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: source
|
- name: source
|
||||||
workspace: git-source
|
workspace: git-source
|
||||||
@@ -153,7 +186,7 @@ spec:
|
|||||||
- build-image
|
- build-image
|
||||||
params:
|
params:
|
||||||
- name: docker-image
|
- name: docker-image
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
finally:
|
finally:
|
||||||
- name: report-success
|
- name: report-success
|
||||||
when:
|
when:
|
||||||
@@ -164,9 +197,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -193,9 +226,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -247,7 +280,7 @@ spec:
|
|||||||
workspace: cargo-cache
|
workspace: cargo-cache
|
||||||
params:
|
params:
|
||||||
- name: docker-image
|
- name: docker-image
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: git-source
|
- name: git-source
|
||||||
- name: docker-credentials
|
- name: docker-credentials
|
||||||
@@ -256,7 +289,7 @@ spec:
|
|||||||
- name: git-source
|
- name: git-source
|
||||||
volumeClaimTemplate:
|
volumeClaimTemplate:
|
||||||
spec:
|
spec:
|
||||||
storageClassName: "nfs-client"
|
storageClassName: "local-path"
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
@@ -271,8 +304,10 @@ spec:
|
|||||||
secretName: harbor-plain
|
secretName: harbor-plain
|
||||||
params:
|
params:
|
||||||
- name: image-name
|
- name: image-name
|
||||||
value: "harbor.fizz.buzz/private/webhook-bridge-development"
|
value: "harbor.fizz.buzz/private/webhook-bridge-development-clippy"
|
||||||
|
- name: target-name
|
||||||
|
value: ""
|
||||||
- name: path-to-image-context
|
- name: path-to-image-context
|
||||||
value: docker/webhook_bridge_development/
|
value: docker/webhook_bridge_development/
|
||||||
- name: path-to-dockerfile
|
- name: path-to-dockerfile
|
||||||
value: docker/webhook_bridge_development/Dockerfile
|
value: docker/webhook_bridge_development/
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ spec:
|
|||||||
- name: image-name
|
- name: image-name
|
||||||
description: The name for the built image
|
description: The name for the built image
|
||||||
type: string
|
type: string
|
||||||
|
- name: target-name
|
||||||
|
description: The dockerfile target to build
|
||||||
|
type: string
|
||||||
- name: path-to-image-context
|
- name: path-to-image-context
|
||||||
description: The path to the build context
|
description: The path to the build context
|
||||||
type: string
|
type: string
|
||||||
@@ -26,13 +29,11 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
params:
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: "$(params.JOB_NAME)"
|
value: "$(params.JOB_NAME)"
|
||||||
@@ -53,9 +54,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/git-clone/0.9/git-clone.yaml
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
workspaces:
|
workspaces:
|
||||||
@@ -68,35 +69,67 @@ spec:
|
|||||||
value: $(params.PULL_BASE_SHA)
|
value: $(params.PULL_BASE_SHA)
|
||||||
- name: deleteExisting
|
- name: deleteExisting
|
||||||
value: "true"
|
value: "true"
|
||||||
|
- name: get-git-commit-time
|
||||||
|
taskSpec:
|
||||||
|
metadata: {}
|
||||||
|
stepTemplate:
|
||||||
|
image: alpine:3.20
|
||||||
|
computeResources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 600Mi
|
||||||
|
workingDir: "$(workspaces.repo.path)"
|
||||||
|
results:
|
||||||
|
- name: unix-time
|
||||||
|
description: The time of the git commit in unix timestamp format.
|
||||||
|
steps:
|
||||||
|
- image: alpine/git:v2.34.2
|
||||||
|
name: detect-tag-step
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
set -euo pipefail
|
||||||
|
echo -n "$(git log -1 --pretty=%ct)" | tee $(results.unix-time.path)
|
||||||
|
workspaces:
|
||||||
|
- name: repo
|
||||||
|
workspace: git-source
|
||||||
|
runAfter:
|
||||||
|
- fetch-repository
|
||||||
- name: build-image
|
- name: build-image
|
||||||
taskRef:
|
taskRef:
|
||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/talexander/personal_tekton_catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: 7ee31a185243ee6da13dcd26a592c585b64c80e5
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/kaniko/0.6//kaniko.yaml
|
value: task/buildkit-rootless-daemonless/0.1/buildkit-rootless-daemonless.yaml
|
||||||
params:
|
params:
|
||||||
- name: IMAGE
|
- name: OUTPUT
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: >-
|
||||||
|
type=image,"name=$(params.image-name):latest,$(params.image-name):$(tasks.fetch-repository.results.commit)",push=true,compression=zstd,compression-level=22,oci-mediatypes=true
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: $(params.path-to-image-context)
|
value: $(params.path-to-image-context)
|
||||||
- name: DOCKERFILE
|
- name: DOCKERFILE
|
||||||
value: $(params.path-to-dockerfile)
|
value: $(params.path-to-dockerfile)
|
||||||
- name: BUILDER_IMAGE
|
|
||||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
|
||||||
- name: EXTRA_ARGS
|
- name: EXTRA_ARGS
|
||||||
value:
|
value:
|
||||||
- --cache=true
|
- "--opt"
|
||||||
- --cache-copy-layers
|
- "target=$(params.target-name)"
|
||||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
- --import-cache
|
||||||
- --use-new-run # Should result in a speed-up
|
- "type=registry,ref=$(params.image-name):buildcache"
|
||||||
- --reproducible # To remove timestamps so layer caching works.
|
- --export-cache
|
||||||
- --snapshot-mode=redo
|
- "type=registry,ref=$(params.image-name):buildcache,mode=max,compression=zstd,compression-level=22,rewrite-timestamp=true,image-manifest=true,oci-mediatypes=true"
|
||||||
- --skip-unused-stages=true
|
- --opt
|
||||||
- --registry-mirror=dockerhub.dockerhub.svc.cluster.local
|
- build-arg:SOURCE_DATE_EPOCH=$(tasks.get-git-commit-time.results.unix-time)
|
||||||
|
- name: BUILDKITD_TOML
|
||||||
|
value: |
|
||||||
|
debug = true
|
||||||
|
[registry."docker.io"]
|
||||||
|
mirrors = ["dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
[registry."dockerhub.dockerhub.svc.cluster.local"]
|
||||||
|
http = true
|
||||||
|
insecure = true
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: source
|
- name: source
|
||||||
workspace: git-source
|
workspace: git-source
|
||||||
@@ -143,7 +176,7 @@ spec:
|
|||||||
- build-image
|
- build-image
|
||||||
params:
|
params:
|
||||||
- name: docker-image
|
- name: docker-image
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
finally:
|
finally:
|
||||||
- name: report-success
|
- name: report-success
|
||||||
when:
|
when:
|
||||||
@@ -154,9 +187,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -183,9 +216,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -237,7 +270,7 @@ spec:
|
|||||||
workspace: cargo-cache
|
workspace: cargo-cache
|
||||||
params:
|
params:
|
||||||
- name: docker-image
|
- name: docker-image
|
||||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
value: "$(tasks.build-image.results.IMAGE_URL[1])"
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: git-source
|
- name: git-source
|
||||||
- name: docker-credentials
|
- name: docker-credentials
|
||||||
@@ -246,7 +279,7 @@ spec:
|
|||||||
- name: git-source
|
- name: git-source
|
||||||
volumeClaimTemplate:
|
volumeClaimTemplate:
|
||||||
spec:
|
spec:
|
||||||
storageClassName: "nfs-client"
|
storageClassName: "local-path"
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
@@ -261,8 +294,10 @@ spec:
|
|||||||
secretName: harbor-plain
|
secretName: harbor-plain
|
||||||
params:
|
params:
|
||||||
- name: image-name
|
- name: image-name
|
||||||
value: "harbor.fizz.buzz/private/webhook-bridge-development"
|
value: "harbor.fizz.buzz/private/webhook-bridge-development-test"
|
||||||
|
- name: target-name
|
||||||
|
value: ""
|
||||||
- name: path-to-image-context
|
- name: path-to-image-context
|
||||||
value: docker/webhook_bridge_development/
|
value: docker/webhook_bridge_development/
|
||||||
- name: path-to-dockerfile
|
- name: path-to-dockerfile
|
||||||
value: docker/webhook_bridge_development/Dockerfile
|
value: docker/webhook_bridge_development/
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ spec:
|
|||||||
tasks:
|
tasks:
|
||||||
- name: calculate-tag
|
- name: calculate-tag
|
||||||
runAfter:
|
runAfter:
|
||||||
- report-pending
|
- fetch-repository
|
||||||
workspaces:
|
workspaces:
|
||||||
- name: source
|
- name: source
|
||||||
workspace: git-source
|
workspace: git-source
|
||||||
@@ -72,13 +72,11 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
runAfter:
|
|
||||||
- fetch-repository
|
|
||||||
params:
|
params:
|
||||||
- name: CONTEXT
|
- name: CONTEXT
|
||||||
value: "$(params.JOB_NAME)"
|
value: "$(params.JOB_NAME)"
|
||||||
@@ -99,9 +97,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/git-clone/0.9/git-clone.yaml
|
value: task/git-clone/0.9/git-clone.yaml
|
||||||
workspaces:
|
workspaces:
|
||||||
@@ -124,9 +122,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -153,9 +151,9 @@ spec:
|
|||||||
resolver: git
|
resolver: git
|
||||||
params:
|
params:
|
||||||
- name: url
|
- name: url
|
||||||
value: https://github.com/tektoncd/catalog.git
|
value: https://code.fizz.buzz/mirror/catalog.git # mirror of https://github.com/tektoncd/catalog.git
|
||||||
- name: revision
|
- name: revision
|
||||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
value: f914437a46978b95f325f68d791dcf1a35738f60
|
||||||
- name: pathInRepo
|
- name: pathInRepo
|
||||||
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
value: task/gitea-set-status/0.1/gitea-set-status.yaml
|
||||||
params:
|
params:
|
||||||
@@ -179,7 +177,7 @@ spec:
|
|||||||
- name: git-source
|
- name: git-source
|
||||||
volumeClaimTemplate:
|
volumeClaimTemplate:
|
||||||
spec:
|
spec:
|
||||||
storageClassName: "nfs-client"
|
storageClassName: "local-path"
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
- ReadWriteOnce
|
||||||
resources:
|
resources:
|
||||||
|
|||||||
@@ -26,6 +26,6 @@ version = "0.0.1"
|
|||||||
|
|
||||||
[[push]]
|
[[push]]
|
||||||
name = "build"
|
name = "build"
|
||||||
source = "pipeline-build.yaml"
|
source = "pipeline-build-semver.yaml"
|
||||||
clone_uri = "git@code.fizz.buzz:talexander/webhook_bridge.git"
|
clone_uri = "git@code.fizz.buzz:talexander/webhook_bridge.git"
|
||||||
branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
||||||
|
|||||||
11
Cargo.toml
11
Cargo.toml
@@ -1,5 +1,3 @@
|
|||||||
cargo-features = ["codegen-backend"]
|
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "webhook_bridge"
|
name = "webhook_bridge"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
@@ -38,7 +36,7 @@ default = ["local_trigger"]
|
|||||||
local_trigger = []
|
local_trigger = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = { version = "0.7.5", default-features = false, features = ["tokio", "http1", "http2", "json"] }
|
axum = { version = "0.7.5", default-features = false, features = ["tokio", "http1", "json"] }
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
http-body-util = "0.1.2"
|
http-body-util = "0.1.2"
|
||||||
@@ -61,10 +59,3 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
|
|||||||
inherits = "release"
|
inherits = "release"
|
||||||
lto = true
|
lto = true
|
||||||
strip = "symbols"
|
strip = "symbols"
|
||||||
|
|
||||||
[profile.dev]
|
|
||||||
codegen-backend = "cranelift"
|
|
||||||
|
|
||||||
[profile.dev.package."*"]
|
|
||||||
codegen-backend = "llvm"
|
|
||||||
opt-level = 3
|
|
||||||
|
|||||||
1
Makefile
1
Makefile
@@ -33,3 +33,4 @@ format: ## Auto-format source files.
|
|||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
> $(MAKE) -C docker/webhook_bridge_development clean
|
> $(MAKE) -C docker/webhook_bridge_development clean
|
||||||
|
> rm -rf target
|
||||||
|
|||||||
@@ -1,15 +1,36 @@
|
|||||||
FROM rustlang/rust:nightly-alpine3.20 AS builder
|
#
|
||||||
|
# Builder
|
||||||
|
#
|
||||||
|
|
||||||
RUN apk add --no-cache musl-dev pkgconfig libressl-dev
|
FROM nixos/nix:latest AS builder
|
||||||
|
|
||||||
RUN mkdir /source
|
COPY . /tmp/build
|
||||||
WORKDIR /source
|
WORKDIR /tmp/build
|
||||||
COPY . .
|
|
||||||
# TODO: Add static build, which currently errors due to proc_macro. RUSTFLAGS="-C target-feature=+crt-static"
|
|
||||||
RUN CARGO_TARGET_DIR=/target cargo build --profile release-lto --bin webhook_bridge
|
|
||||||
|
|
||||||
FROM alpine:3.20 AS runner
|
RUN nix \
|
||||||
|
--extra-experimental-features "nix-command flakes" \
|
||||||
|
--option filter-syscalls false \
|
||||||
|
build '.#docker_env'
|
||||||
|
|
||||||
COPY --from=builder /target/release-lto/webhook_bridge /usr/bin/
|
# Export the built closure to a folder
|
||||||
|
RUN mkdir /tmp/nix-store-closure
|
||||||
|
RUN cp -R $(nix-store -qR result/) /tmp/nix-store-closure
|
||||||
|
RUN ln -s $(readlink -f /tmp/build/result/bin/sh) /tmp/sh
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/bin/webhook_bridge"]
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Runner
|
||||||
|
#
|
||||||
|
|
||||||
|
FROM scratch
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV PATH="$PATH:/app/bin"
|
||||||
|
|
||||||
|
COPY --from=builder /tmp/nix-store-closure /nix/store
|
||||||
|
COPY --from=builder /tmp/build/result /app
|
||||||
|
COPY --from=builder /tmp/sh /bin/sh
|
||||||
|
EXPOSE 9988
|
||||||
|
CMD ["/app/bin/webhook_bridge"]
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
FROM rustlang/rust:nightly-alpine3.20 AS builder
|
# syntax=docker/dockerfile:1
|
||||||
|
ARG ALPINE_VERSION="3.20"
|
||||||
|
|
||||||
|
FROM rustlang/rust:nightly-alpine$ALPINE_VERSION AS builder
|
||||||
|
|
||||||
RUN apk add --no-cache musl-dev pkgconfig libressl3.8-libssl libressl-dev
|
RUN apk add --no-cache musl-dev pkgconfig libressl3.8-libssl libressl-dev
|
||||||
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
RUN --mount=type=tmpfs,target=/tmp --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||||
RUN rustup component add rustfmt
|
RUN rustup component add rustfmt
|
||||||
RUN rustup component add clippy
|
RUN rustup component add clippy
|
||||||
|
|||||||
@@ -1,165 +0,0 @@
|
|||||||
{
|
|
||||||
"ref": "refs/tags/v0.0.2",
|
|
||||||
"before": "0000000000000000000000000000000000000000",
|
|
||||||
"after": "84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
|
||||||
"compare_url": "https://code.fizz.buzz/talexander/webhook_bridge/compare/0000000000000000000000000000000000000000...84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
|
||||||
"commits": [],
|
|
||||||
"total_commits": 0,
|
|
||||||
"head_commit": {
|
|
||||||
"id": "84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
|
||||||
"message": "Add a pipeline to build the server image.\n",
|
|
||||||
"url": "https://code.fizz.buzz/talexander/webhook_bridge/commit/84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
|
||||||
"author": {
|
|
||||||
"name": "Tom Alexander",
|
|
||||||
"email": "tom@fizz.buzz",
|
|
||||||
"username": ""
|
|
||||||
},
|
|
||||||
"committer": {
|
|
||||||
"name": "Tom Alexander",
|
|
||||||
"email": "tom@fizz.buzz",
|
|
||||||
"username": ""
|
|
||||||
},
|
|
||||||
"verification": null,
|
|
||||||
"timestamp": "2024-09-29T00:19:22-04:00",
|
|
||||||
"added": [
|
|
||||||
".webhook_bridge/pipeline-build.yaml"
|
|
||||||
],
|
|
||||||
"removed": [],
|
|
||||||
"modified": [
|
|
||||||
".webhook_bridge/webhook_bridge.toml"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"id": 21,
|
|
||||||
"owner": {
|
|
||||||
"id": 1,
|
|
||||||
"login": "talexander",
|
|
||||||
"login_name": "",
|
|
||||||
"full_name": "",
|
|
||||||
"email": "gitea@local.domain",
|
|
||||||
"avatar_url": "https://code.fizz.buzz/avatars/9d402a89b5a0786f83c1b8c5486fc7ff3d083a54fe20e55c0a776a1932c30289",
|
|
||||||
"language": "",
|
|
||||||
"is_admin": false,
|
|
||||||
"last_login": "0001-01-01T00:00:00Z",
|
|
||||||
"created": "2023-07-05T22:03:28Z",
|
|
||||||
"restricted": false,
|
|
||||||
"active": false,
|
|
||||||
"prohibit_login": false,
|
|
||||||
"location": "",
|
|
||||||
"website": "",
|
|
||||||
"description": "",
|
|
||||||
"visibility": "public",
|
|
||||||
"followers_count": 0,
|
|
||||||
"following_count": 0,
|
|
||||||
"starred_repos_count": 0,
|
|
||||||
"username": "talexander"
|
|
||||||
},
|
|
||||||
"name": "webhook_bridge",
|
|
||||||
"full_name": "talexander/webhook_bridge",
|
|
||||||
"description": "A server that receives webhooks from gitea and fires off Tekton jobs in response.",
|
|
||||||
"empty": false,
|
|
||||||
"private": false,
|
|
||||||
"fork": false,
|
|
||||||
"template": false,
|
|
||||||
"parent": null,
|
|
||||||
"mirror": false,
|
|
||||||
"size": 346,
|
|
||||||
"language": "",
|
|
||||||
"languages_url": "https://code.fizz.buzz/api/v1/repos/talexander/webhook_bridge/languages",
|
|
||||||
"html_url": "https://code.fizz.buzz/talexander/webhook_bridge",
|
|
||||||
"url": "https://code.fizz.buzz/api/v1/repos/talexander/webhook_bridge",
|
|
||||||
"link": "",
|
|
||||||
"ssh_url": "git@code.fizz.buzz:talexander/webhook_bridge.git",
|
|
||||||
"clone_url": "https://code.fizz.buzz/talexander/webhook_bridge.git",
|
|
||||||
"original_url": "",
|
|
||||||
"website": "",
|
|
||||||
"stars_count": 0,
|
|
||||||
"forks_count": 0,
|
|
||||||
"watchers_count": 1,
|
|
||||||
"open_issues_count": 0,
|
|
||||||
"open_pr_counter": 0,
|
|
||||||
"release_counter": 0,
|
|
||||||
"default_branch": "main",
|
|
||||||
"archived": false,
|
|
||||||
"created_at": "2024-07-14T18:48:52Z",
|
|
||||||
"updated_at": "2024-09-29T04:25:36Z",
|
|
||||||
"archived_at": "1970-01-01T00:00:00Z",
|
|
||||||
"permissions": {
|
|
||||||
"admin": true,
|
|
||||||
"push": true,
|
|
||||||
"pull": true
|
|
||||||
},
|
|
||||||
"has_issues": true,
|
|
||||||
"internal_tracker": {
|
|
||||||
"enable_time_tracker": true,
|
|
||||||
"allow_only_contributors_to_track_time": true,
|
|
||||||
"enable_issue_dependencies": true
|
|
||||||
},
|
|
||||||
"has_wiki": true,
|
|
||||||
"has_pull_requests": true,
|
|
||||||
"has_projects": true,
|
|
||||||
"has_releases": true,
|
|
||||||
"has_packages": true,
|
|
||||||
"has_actions": false,
|
|
||||||
"ignore_whitespace_conflicts": false,
|
|
||||||
"allow_merge_commits": true,
|
|
||||||
"allow_rebase": true,
|
|
||||||
"allow_rebase_explicit": true,
|
|
||||||
"allow_squash_merge": true,
|
|
||||||
"allow_rebase_update": true,
|
|
||||||
"default_delete_branch_after_merge": false,
|
|
||||||
"default_merge_style": "merge",
|
|
||||||
"default_allow_maintainer_edit": false,
|
|
||||||
"avatar_url": "",
|
|
||||||
"internal": false,
|
|
||||||
"mirror_interval": "",
|
|
||||||
"mirror_updated": "0001-01-01T00:00:00Z",
|
|
||||||
"repo_transfer": null
|
|
||||||
},
|
|
||||||
"pusher": {
|
|
||||||
"id": 2,
|
|
||||||
"login": "build-bot",
|
|
||||||
"login_name": "",
|
|
||||||
"full_name": "",
|
|
||||||
"email": "build-bot@noreply.code.fizz.buzz",
|
|
||||||
"avatar_url": "https://secure.gravatar.com/avatar/e39ef2faba8a3dfb3dcb4d8275a532d4?d=identicon",
|
|
||||||
"language": "",
|
|
||||||
"is_admin": false,
|
|
||||||
"last_login": "0001-01-01T00:00:00Z",
|
|
||||||
"created": "2023-07-09T04:25:44Z",
|
|
||||||
"restricted": false,
|
|
||||||
"active": false,
|
|
||||||
"prohibit_login": false,
|
|
||||||
"location": "",
|
|
||||||
"website": "",
|
|
||||||
"description": "",
|
|
||||||
"visibility": "private",
|
|
||||||
"followers_count": 0,
|
|
||||||
"following_count": 0,
|
|
||||||
"starred_repos_count": 0,
|
|
||||||
"username": "build-bot"
|
|
||||||
},
|
|
||||||
"sender": {
|
|
||||||
"id": 2,
|
|
||||||
"login": "build-bot",
|
|
||||||
"login_name": "",
|
|
||||||
"full_name": "",
|
|
||||||
"email": "build-bot@noreply.code.fizz.buzz",
|
|
||||||
"avatar_url": "https://secure.gravatar.com/avatar/e39ef2faba8a3dfb3dcb4d8275a532d4?d=identicon",
|
|
||||||
"language": "",
|
|
||||||
"is_admin": false,
|
|
||||||
"last_login": "0001-01-01T00:00:00Z",
|
|
||||||
"created": "2023-07-09T04:25:44Z",
|
|
||||||
"restricted": false,
|
|
||||||
"active": false,
|
|
||||||
"prohibit_login": false,
|
|
||||||
"location": "",
|
|
||||||
"website": "",
|
|
||||||
"description": "",
|
|
||||||
"visibility": "private",
|
|
||||||
"followers_count": 0,
|
|
||||||
"following_count": 0,
|
|
||||||
"starred_repos_count": 0,
|
|
||||||
"username": "build-bot"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
48
flake.lock
generated
Normal file
48
flake.lock
generated
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1777578337,
|
||||||
|
"narHash": "sha256-Ad49moKWeXtKBJNy2ebiTQUEgdLyvGmTeykAQ9xM+Z4=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "15f4ee454b1dce334612fa6843b3e05cf546efab",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1777691680,
|
||||||
|
"narHash": "sha256-sdCAzrPAaKu+yo7L2pWddy5PN6U9bO++WEWc1zcr7aQ=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "4757db4358c77c1cbe878fa5990e6ea88d82f6b5",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
92
flake.nix
Normal file
92
flake.nix
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
{
|
||||||
|
description = "webhook-bridge development environment";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
rust-overlay,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
forAllSystems =
|
||||||
|
func:
|
||||||
|
builtins.listToAttrs (
|
||||||
|
map (system: {
|
||||||
|
name = system;
|
||||||
|
value = func system;
|
||||||
|
}) nixpkgs.lib.systems.flakeExposed
|
||||||
|
);
|
||||||
|
in
|
||||||
|
{
|
||||||
|
devShells = forAllSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
overlays = [ (import rust-overlay) ];
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkgs.pkg-config
|
||||||
|
rustToolchain
|
||||||
|
pkgs.openssl
|
||||||
|
];
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
# sqlx-cli # For sqlx CLI to manage migrations
|
||||||
|
# sqlite # To access the database (sqlite is bundled into the together_alone binary but this is for manually accessing the db).
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
packages = forAllSystems (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
overlays = [ (import rust-overlay) ];
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
app = pkgs.rustPlatform.buildRustPackage {
|
||||||
|
pname = "webhook-bridge";
|
||||||
|
version = "0.0.0";
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
# If you have a Cargo.lock file, use this:
|
||||||
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkgs.pkg-config
|
||||||
|
];
|
||||||
|
buildInputs = [
|
||||||
|
pkgs.openssl
|
||||||
|
];
|
||||||
|
};
|
||||||
|
docker_env = pkgs.buildEnv {
|
||||||
|
name = "webhook-bridge";
|
||||||
|
paths = with pkgs; [
|
||||||
|
app
|
||||||
|
bash
|
||||||
|
uutils-coreutils-noprefix
|
||||||
|
# toybox # Smaller than uutils-coreutils?
|
||||||
|
];
|
||||||
|
};
|
||||||
|
default = app;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"ref": "refs/heads/main",
|
"ref": "refs/heads/main",
|
||||||
"before": "a2aca6d2f1c85b5d4bef1349230fdaef1683622d",
|
"before": "6eac598600c436d33de295d5b5f05b444beb2d3d",
|
||||||
"after": "84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
"after": "1f52dd8995987337a3a33ce675625647545490c2",
|
||||||
"compare_url": "https://code.fizz.buzz/talexander/webhook_bridge/compare/a2aca6d2f1c85b5d4bef1349230fdaef1683622d...84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
"compare_url": "https://code.fizz.buzz/talexander/webhook_bridge/compare/6eac598600c436d33de295d5b5f05b444beb2d3d...1f52dd8995987337a3a33ce675625647545490c2",
|
||||||
"commits": [
|
"commits": [
|
||||||
{
|
{
|
||||||
"id": "84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
"id": "1f52dd8995987337a3a33ce675625647545490c2",
|
||||||
"message": "Add a pipeline to build the server image.\n",
|
"message": "Update to the latest catalog.\n",
|
||||||
"url": "https://code.fizz.buzz/talexander/webhook_bridge/commit/84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
"url": "https://code.fizz.buzz/talexander/webhook_bridge/commit/1f52dd8995987337a3a33ce675625647545490c2",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Tom Alexander",
|
"name": "Tom Alexander",
|
||||||
"email": "tom@fizz.buzz",
|
"email": "tom@fizz.buzz",
|
||||||
@@ -19,21 +19,24 @@
|
|||||||
"username": ""
|
"username": ""
|
||||||
},
|
},
|
||||||
"verification": null,
|
"verification": null,
|
||||||
"timestamp": "2024-09-29T00:19:22-04:00",
|
"timestamp": "2026-05-02T17:50:49-04:00",
|
||||||
"added": [
|
"added": [],
|
||||||
".webhook_bridge/pipeline-build.yaml"
|
|
||||||
],
|
|
||||||
"removed": [],
|
"removed": [],
|
||||||
"modified": [
|
"modified": [
|
||||||
".webhook_bridge/webhook_bridge.toml"
|
".webhook_bridge/pipeline-build-semver.yaml",
|
||||||
|
".webhook_bridge/pipeline-format.yaml",
|
||||||
|
".webhook_bridge/pipeline-rust-clippy.yaml",
|
||||||
|
".webhook_bridge/pipeline-rust-test.yaml",
|
||||||
|
".webhook_bridge/pipeline-semver.yaml",
|
||||||
|
"local_payload.json"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"total_commits": 1,
|
"total_commits": 1,
|
||||||
"head_commit": {
|
"head_commit": {
|
||||||
"id": "84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
"id": "1f52dd8995987337a3a33ce675625647545490c2",
|
||||||
"message": "Add a pipeline to build the server image.\n",
|
"message": "Update to the latest catalog.\n",
|
||||||
"url": "https://code.fizz.buzz/talexander/webhook_bridge/commit/84fe1ec23ae242cb1bbccbc2ab999c3082f54d45",
|
"url": "https://code.fizz.buzz/talexander/webhook_bridge/commit/1f52dd8995987337a3a33ce675625647545490c2",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Tom Alexander",
|
"name": "Tom Alexander",
|
||||||
"email": "tom@fizz.buzz",
|
"email": "tom@fizz.buzz",
|
||||||
@@ -45,13 +48,16 @@
|
|||||||
"username": ""
|
"username": ""
|
||||||
},
|
},
|
||||||
"verification": null,
|
"verification": null,
|
||||||
"timestamp": "2024-09-29T00:19:22-04:00",
|
"timestamp": "2026-05-02T17:50:49-04:00",
|
||||||
"added": [
|
"added": [],
|
||||||
".webhook_bridge/pipeline-build.yaml"
|
|
||||||
],
|
|
||||||
"removed": [],
|
"removed": [],
|
||||||
"modified": [
|
"modified": [
|
||||||
".webhook_bridge/webhook_bridge.toml"
|
".webhook_bridge/pipeline-build-semver.yaml",
|
||||||
|
".webhook_bridge/pipeline-format.yaml",
|
||||||
|
".webhook_bridge/pipeline-rust-clippy.yaml",
|
||||||
|
".webhook_bridge/pipeline-rust-test.yaml",
|
||||||
|
".webhook_bridge/pipeline-semver.yaml",
|
||||||
|
"local_payload.json"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -60,9 +66,11 @@
|
|||||||
"id": 1,
|
"id": 1,
|
||||||
"login": "talexander",
|
"login": "talexander",
|
||||||
"login_name": "",
|
"login_name": "",
|
||||||
|
"source_id": 0,
|
||||||
"full_name": "",
|
"full_name": "",
|
||||||
"email": "gitea@local.domain",
|
"email": "gitea@local.domain",
|
||||||
"avatar_url": "https://code.fizz.buzz/avatars/9d402a89b5a0786f83c1b8c5486fc7ff3d083a54fe20e55c0a776a1932c30289",
|
"avatar_url": "https://code.fizz.buzz/avatars/9d402a89b5a0786f83c1b8c5486fc7ff3d083a54fe20e55c0a776a1932c30289",
|
||||||
|
"html_url": "https://code.fizz.buzz/talexander",
|
||||||
"language": "",
|
"language": "",
|
||||||
"is_admin": false,
|
"is_admin": false,
|
||||||
"last_login": "0001-01-01T00:00:00Z",
|
"last_login": "0001-01-01T00:00:00Z",
|
||||||
@@ -86,15 +94,14 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"fork": false,
|
"fork": false,
|
||||||
"template": false,
|
"template": false,
|
||||||
"parent": null,
|
|
||||||
"mirror": false,
|
"mirror": false,
|
||||||
"size": 343,
|
"size": 179,
|
||||||
"language": "",
|
"language": "",
|
||||||
"languages_url": "https://code.fizz.buzz/api/v1/repos/talexander/webhook_bridge/languages",
|
"languages_url": "https://code.fizz.buzz/api/v1/repos/talexander/webhook_bridge/languages",
|
||||||
"html_url": "https://code.fizz.buzz/talexander/webhook_bridge",
|
"html_url": "https://code.fizz.buzz/talexander/webhook_bridge",
|
||||||
"url": "https://code.fizz.buzz/api/v1/repos/talexander/webhook_bridge",
|
"url": "https://code.fizz.buzz/api/v1/repos/talexander/webhook_bridge",
|
||||||
"link": "",
|
"link": "",
|
||||||
"ssh_url": "git@code.fizz.buzz:talexander/webhook_bridge.git",
|
"ssh_url": "git@git.example.com:talexander/webhook_bridge.git",
|
||||||
"clone_url": "https://code.fizz.buzz/talexander/webhook_bridge.git",
|
"clone_url": "https://code.fizz.buzz/talexander/webhook_bridge.git",
|
||||||
"original_url": "",
|
"original_url": "",
|
||||||
"website": "",
|
"website": "",
|
||||||
@@ -107,47 +114,58 @@
|
|||||||
"default_branch": "main",
|
"default_branch": "main",
|
||||||
"archived": false,
|
"archived": false,
|
||||||
"created_at": "2024-07-14T18:48:52Z",
|
"created_at": "2024-07-14T18:48:52Z",
|
||||||
"updated_at": "2024-09-29T04:14:47Z",
|
"updated_at": "2026-05-02T21:52:29Z",
|
||||||
"archived_at": "1970-01-01T00:00:00Z",
|
"archived_at": "1970-01-01T00:00:00Z",
|
||||||
"permissions": {
|
"permissions": {
|
||||||
"admin": true,
|
"admin": true,
|
||||||
"push": true,
|
"push": true,
|
||||||
"pull": true
|
"pull": true
|
||||||
},
|
},
|
||||||
|
"has_code": true,
|
||||||
"has_issues": true,
|
"has_issues": true,
|
||||||
"internal_tracker": {
|
"internal_tracker": {
|
||||||
"enable_time_tracker": true,
|
"enable_time_tracker": true,
|
||||||
"allow_only_contributors_to_track_time": true,
|
"allow_only_contributors_to_track_time": true,
|
||||||
"enable_issue_dependencies": true
|
"enable_issue_dependencies": true
|
||||||
},
|
},
|
||||||
"has_wiki": true,
|
"has_wiki": false,
|
||||||
"has_pull_requests": true,
|
"has_pull_requests": true,
|
||||||
"has_projects": true,
|
"has_projects": false,
|
||||||
|
"projects_mode": "all",
|
||||||
"has_releases": true,
|
"has_releases": true,
|
||||||
"has_packages": true,
|
"has_packages": false,
|
||||||
"has_actions": false,
|
"has_actions": false,
|
||||||
"ignore_whitespace_conflicts": false,
|
"ignore_whitespace_conflicts": false,
|
||||||
"allow_merge_commits": true,
|
"allow_merge_commits": true,
|
||||||
"allow_rebase": true,
|
"allow_rebase": true,
|
||||||
"allow_rebase_explicit": true,
|
"allow_rebase_explicit": true,
|
||||||
"allow_squash_merge": true,
|
"allow_squash_merge": true,
|
||||||
|
"allow_fast_forward_only_merge": false,
|
||||||
"allow_rebase_update": true,
|
"allow_rebase_update": true,
|
||||||
|
"allow_manual_merge": false,
|
||||||
|
"autodetect_manual_merge": false,
|
||||||
"default_delete_branch_after_merge": false,
|
"default_delete_branch_after_merge": false,
|
||||||
"default_merge_style": "merge",
|
"default_merge_style": "merge",
|
||||||
"default_allow_maintainer_edit": false,
|
"default_allow_maintainer_edit": false,
|
||||||
"avatar_url": "",
|
"avatar_url": "",
|
||||||
"internal": false,
|
"internal": false,
|
||||||
"mirror_interval": "",
|
"mirror_interval": "",
|
||||||
|
"object_format_name": "sha1",
|
||||||
"mirror_updated": "0001-01-01T00:00:00Z",
|
"mirror_updated": "0001-01-01T00:00:00Z",
|
||||||
"repo_transfer": null
|
"topics": [],
|
||||||
|
"licenses": [
|
||||||
|
"0BSD"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"pusher": {
|
"pusher": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"login": "talexander",
|
"login": "talexander",
|
||||||
"login_name": "",
|
"login_name": "",
|
||||||
|
"source_id": 0,
|
||||||
"full_name": "",
|
"full_name": "",
|
||||||
"email": "talexander@noreply.code.fizz.buzz",
|
"email": "talexander@noreply.code.fizz.buzz",
|
||||||
"avatar_url": "https://code.fizz.buzz/avatars/9d402a89b5a0786f83c1b8c5486fc7ff3d083a54fe20e55c0a776a1932c30289",
|
"avatar_url": "https://code.fizz.buzz/avatars/9d402a89b5a0786f83c1b8c5486fc7ff3d083a54fe20e55c0a776a1932c30289",
|
||||||
|
"html_url": "https://code.fizz.buzz/talexander",
|
||||||
"language": "",
|
"language": "",
|
||||||
"is_admin": false,
|
"is_admin": false,
|
||||||
"last_login": "0001-01-01T00:00:00Z",
|
"last_login": "0001-01-01T00:00:00Z",
|
||||||
@@ -168,9 +186,11 @@
|
|||||||
"id": 1,
|
"id": 1,
|
||||||
"login": "talexander",
|
"login": "talexander",
|
||||||
"login_name": "",
|
"login_name": "",
|
||||||
|
"source_id": 0,
|
||||||
"full_name": "",
|
"full_name": "",
|
||||||
"email": "talexander@noreply.code.fizz.buzz",
|
"email": "talexander@noreply.code.fizz.buzz",
|
||||||
"avatar_url": "https://code.fizz.buzz/avatars/9d402a89b5a0786f83c1b8c5486fc7ff3d083a54fe20e55c0a776a1932c30289",
|
"avatar_url": "https://code.fizz.buzz/avatars/9d402a89b5a0786f83c1b8c5486fc7ff3d083a54fe20e55c0a776a1932c30289",
|
||||||
|
"html_url": "https://code.fizz.buzz/talexander",
|
||||||
"language": "",
|
"language": "",
|
||||||
"is_admin": false,
|
"is_admin": false,
|
||||||
"last_login": "0001-01-01T00:00:00Z",
|
"last_login": "0001-01-01T00:00:00Z",
|
||||||
10
run.bash
10
run.bash
@@ -4,4 +4,12 @@ set -euo pipefail
|
|||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
RUST_LOG=webhook_bridge=DEBUG WEBHOOK_BRIDGE_API_ROOT="https://code.fizz.buzz/api" WEBHOOK_BRIDGE_HMAC_SECRET=$(cat /bridge/git/mrmanager/k8s/webhook-bridge/secrets/webhook-bridge/webhook-bridge/HMAC_TOKEN) WEBHOOK_BRIDGE_OAUTH_TOKEN=$(cat /bridge/git/mrmanager/k8s/webhook-bridge/secrets/webhook-bridge/webhook-bridge/OAUTH_TOKEN) cargo run
|
function main {
|
||||||
|
exec env RUST_LOG=webhook_bridge=DEBUG WEBHOOK_BRIDGE_API_ROOT="https://code.fizz.buzz/api" WEBHOOK_BRIDGE_HMAC_SECRET="$(decrypt_k8s_secret -n webhook-bridge webhook-bridge | jq -r '.HMAC_TOKEN')" WEBHOOK_BRIDGE_OAUTH_TOKEN="$(decrypt_k8s_secret -n webhook-bridge webhook-bridge | jq -r '.OAUTH_TOKEN')" WEBHOOK_BRIDGE_REPO_WHITELIST="talexander/webhook_bridge,talexander/homepage,talexander/natter,talexander/poudboot,talexander/ta_waybar_pipewire,talexander/organic" cargo run "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function decrypt_k8s_secret {
|
||||||
|
kubectl get secret -o json "${@}" | jq '.data[] |= @base64d | .data'
|
||||||
|
}
|
||||||
|
|
||||||
|
main "${@}"
|
||||||
|
|||||||
4
rust-toolchain.toml
Normal file
4
rust-toolchain.toml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
[toolchain]
|
||||||
|
channel = "nightly"
|
||||||
|
profile = "default"
|
||||||
|
components = ["clippy", "rustfmt"]
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
use kube::Client;
|
use std::collections::HashSet;
|
||||||
|
use std::sync::Arc;
|
||||||
use crate::gitea_client::GiteaClient;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct AppState {
|
pub(crate) struct AppState {
|
||||||
pub(crate) kubernetes_client: Client,
|
pub(crate) allowed_repos: Arc<HashSet<String>>,
|
||||||
pub(crate) gitea: GiteaClient,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
use webhookbridge::init_tracing;
|
use webhookbridge::init_tracing;
|
||||||
use webhookbridge::local_trigger;
|
use webhookbridge::local_trigger;
|
||||||
|
|
||||||
const EXAMPLE_WEBHOOK_PAYLOAD: &str = include_str!("../example_tag_webhook_payload.json");
|
const EXAMPLE_WEBHOOK_PAYLOAD: &str = include_str!("../local_payload.json");
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
#[allow(clippy::needless_return)]
|
#[allow(clippy::needless_return)]
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use serde_json::Value;
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub(crate) struct HookPush {
|
pub(crate) struct HookPush {
|
||||||
#[serde(rename = "ref")]
|
#[serde(rename = "ref")]
|
||||||
pub(crate) ref_field: String,
|
pub(crate) ref_field: String,
|
||||||
@@ -16,21 +15,23 @@ pub(crate) struct HookPush {
|
|||||||
commits: Vec<HookCommit>,
|
commits: Vec<HookCommit>,
|
||||||
total_commits: u64,
|
total_commits: u64,
|
||||||
head_commit: HookCommit,
|
head_commit: HookCommit,
|
||||||
repository: HookRepository,
|
pub(crate) repository: HookRepository,
|
||||||
pusher: HookUser,
|
pusher: HookUser,
|
||||||
sender: HookUser,
|
sender: HookUser,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub(crate) struct HookUser {
|
pub(crate) struct HookUser {
|
||||||
id: u64,
|
id: u64,
|
||||||
login: String,
|
login: String,
|
||||||
login_name: String,
|
login_name: String,
|
||||||
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
source_id: Option<u64>,
|
||||||
full_name: String,
|
full_name: String,
|
||||||
email: String,
|
email: String,
|
||||||
avatar_url: String,
|
avatar_url: String,
|
||||||
|
html_url: String,
|
||||||
language: String,
|
language: String,
|
||||||
is_admin: bool,
|
is_admin: bool,
|
||||||
last_login: String, // TODO: parse to datetime
|
last_login: String, // TODO: parse to datetime
|
||||||
@@ -50,18 +51,16 @@ pub(crate) struct HookUser {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub(crate) struct HookRepository {
|
pub(crate) struct HookRepository {
|
||||||
id: u64,
|
id: u64,
|
||||||
owner: HookUser,
|
owner: HookUser,
|
||||||
name: String,
|
name: String,
|
||||||
full_name: String,
|
pub(crate) full_name: String,
|
||||||
description: String,
|
description: String,
|
||||||
empty: bool,
|
empty: bool,
|
||||||
private: bool,
|
private: bool,
|
||||||
fork: bool,
|
fork: bool,
|
||||||
template: bool,
|
template: bool,
|
||||||
parent: Value, // Was null in test hook
|
|
||||||
mirror: bool,
|
mirror: bool,
|
||||||
size: u64,
|
size: u64,
|
||||||
language: String,
|
language: String,
|
||||||
@@ -86,10 +85,12 @@ pub(crate) struct HookRepository {
|
|||||||
archived_at: String, // TODO: parse to datetime
|
archived_at: String, // TODO: parse to datetime
|
||||||
permissions: HookRepositoryPermissions,
|
permissions: HookRepositoryPermissions,
|
||||||
has_issues: bool,
|
has_issues: bool,
|
||||||
internal_tracker: HookRepositoryInternalTracker,
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
|
internal_tracker: Option<HookRepositoryInternalTracker>,
|
||||||
has_wiki: bool,
|
has_wiki: bool,
|
||||||
has_pull_requests: bool,
|
has_pull_requests: bool,
|
||||||
has_projects: bool,
|
has_projects: bool,
|
||||||
|
projects_mode: String,
|
||||||
has_releases: bool,
|
has_releases: bool,
|
||||||
has_packages: bool,
|
has_packages: bool,
|
||||||
has_actions: bool,
|
has_actions: bool,
|
||||||
@@ -98,6 +99,7 @@ pub(crate) struct HookRepository {
|
|||||||
allow_rebase: bool,
|
allow_rebase: bool,
|
||||||
allow_rebase_explicit: bool,
|
allow_rebase_explicit: bool,
|
||||||
allow_squash_merge: bool,
|
allow_squash_merge: bool,
|
||||||
|
allow_fast_forward_only_merge: bool,
|
||||||
allow_rebase_update: bool,
|
allow_rebase_update: bool,
|
||||||
default_delete_branch_after_merge: bool,
|
default_delete_branch_after_merge: bool,
|
||||||
default_merge_style: String,
|
default_merge_style: String,
|
||||||
@@ -105,13 +107,12 @@ pub(crate) struct HookRepository {
|
|||||||
avatar_url: String,
|
avatar_url: String,
|
||||||
internal: bool,
|
internal: bool,
|
||||||
mirror_interval: String,
|
mirror_interval: String,
|
||||||
|
object_format_name: String,
|
||||||
mirror_updated: String, // TODO: parse to datetime
|
mirror_updated: String, // TODO: parse to datetime
|
||||||
repo_transfer: Value, // Was null in test hook
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub(crate) struct HookRepositoryPermissions {
|
pub(crate) struct HookRepositoryPermissions {
|
||||||
admin: bool,
|
admin: bool,
|
||||||
push: bool,
|
push: bool,
|
||||||
@@ -120,7 +121,6 @@ pub(crate) struct HookRepositoryPermissions {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub(crate) struct HookRepositoryInternalTracker {
|
pub(crate) struct HookRepositoryInternalTracker {
|
||||||
enable_time_tracker: bool,
|
enable_time_tracker: bool,
|
||||||
allow_only_contributors_to_track_time: bool,
|
allow_only_contributors_to_track_time: bool,
|
||||||
@@ -129,7 +129,6 @@ pub(crate) struct HookRepositoryInternalTracker {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub(crate) struct HookCommit {
|
pub(crate) struct HookCommit {
|
||||||
id: String,
|
id: String,
|
||||||
message: String,
|
message: String,
|
||||||
@@ -145,7 +144,6 @@ pub(crate) struct HookCommit {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
pub(crate) struct HookGitUser {
|
pub(crate) struct HookGitUser {
|
||||||
name: String,
|
name: String,
|
||||||
email: String,
|
email: String,
|
||||||
|
|||||||
34
src/lib.rs
34
src/lib.rs
@@ -1,4 +1,6 @@
|
|||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use axum::http::StatusCode;
|
use axum::http::StatusCode;
|
||||||
@@ -35,7 +37,8 @@ pub async fn init_tracing() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with(
|
.with(
|
||||||
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
|
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
|
||||||
"webhook_bridge=info,tower_http=debug,axum::rejection=trace".into()
|
"webhookbridge=info,webhook_bridge=info,local_trigger=info,tower_http=debug,axum::rejection=trace"
|
||||||
|
.into()
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.with(tracing_subscriber::fmt::layer())
|
.with(tracing_subscriber::fmt::layer())
|
||||||
@@ -44,13 +47,13 @@ pub async fn init_tracing() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn launch_server() -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn launch_server() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let kubernetes_client: Client = Client::try_default()
|
let allowed_repos = std::env::var("WEBHOOK_BRIDGE_REPO_WHITELIST")?;
|
||||||
.await
|
let allowed_repos: HashSet<_> = allowed_repos
|
||||||
.expect("Set KUBECONFIG to a valid kubernetes config.");
|
.split(",")
|
||||||
|
.filter(|s| !s.is_empty())
|
||||||
let gitea_api_root = std::env::var("WEBHOOK_BRIDGE_API_ROOT")?;
|
.map(str::to_owned)
|
||||||
let gitea_api_token = std::env::var("WEBHOOK_BRIDGE_OAUTH_TOKEN")?;
|
.collect();
|
||||||
let gitea = GiteaClient::new(gitea_api_root, gitea_api_token);
|
tracing::debug!("Using repo whitelist: {:?}", allowed_repos);
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/hook", post(hook))
|
.route("/hook", post(hook))
|
||||||
@@ -62,8 +65,7 @@ pub async fn launch_server() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
TimeoutLayer::new(Duration::from_secs(600)),
|
TimeoutLayer::new(Duration::from_secs(600)),
|
||||||
))
|
))
|
||||||
.with_state(AppState {
|
.with_state(AppState {
|
||||||
kubernetes_client,
|
allowed_repos: Arc::new(allowed_repos),
|
||||||
gitea,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:9988").await?;
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:9988").await?;
|
||||||
@@ -83,9 +85,19 @@ pub async fn local_trigger(payload: &str) -> Result<(), Box<dyn std::error::Erro
|
|||||||
let gitea_api_token = std::env::var("WEBHOOK_BRIDGE_OAUTH_TOKEN")?;
|
let gitea_api_token = std::env::var("WEBHOOK_BRIDGE_OAUTH_TOKEN")?;
|
||||||
let gitea = GiteaClient::new(gitea_api_root, gitea_api_token);
|
let gitea = GiteaClient::new(gitea_api_root, gitea_api_token);
|
||||||
|
|
||||||
|
let allowed_repos = std::env::var("WEBHOOK_BRIDGE_REPO_WHITELIST")
|
||||||
|
.ok()
|
||||||
|
.unwrap_or_default();
|
||||||
|
let allowed_repos: HashSet<_> = allowed_repos
|
||||||
|
.split(",")
|
||||||
|
.filter(|s| !s.is_empty())
|
||||||
|
.map(str::to_owned)
|
||||||
|
.collect();
|
||||||
|
tracing::debug!("Using repo whitelist: {:?}", allowed_repos);
|
||||||
|
|
||||||
let webhook_payload: HookPush = serde_json::from_str(payload)?;
|
let webhook_payload: HookPush = serde_json::from_str(payload)?;
|
||||||
|
|
||||||
handle_push(gitea, kubernetes_client, webhook_payload).await?;
|
handle_push(gitea, kubernetes_client, &allowed_repos, webhook_payload).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use std::borrow::Borrow;
|
||||||
|
use std::collections::HashSet;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
use axum::async_trait;
|
use axum::async_trait;
|
||||||
@@ -40,19 +42,54 @@ pub(crate) async fn hook(
|
|||||||
debug!("REQ: {:?}", payload);
|
debug!("REQ: {:?}", payload);
|
||||||
match payload {
|
match payload {
|
||||||
HookRequest::Push(webhook_payload) => {
|
HookRequest::Push(webhook_payload) => {
|
||||||
handle_push(state.gitea, state.kubernetes_client, webhook_payload)
|
let kubernetes_client: kube::Client = kube::Client::try_default()
|
||||||
.await
|
.await
|
||||||
.expect("Failed to handle push event.");
|
.expect("Set KUBECONFIG to a valid kubernetes config.");
|
||||||
(
|
|
||||||
|
let gitea_api_root = std::env::var("WEBHOOK_BRIDGE_API_ROOT");
|
||||||
|
let gitea_api_token = std::env::var("WEBHOOK_BRIDGE_OAUTH_TOKEN");
|
||||||
|
let (gitea_api_root, gitea_api_token) = match (gitea_api_root, gitea_api_token) {
|
||||||
|
(Ok(r), Ok(t)) => (r, t),
|
||||||
|
_ => {
|
||||||
|
return (
|
||||||
StatusCode::OK,
|
StatusCode::OK,
|
||||||
Json(HookResponse {
|
Json(HookResponse {
|
||||||
ok: true,
|
ok: true,
|
||||||
message: None,
|
message: None,
|
||||||
}),
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let gitea = GiteaClient::new(gitea_api_root, gitea_api_token);
|
||||||
|
|
||||||
|
let push_result = handle_push(
|
||||||
|
gitea,
|
||||||
|
kubernetes_client,
|
||||||
|
state.allowed_repos.borrow(),
|
||||||
|
webhook_payload,
|
||||||
)
|
)
|
||||||
|
.await;
|
||||||
|
match push_result {
|
||||||
|
Ok(_) => (
|
||||||
|
StatusCode::OK,
|
||||||
|
Json(HookResponse {
|
||||||
|
ok: true,
|
||||||
|
message: None,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
Err(_) => (
|
||||||
|
// StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
StatusCode::OK,
|
||||||
|
Json(HookResponse {
|
||||||
|
ok: false,
|
||||||
|
message: Some("Failed to handle push event.".to_string()),
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
HookRequest::Unrecognized(payload) => (
|
HookRequest::Unrecognized(payload) => (
|
||||||
StatusCode::BAD_REQUEST,
|
// StatusCode::BAD_REQUEST,
|
||||||
|
StatusCode::OK,
|
||||||
Json(HookResponse {
|
Json(HookResponse {
|
||||||
ok: false,
|
ok: false,
|
||||||
message: Some(format!("unrecognized event type: {payload}")),
|
message: Some(format!("unrecognized event type: {payload}")),
|
||||||
@@ -139,9 +176,9 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn check_hash(body: Bytes, secret: String, signature: Vec<u8>) -> Result<Bytes, Response> {
|
async fn check_hash(body: Bytes, secret: String, signature: Vec<u8>) -> Result<Bytes, Response> {
|
||||||
tracing::info!("Checking signature {:02x?}", signature.as_slice());
|
tracing::debug!("Checking signature {:02x?}", signature.as_slice());
|
||||||
tracing::info!("Using secret {:?}", secret);
|
// tracing::info!("Using secret {:?}", secret);
|
||||||
tracing::info!("and body {}", general_purpose::STANDARD.encode(&body));
|
tracing::debug!("and body {}", general_purpose::STANDARD.encode(&body));
|
||||||
let mut mac = HmacSha256::new_from_slice(secret.as_bytes())
|
let mut mac = HmacSha256::new_from_slice(secret.as_bytes())
|
||||||
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response())?;
|
.map_err(|e| (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response())?;
|
||||||
mac.update(&body);
|
mac.update(&body);
|
||||||
@@ -167,11 +204,19 @@ fn hex_to_bytes(s: &str) -> Option<Vec<u8>> {
|
|||||||
pub(crate) async fn handle_push(
|
pub(crate) async fn handle_push(
|
||||||
gitea: GiteaClient,
|
gitea: GiteaClient,
|
||||||
kubernetes_client: kube::Client,
|
kubernetes_client: kube::Client,
|
||||||
|
allowed_repos: &HashSet<String>,
|
||||||
webhook_payload: HookPush,
|
webhook_payload: HookPush,
|
||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let repo_owner = webhook_payload.get_repo_owner()?;
|
let repo_owner = webhook_payload.get_repo_owner()?;
|
||||||
let repo_name = webhook_payload.get_repo_name()?;
|
let repo_name = webhook_payload.get_repo_name()?;
|
||||||
let pull_base_sha = webhook_payload.get_pull_base_sha()?;
|
let pull_base_sha = webhook_payload.get_pull_base_sha()?;
|
||||||
|
if !allowed_repos.contains(&webhook_payload.repository.full_name) {
|
||||||
|
tracing::info!(
|
||||||
|
"{} is not an allowed repository.",
|
||||||
|
webhook_payload.repository.full_name
|
||||||
|
);
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
let repo_tree = gitea.get_tree(repo_owner, repo_name, pull_base_sha).await?;
|
let repo_tree = gitea.get_tree(repo_owner, repo_name, pull_base_sha).await?;
|
||||||
let remote_config = discover_webhook_bridge_config(&gitea, &repo_tree).await?;
|
let remote_config = discover_webhook_bridge_config(&gitea, &repo_tree).await?;
|
||||||
let pipelines = discover_matching_push_triggers(
|
let pipelines = discover_matching_push_triggers(
|
||||||
|
|||||||
Reference in New Issue
Block a user