Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add automation pipeline framework #42

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/common-dependency/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

apiVersion: v2
name: common-dependency
version: "1.0.13"
version: "1.0.14"
appVersion: "1.0.0"
description: common-dependency
type: application
Expand Down
10 changes: 8 additions & 2 deletions charts/common-dependency/scripts/_funcs_generic_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ function generic-runner::setup_payload() {
_base64_encoded=$(echo "${_payload_section}" | common::yq4-get .base64Encoded)
if [[ ${_base64_encoded} == "true" ]]; then
common::debug "use base64 to decode script"
echo "${_payload_section}" | common::yq4-get .content | base64 -D > "${_payload_filename}"
if ! echo "${_payload_section}" | common::yq4-get .content | base64 -d > "${_payload_filename}"; then
common::err "error: generic-runner::setup_payload base64 -d return none 0"
return 1
fi
else
echo "${_payload_section}" | common::yq4-get .content > "${_payload_filename}"
fi
Expand Down Expand Up @@ -157,7 +160,10 @@ function generic-runner::setup_script() {
_base64_encoded=$(echo "${_script_section}" | common::yq4-get .base64Encoded)
if [[ ${_base64_encoded} == "true" ]]; then
common::debug "use base64 to decode script"
echo "${_script_content}" | base64 -D > "${_script_filename}"
if ! echo "${_script_content}" | base64 -d > "${_script_filename}"; then
common::err "error: generic-runner::setup_script base64 -d return none 0"
return 1
fi
else
echo "${_script_content}" > "${_script_filename}"
fi
Expand Down
2 changes: 1 addition & 1 deletion charts/provisioner-config-local/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ apiVersion: v2
name: provisioner-config-local
description: Platform Provisioner local config
type: application
version: "1.0.94"
version: "1.0.95"
appVersion: "2.0.0"
home: https://github.com/TIBCOSoftware/tp-helm-charts
maintainers:
Expand Down
6 changes: 6 additions & 0 deletions charts/provisioner-config-local/config/menuContent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ menuConfig:
- label: "Refresh Docker Registry token"
url: "/pipelines/generic-runner?title=refresh-docker-registry-token"
config: pp-maintain-tp-refresh-docker-token.yaml
- label: "TP Automation"
icon: 'pi pi-th-large'
items:
- label: "Deploy DP and config o11y"
url: "/pipelines/generic-runner?title=tp-automation-o11y"
config: pp-maintain-tp-automation-o11y.yaml
- label: "Pipelines"
url: "/pipelines"
icon: 'pi pi-fw pi-list'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Copyright © 2024. Cloud Software Group, Inc.
# This file is subject to the license terms contained
# in the license file that is distributed with this file.
#

pipelineName: "TP Automation o11y"
description: |
This pipeline will run an automation for o11y services.

The input of this recipe is user name an password.

To use this pipeline you need to:
* Deploy a CP and create admin user
* Create a subscription with give user which will be used for this pipeline
* Deploy o11y stack. (Elastic, Prometheus)

The automation will:
* Adjust user permission if necessary
* Create a new DP
* Register a DP
* Config o11y service for a given DP

options:
- name: "DP user name"
type: string
guiType: input
reference: "meta.guiEnv.GUI_DP_USER_NAME"
required: true
description: |
The user name of DP
- name: "DP password"
type: password
guiType: input
reference: "meta.guiEnv.GUI_DP_PASSWORD"
required: true
description: |
The password of DP
recipe: |
{{ tpl (.Files.Get "recipes/tp-automation-o11y.yaml") . | indent 2 }}
51 changes: 51 additions & 0 deletions charts/provisioner-config-local/recipes/tp-automation-o11y.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Copyright © 2024. Cloud Software Group, Inc.
# This file is subject to the license terms contained
# in the license file that is distributed with this file.
#

apiVersion: v1
kind: generic-runner
meta:
guiEnv:
note: "tp-automation-o11y"
GUI_TP_CLUSTER_NAME: ''
GUI_PIPELINE_LOG_DEBUG: false
GUI_DP_USER_NAME: ""
GUI_DP_PASSWORD: ""
globalEnvVariable:
REPLACE_RECIPE: true
PIPELINE_LOG_DEBUG: ${GUI_PIPELINE_LOG_DEBUG}
PIPELINE_CHECK_DOCKER_STATUS: false
TP_CLUSTER_NAME: ${GUI_TP_CLUSTER_NAME}
DP_USER_NAME: ${GUI_DP_USER_NAME:-""}
DP_PASSWORD: ${GUI_DP_PASSWORD:-""}
PYTHON_FILE_INPUT_NAME: py-scripts.yaml
PYTHON_FILE_ENTRY_POINT: run.py
tasks:
- condition: true
clusters:
- name: ${TP_CLUSTER_NAME}
script:
ignoreErrors: false
fileName: script.sh
content: |
input_yaml="${PYTHON_FILE_INPUT_NAME}"

yq eval 'to_entries | .[] | .key + " " + (.value)' "$input_yaml" | while read -r file_name decoded_content; do
if [[ -n $file_name ]]; then
echo "$decoded_content" | base64 -d > "$file_name"
echo "Created file: $file_name"
fi
done

python ${PYTHON_FILE_ENTRY_POINT}
payload:
base64Encoded: false
fileName: ${PYTHON_FILE_INPUT_NAME}
content: |
{{- $root := . }}
{{- range $path, $bytes := .Files.Glob "scripts/o11y/*" }}
{{ base $path }}: |
{{ $root.Files.Get $path | b64enc | indent 2 -}}
{{- end }}
5 changes: 5 additions & 0 deletions charts/provisioner-config-local/scripts/o11y/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main():
print("Hello, World!")

if __name__ == "__main__":
main()
5 changes: 5 additions & 0 deletions charts/provisioner-config-local/scripts/o11y/run1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def main():
print("Hello, World!")

if __name__ == "__main__":
main()
Loading