329 lines
10 KiB
HCL
329 lines
10 KiB
HCL
resource "kubectl_manifest" "Task_auto-cd-activate" {
|
|
yaml_body = <<-EOF
|
|
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: auto-cd-activate
|
|
namespace: ${var.namespace}
|
|
ownerReferences: ${jsonencode(var.install_owner)}
|
|
labels: ${jsonencode(local.common_labels)}
|
|
spec:
|
|
params:
|
|
- name: toolbox-image
|
|
default: sebt3/basic-toolbox-image:1.29.4
|
|
description: The name of the toolbox image
|
|
type: string
|
|
- name: issuer-name
|
|
default: ${var.issuer}
|
|
type: string
|
|
- name: domain-name
|
|
type: string
|
|
default: ${var.domain_name}
|
|
- name: domain
|
|
type: string
|
|
default: ${var.domain}
|
|
- name: stages
|
|
type: array
|
|
default: ${jsonencode(var.stages)}
|
|
- name: artifactory-url
|
|
description: The url of the current artifactory
|
|
- name: project-name
|
|
description: The git repository name
|
|
- name: project-path
|
|
description: The path of the current project
|
|
- name: git-repository-url
|
|
description: The git repository url
|
|
- name: deploy-url
|
|
description: The git repository url for the deploy project
|
|
steps:
|
|
- name: activate
|
|
image: $(params.toolbox-image)
|
|
workingDir: $(workspaces.source.path)
|
|
args:
|
|
- $(params.stages)
|
|
env:
|
|
- name: ARTIFACTORY_URL
|
|
value: $(params.artifactory-url)
|
|
- name: DOMAIN
|
|
value: $(params.domain)
|
|
- 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)
|
|
- name: NAMESPACE
|
|
value: $(context.taskRun.namespace)
|
|
script: |-
|
|
#!/usr/bin/env bash
|
|
. $${TEMPLATE_ROOT}/functions.sh
|
|
cleanup
|
|
git_prepare "$(params.deploy-url)" "Auto CD" "autocd@$(params.domain-name)"
|
|
install_base
|
|
create_prj "$@"
|
|
activate_prj "$@"
|
|
git_push "Activating $(params.project-name)"
|
|
cleanup
|
|
volumeMounts:
|
|
- mountPath: /etc/templates
|
|
name: templates
|
|
volumes:
|
|
- name: templates
|
|
configMap:
|
|
name: auto-cd-templates
|
|
workspaces:
|
|
- name: source
|
|
mountPath: /data
|
|
- description: |
|
|
A .ssh directory with private key, known_hosts, config, etc. Copied to
|
|
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
|
|
EOF
|
|
}
|
|
|
|
resource "kubectl_manifest" "Task_auto-cd-create" {
|
|
yaml_body = <<-EOF
|
|
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: auto-cd-create
|
|
namespace: ${var.namespace}
|
|
ownerReferences: ${jsonencode(var.install_owner)}
|
|
labels: ${jsonencode(local.common_labels)}
|
|
spec:
|
|
params:
|
|
- name: toolbox-image
|
|
default: sebt3/basic-toolbox-image:1.29.4
|
|
description: The name of the toolbox image
|
|
type: string
|
|
- name: issuer-name
|
|
default: ${var.issuer}
|
|
type: string
|
|
- name: domain-name
|
|
type: string
|
|
default: ${var.domain_name}
|
|
- name: domain
|
|
type: string
|
|
default: ${var.domain}
|
|
- name: stages
|
|
type: array
|
|
default: ${jsonencode(var.stages)}
|
|
- name: known-repos
|
|
type: array
|
|
default: ${jsonencode(var.known_repos)}
|
|
- name: artifactory-url
|
|
description: The url of the current artifactory
|
|
- name: project-name
|
|
description: The git repository name
|
|
- name: project-path
|
|
description: The path of the current project
|
|
- name: git-repository-url
|
|
description: The git repository url
|
|
- name: deploy-url
|
|
description: The git repository url for the deploy project
|
|
steps:
|
|
- name: create
|
|
image: $(params.toolbox-image)
|
|
workingDir: $(workspaces.source.path)
|
|
args:
|
|
- $(params.known-repos)
|
|
- --
|
|
- $(params.stages)
|
|
env:
|
|
- name: ARTIFACTORY_URL
|
|
value: $(params.artifactory-url)
|
|
- name: DOMAIN
|
|
value: $(params.domain)
|
|
- 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)
|
|
- name: NAMESPACE
|
|
value: $(context.taskRun.namespace)
|
|
script: |-
|
|
#!/usr/bin/env bash
|
|
. $${TEMPLATE_ROOT}/functions.sh
|
|
cleanup
|
|
git_prepare "$(params.deploy-url)" "Auto CD" "autocd@$(params.domain-name)"
|
|
install_base
|
|
REPOS=""
|
|
while [ $# -ge 1 ] && [[ $1 != "--" ]];do
|
|
REPOS="$REPOS$1 "
|
|
shift
|
|
done
|
|
if [ $# -gt 1 ];then
|
|
shift
|
|
fi
|
|
create_prj "$@"
|
|
STAGES="$*"
|
|
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)"
|
|
cleanup
|
|
volumeMounts:
|
|
- mountPath: /etc/templates
|
|
name: templates
|
|
volumes:
|
|
- name: templates
|
|
configMap:
|
|
name: auto-cd-templates
|
|
workspaces:
|
|
- name: source
|
|
mountPath: /data
|
|
- description: |
|
|
A .ssh directory with private key, known_hosts, config, etc. Copied to
|
|
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
|
|
EOF
|
|
}
|
|
|
|
resource "kubectl_manifest" "Task_auto-cd-delete" {
|
|
yaml_body = <<-EOF
|
|
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: auto-cd-delete
|
|
namespace: ${var.namespace}
|
|
ownerReferences: ${jsonencode(var.install_owner)}
|
|
labels: ${jsonencode(local.common_labels)}
|
|
spec:
|
|
params:
|
|
- name: toolbox-image
|
|
default: sebt3/basic-toolbox-image:1.29.4
|
|
description: The name of the toolbox image
|
|
type: string
|
|
- name: issuer-name
|
|
default: ${var.issuer}
|
|
type: string
|
|
- name: domain-name
|
|
type: string
|
|
default: ${var.domain_name}
|
|
- name: domain
|
|
type: string
|
|
default: ${var.domain}
|
|
- name: stages
|
|
type: array
|
|
default: ${jsonencode(var.stages)}
|
|
- name: artifactory-url
|
|
description: The url of the current artifactory
|
|
- name: project-name
|
|
description: The git repository name
|
|
- name: project-path
|
|
description: The path of the current project
|
|
- name: git-repository-url
|
|
description: The git repository url
|
|
- name: deploy-url
|
|
description: The git repository url for the deploy project
|
|
steps:
|
|
- name: delete
|
|
image: $(params.toolbox-image)
|
|
workingDir: $(workspaces.source.path)
|
|
args:
|
|
- $(params.stages)
|
|
env:
|
|
- name: ARTIFACTORY_URL
|
|
value: $(params.artifactory-url)
|
|
- name: DOMAIN
|
|
value: $(params.domain)
|
|
- 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)
|
|
- name: NAMESPACE
|
|
value: $(context.taskRun.namespace)
|
|
script: |-
|
|
#!/usr/bin/env bash
|
|
. $${TEMPLATE_ROOT}/functions.sh
|
|
cleanup
|
|
git_prepare "$(params.deploy-url)" "Auto CD" "autocd@$(params.domain-name)"
|
|
delete_prj "$@"
|
|
git_push "Removing $(params.project-name)"
|
|
cleanup
|
|
volumeMounts:
|
|
- mountPath: /etc/templates
|
|
name: templates
|
|
volumes:
|
|
- name: templates
|
|
configMap:
|
|
name: auto-cd-templates
|
|
workspaces:
|
|
- name: source
|
|
mountPath: /data
|
|
- description: |
|
|
A .ssh directory with private key, known_hosts, config, etc. Copied to
|
|
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
|
|
EOF
|
|
}
|
|
|
|
resource "kubectl_manifest" "Task_auto-ci-cleanup" {
|
|
yaml_body = <<-EOF
|
|
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: auto-ci-cleanup
|
|
namespace: ${var.namespace}
|
|
ownerReferences: ${jsonencode(var.install_owner)}
|
|
labels: ${jsonencode(local.common_labels)}
|
|
spec:
|
|
params:
|
|
- name: toolbox-image
|
|
default: sebt3/basic-toolbox-image:1.29.4
|
|
description: The name of the toolbox image
|
|
type: string
|
|
steps:
|
|
- name: cleanup
|
|
image: $(params.toolbox-image)
|
|
workingDir: $(workspaces.source.path)
|
|
script: |-
|
|
#!/usr/bin/env bash
|
|
rm -rf .* * || true
|
|
workspaces:
|
|
- name: source
|
|
mountPath: /data
|
|
EOF
|
|
}
|
|
|