This commit is contained in:
2024-04-23 10:52:04 +02:00
parent bacc62981c
commit 5a6cd40cc7
9 changed files with 282 additions and 49 deletions

View File

@@ -13,6 +13,8 @@ spec:
type: string
- name: domain-name
type: string
- name: stages
type: array
- name: artifactory-url
description: The url of the current artifactory
- name: project-name
@@ -24,71 +26,45 @@ spec:
- name: deploy-url
description: The git repository url for the deploy project
steps:
- name: cleanup
- name: create
image: $(params.toolbox-image)
workingDir: $(workspaces.source.path)
args:
- $(params.stages)
env:
- name: ARTIFACTORY_URL
value: $(params.artifactory-url)
- name: PROJECT_NAME
value: $(params.project-name)
- name: DOMAIN_NAME
value: $(params.domain-name)
- name: ISSUER_NAME
value: $(params.issuer-name)
- name: PROJECT_NAME
value: $(params.project-name)
- name: PROJECT_PATH
value: $(params.project-path)
- name: GIT_REPOSITORY_URL
value: $(params.git-repository-url)
- name: DEPLOY_URL
value: $(params.deploy-url)
- name: TEMPLATE_ROOT
value: /etc/templates
- name: WORKSPACE_SSH_DIRECTORY_PATH
value: $(workspaces.ssh-directory.path)
script: |-
#!/usr/bin/env bash
git clone "$(params.deploy-url)" --depth 1 .
mkdir -p "projects/$(params.project-name)" bases/project bases/install bases/deploy
added=0
copy() {
local src=/etc/templates/$1 dest=$2
if [ ! -f $dest ];then
cp "$src" "$dest"
git add "$dest"
added=$(($added+1))
fi
}
template() {
local src=/etc/templates/$1 dest=$2
if [ ! -f $dest ];then
envsubst <"$src" >"$dest"
git add "$dest"
added=$(($added+1))
fi
}
template base-update.yaml.tmpl bases/project/base-update.yaml
copy base-repo.yaml bases/project/repo.yaml
copy base-cert.yaml bases/project/cert.yaml
copy base-ingress.yaml bases/project/ingress.yaml
copy base-policy.yaml bases/project/policy.yaml
copy base-deploy.yaml bases/project/deploy.yaml
copy base-secret.yaml bases/project/secret.yaml
copy base-config.yaml bases/project/config.yaml
copy base-service.yaml bases/project/service.yaml
copy base-kusto.yaml bases/project/kustomization.yaml
copy install-install.yaml bases/install/install.yaml
copy install-kusto.yaml bases/install/kustomization.yaml
copy deploy-kusto.yaml bases/deploy/kustomization.yaml
template deploy-repo.yaml.tmpl bases/deploy/repo.yaml
template project-kusto.yaml.tmpl "projects/$(params.project-name)/kustomization.yaml"
if [ $added -ne 0 ];then
git commit -am "Adding $(params.project-name)"
git push
fi
. ${TEMPLATE_ROOT}/functions.sh
git_prepare "$(params.deploy-url)" "Auto CD" "autocd@$(params.domain-name)"
install_base
create_prj
git_push "Adding $(params.project-name)"
cleanup
volumeMounts:
- mountPath: /etc/templates
name: templates
volumes:
- name: templates
configmap:
name: auto-cd-create-templates
name: auto-cd-templates
workspaces:
- name: source
mountPath: /data
@@ -97,5 +73,4 @@ spec:
the user's home before git commands are executed. Used to authenticate
with the git remote when performing the clone. Binding a Secret to this
Workspace is strongly recommended over other volume types.
name: ssh-directory
optional: true
name: ssh-directory