Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f18c1fe421 | ||
|
|
3c58d19a88 | ||
|
|
f07c0dc971 | ||
|
|
fd7b22c5ce | ||
|
|
1c082a5e24 | ||
|
|
9ed8905a5c | ||
|
|
8cb28459a0 | ||
|
|
753ad6dd05 |
@@ -14,6 +14,9 @@ spec:
|
||||
- name: image-name
|
||||
description: The name for the built image
|
||||
type: string
|
||||
- name: target-name
|
||||
description: The dockerfile target to build
|
||||
type: string
|
||||
- name: path-to-image-context
|
||||
description: The path to the build context
|
||||
type: string
|
||||
@@ -109,7 +112,7 @@ spec:
|
||||
- name: revision
|
||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||
- name: pathInRepo
|
||||
value: task/kaniko/0.6//kaniko.yaml
|
||||
value: task/kaniko/0.6/kaniko.yaml
|
||||
params:
|
||||
- name: IMAGE
|
||||
value: "$(params.image-name):$(tasks.detect-tag.results.tag)"
|
||||
@@ -122,6 +125,7 @@ spec:
|
||||
- name: EXTRA_ARGS
|
||||
value:
|
||||
- "--destination=$(params.image-name)" # Also write the :latest image
|
||||
- "--target=$(params.target-name)"
|
||||
- --cache=true
|
||||
- --cache-copy-layers
|
||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
||||
@@ -216,6 +220,8 @@ spec:
|
||||
params:
|
||||
- name: image-name
|
||||
value: "harbor.fizz.buzz/private/webhook-bridge"
|
||||
- name: target-name
|
||||
value: ""
|
||||
- name: path-to-image-context
|
||||
value: .
|
||||
- name: path-to-dockerfile
|
||||
@@ -14,6 +14,9 @@ spec:
|
||||
- name: image-name
|
||||
description: The name for the built image
|
||||
type: string
|
||||
- name: target-name
|
||||
description: The dockerfile target to build
|
||||
type: string
|
||||
- name: path-to-image-context
|
||||
description: The path to the build context
|
||||
type: string
|
||||
@@ -89,6 +92,7 @@ spec:
|
||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
||||
- name: EXTRA_ARGS
|
||||
value:
|
||||
- "--target=$(params.target-name)"
|
||||
- --cache=true
|
||||
- --cache-copy-layers
|
||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
||||
@@ -292,7 +296,9 @@ spec:
|
||||
secretName: harbor-plain
|
||||
params:
|
||||
- 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
|
||||
value: docker/webhook_bridge_development/
|
||||
- name: path-to-dockerfile
|
||||
|
||||
@@ -14,6 +14,9 @@ spec:
|
||||
- name: image-name
|
||||
description: The name for the built image
|
||||
type: string
|
||||
- name: target-name
|
||||
description: The dockerfile target to build
|
||||
type: string
|
||||
- name: path-to-image-context
|
||||
description: The path to the build context
|
||||
type: string
|
||||
@@ -89,6 +92,7 @@ spec:
|
||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
||||
- name: EXTRA_ARGS
|
||||
value:
|
||||
- "--target=$(params.target-name)"
|
||||
- --cache=true
|
||||
- --cache-copy-layers
|
||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
||||
@@ -271,7 +275,9 @@ spec:
|
||||
secretName: harbor-plain
|
||||
params:
|
||||
- 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
|
||||
value: docker/webhook_bridge_development/
|
||||
- name: path-to-dockerfile
|
||||
|
||||
@@ -14,6 +14,9 @@ spec:
|
||||
- name: image-name
|
||||
description: The name for the built image
|
||||
type: string
|
||||
- name: target-name
|
||||
description: The dockerfile target to build
|
||||
type: string
|
||||
- name: path-to-image-context
|
||||
description: The path to the build context
|
||||
type: string
|
||||
@@ -77,7 +80,7 @@ spec:
|
||||
- name: revision
|
||||
value: df36b3853a5657fd883015cdbf07ad6466918acf
|
||||
- name: pathInRepo
|
||||
value: task/kaniko/0.6//kaniko.yaml
|
||||
value: task/kaniko/0.6/kaniko.yaml
|
||||
params:
|
||||
- name: IMAGE
|
||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||
@@ -89,6 +92,7 @@ spec:
|
||||
value: "gcr.io/kaniko-project/executor:v1.12.1"
|
||||
- name: EXTRA_ARGS
|
||||
value:
|
||||
- "--target=$(params.target-name)"
|
||||
- --cache=true
|
||||
- --cache-copy-layers
|
||||
- --cache-repo=harbor.fizz.buzz/kanikocache/cache
|
||||
@@ -261,7 +265,9 @@ spec:
|
||||
secretName: harbor-plain
|
||||
params:
|
||||
- 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
|
||||
value: docker/webhook_bridge_development/
|
||||
- name: path-to-dockerfile
|
||||
|
||||
@@ -26,6 +26,6 @@ version = "0.0.1"
|
||||
|
||||
[[push]]
|
||||
name = "build"
|
||||
source = "pipeline-build.yaml"
|
||||
source = "pipeline-build-semver.yaml"
|
||||
clone_uri = "git@code.fizz.buzz:talexander/webhook_bridge.git"
|
||||
branches = [ "^v[0-9]+\\.[0-9]+\\.[0-9]+$" ]
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
cargo-features = ["codegen-backend"]
|
||||
|
||||
[package]
|
||||
name = "webhook_bridge"
|
||||
version = "0.0.1"
|
||||
@@ -61,10 +59,3 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
|
||||
inherits = "release"
|
||||
lto = true
|
||||
strip = "symbols"
|
||||
|
||||
[profile.dev]
|
||||
codegen-backend = "cranelift"
|
||||
|
||||
[profile.dev.package."*"]
|
||||
codegen-backend = "llvm"
|
||||
opt-level = 3
|
||||
|
||||
@@ -2,6 +2,5 @@ FROM rustlang/rust:nightly-alpine3.20 AS builder
|
||||
|
||||
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 rustup component add rustc-codegen-cranelift
|
||||
RUN rustup component add rustfmt
|
||||
RUN rustup component add clippy
|
||||
|
||||
@@ -42,24 +42,54 @@ pub(crate) async fn hook(
|
||||
debug!("REQ: {:?}", payload);
|
||||
match payload {
|
||||
HookRequest::Push(webhook_payload) => {
|
||||
handle_push(
|
||||
state.gitea,
|
||||
state.kubernetes_client,
|
||||
state.allowed_repos.borrow(),
|
||||
webhook_payload,
|
||||
)
|
||||
let kubernetes_client: kube::Client = kube::Client::try_default()
|
||||
.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,
|
||||
Json(HookResponse {
|
||||
ok: true,
|
||||
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) => (
|
||||
StatusCode::BAD_REQUEST,
|
||||
// StatusCode::BAD_REQUEST,
|
||||
StatusCode::OK,
|
||||
Json(HookResponse {
|
||||
ok: false,
|
||||
message: Some(format!("unrecognized event type: {payload}")),
|
||||
|
||||
Reference in New Issue
Block a user