Compare commits

...

10 Commits

Author SHA1 Message Date
834f72a12c fix 2024-07-02 10:40:16 +02:00
04ad5e58f1 fix 2024-07-02 10:37:44 +02:00
3dcb4f9336 fix 2024-07-02 10:36:14 +02:00
cbd2689c80 fix 2024-07-02 10:32:49 +02:00
673f9c64f8 fix 2024-07-02 10:22:28 +02:00
0c0b685396 fix 2024-06-23 15:41:33 +02:00
4b24a11715 fix 2024-06-19 09:00:08 +02:00
efc59eb32a fix 2024-06-19 08:58:10 +02:00
ad64e24720 fix 2024-06-19 07:55:48 +02:00
b9ee4c50ec fix 2024-06-18 18:07:32 +02:00
5 changed files with 70 additions and 13 deletions

View File

@@ -175,13 +175,13 @@ resource "kubectl_manifest" "Task_auto-cd-create" {
REPOS="$REPOS$1 "
shift
done
if [ $# -gt 1 ];then
if [ $# -gt 0 ];then
shift
fi
create_prj "$@"
STAGES="$*"
echo "$(params.known-repos[*])"
for PROJECT_NAME in $REPOS;do
GIT_REPOSITORY_URL="$(dirname $GIT_REPOSITORY_URL)/$${PROJECT_NAME}.git"
create_prj $STAGES
done
git_push "Adding $(params.project-name)"

View File

@@ -0,0 +1,46 @@
resource "kubectl_manifest" "postconfig" {
count = var.autoCD?1:0
yaml_body = <<-EOF
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
name: post-config-auto-cd-create
namespace: ${var.namespace}
ownerReferences: ${jsonencode(var.install_owner)}
labels: ${jsonencode(local.common_labels)}
annotations:
mayfly.cloud.namecheap.com/expire: 336h
spec:
params:
- name: artifactory-url
value: git.${var.domain_name}
- name: project-name
value: deploy
- name: project-path
value: ${var.organization}/deploy
- name: git-repository-url
value: ssh://git@${var.gitea_ssh_prefix}.${var.domain_name}:${var.gitea_ssh_port}/${var.organization}/deploy.git
- name: deploy-url
value: ssh://git@${var.gitea_ssh_prefix}.${var.domain_name}:${var.gitea_ssh_port}/${var.organization}/deploy.git
serviceAccountName: default
taskRef:
kind: Task
name: auto-cd-create
timeout: 1h0m0s
workspaces:
- name: source
persistentVolumeClaim:
claimName: source
subPath: postconfig-cd
- name: ssh-directory
secret:
items:
- key: known_hosts
path: known_hosts
- key: ssh-privatekey
path: id_rsa
- key: ssh-publickey
path: id_rsa.pub
secretName: ssh-credentials
EOF
}

View File

@@ -20,9 +20,12 @@ fn conditions() {
let password = base64_decode(gitea.data.password);
let headers = http_header_basic(username,password);
let response = http_get_json(`http://gitea-http.${global::DOMAIN}-ci.svc:3000/api/v1/orgs/${org}/repos`, headers);
repos += response.json.map(|p| p.name);
repos.sort();
log_info(`Found ${repos.len} repos`);
log_warn(type_of(response.code.to_int()));
if (response.code.to_int()>=200&&response.code.to_int()<300) {
repos += response.json.map(|p| p.name);
repos.sort();
log_info(`Found ${repos.len} repos`);
}
}
json_encode(#{
repos: repos,

View File

@@ -89,11 +89,17 @@ resource "random_password" "password" {
resource "gitea_user" "user-ci" {
count = local.needKnownHost?1:0
username = "${var.instance}-ci"
login_name = "${var.instance}-ci"
password = local.ci-user-password
email = "${var.instance}-ci@${var.domain_name}"
must_change_password = true
username = "${var.instance}-ci"
login_name = "${var.instance}-ci"
password = local.ci-user-password
email = "${var.instance}-ci@${var.domain_name}"
active = true
admin = false
allow_create_organization = false
must_change_password = false
force_password_change = false
send_notification = false
visibility = "limited"
}
resource "gitea_public_key" "user-ci-keys" {

View File

@@ -20,9 +20,11 @@ fn gitea_repos() {
let password = base64_decode(gitea.data.password);
let headers = http_header_basic(username,password);
let response = http_get_json(`http://gitea-http.${global::DOMAIN}-ci.svc:3000/api/v1/orgs/${org}/repos`, headers);
repos += response.json.map(|p| p.name);
repos.sort();
log_info(`Found ${repos.len} repos`);
if (response.code.to_int()>=200&&response.code.to_int()<300) {
repos += response.json.map(|p| p.name);
repos.sort();
log_info(`Found ${repos.len} repos`);
}
}
repos
}