From c2c610cf66523d89bd09ee41ac4b71484b4c2597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Huss?= Date: Sun, 21 Apr 2024 14:41:42 +0200 Subject: [PATCH] fix --- share/gitea-tekton-org/datas.tf | 43 +++++++++++++++++++++++++++++++++ share/organisation/ci-space.tf | 20 +++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/share/gitea-tekton-org/datas.tf b/share/gitea-tekton-org/datas.tf index 6410e20..8a59b3b 100644 --- a/share/gitea-tekton-org/datas.tf +++ b/share/gitea-tekton-org/datas.tf @@ -14,4 +14,47 @@ data "kustomization_overlay" "data" { namespace = var.namespace common_labels = local.common-labels resources = [for file in fileset(path.module, "*.yaml"): file if file != "index.yaml"] + patches { + target { + kind = "Task" + name = "gitea-set-status" + } + patch = <<-EOF + - op: add + path: /spec/params/0/default + value: gitea-http.${var.domain}-ci.svc:3000 + - op: replace + path: /spec/params/1/default + value: http + EOF + } } +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: gitea-set-status + labels: + app.kubernetes.io/version: "0.1" + annotations: + tekton.dev/categories: Git + tekton.dev/pipelines.minVersion: "0.12.1" + tekton.dev/tags: gitea + tekton.dev/displayName: "set gitea status" + tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le" +spec: + description: >- + This task will set the status of the CI job to the specified value along + with a link to the specified target URL where developers can follow the + progress of the CI job. + + The `gitea-set-status` task allows external services to mark Gitea commits + with an `error`, `failure`, `pending`, or `success` state, which is then + reflected in pull requests involving those commits. Statuses include as well a + `description` and a `target_url`, to give the user informations about the CI + statuses or a direct link to the full log. + + params: + - name: GITEA_HOST_URL + description: | + The Gitea host, e.g: git.yourcompany.com. Can include port. + type: string diff --git a/share/organisation/ci-space.tf b/share/organisation/ci-space.tf index 43e6085..deddca6 100644 --- a/share/organisation/ci-space.tf +++ b/share/organisation/ci-space.tf @@ -67,3 +67,23 @@ resource "gitea_public_key" "ci-user-keys" { username = gitea_user.user-ci[0].username key = data.kubernetes_secret_v1.ci-ssh-creds-read[count.index].data["ssh-publickey"] } + +resource "gitea_token" "ci-user-token" { + count = var.haveGitea && var.haveTekton?1:0 + username = gitea_user.user-ci[0].username + name = "tekton" +} + +resource "kubernetes_secret_v1" "ci-user-token-secret" { + count = var.haveGitea && var.haveTekton?1:0 + metadata { + name = "gitea" + namespace = "${var.domain}-ci-${var.instance}" + } + data = { + url = "gitea-http.${var.domain}-ci.svc:3000" + username = gitea_user.user-ci[0].username + token = resource.gitea_token.ci-user-token.token + } +} +