-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: use proper dummy app key length * feat: mount plugin to host path * feat: parameterize dag path, plugin path, and port * feat: plugin artifact via variable * feat: remove artifact path * feat: add load secret script * feat: use relative path instead * feat: adding dummy plugin * feat: multiple secret load * feat: load secret from file contains key value * feat: use load.sh to load plugin and secrets * fix: readme * feat: add image busybox on dummy plugin * refactor: gitignore and add parameterize optimus namespace * feat: add script for load artifacts * doc: update docs for mounting plugings * docs: add port-forward + fix typo * feat: add load secret message
- Loading branch information
1 parent
4f31e3f
commit 930a8e1
Showing
9 changed files
with
164 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
plugins/* | ||
!plugins/optimus-plugin-echo.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
# this script is used to copy plugin artifact to plugins mounted location | ||
# then return the artifact paths which inside the plugins mounted location | ||
|
||
OPTIMUS_PLUGINS_PATH=/tmp/colima/plugins | ||
SETUP_PATH=$1 | ||
|
||
is_yq_installed(){ | ||
if [ -z $(command -v yq) ]; then | ||
>&2 echo "yq must be installed: \`brew install yq\`" | ||
exit 1 | ||
fi | ||
} | ||
|
||
if [ -z "$SETUP_PATH" ]; then | ||
>&2 echo "must provide setup_path: ./get_artifacts.sh <setup_path>" | ||
exit 1 | ||
fi | ||
|
||
# load plugins | ||
is_yq_installed | ||
mkdir -p ${OPTIMUS_PLUGINS_PATH} | ||
OPTIMUS_PLUGIN_ARTIFACTS="" | ||
yq '.plugins[]' ${SETUP_PATH} >> p.tmp | ||
while read artifact; do | ||
artifact=$(cp $artifact $OPTIMUS_PLUGINS_PATH 2> /dev/null && echo "/app/plugins/$(basename ${artifact})" || echo $artifact) | ||
OPTIMUS_PLUGIN_ARTIFACTS="${OPTIMUS_PLUGIN_ARTIFACTS}\,${artifact}" | ||
done < p.tmp && rm p.tmp | ||
OPTIMUS_PLUGIN_ARTIFACTS="\"$(echo $OPTIMUS_PLUGIN_ARTIFACTS | sed 's/^\\,//g')\"" | ||
echo $OPTIMUS_PLUGIN_ARTIFACTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
|
||
OPTIMUS_NAMESPACE=optimus-dev | ||
|
||
PROJECT=${PROJECT:-project-a} | ||
HOST=${HOST:-"localhost:9100"} | ||
SETUP_PATH=$1 | ||
|
||
is_yq_installed(){ | ||
if [ -z $(command -v yq) ]; then | ||
>&2 echo "yq must be installed: \`brew install yq\`" | ||
exit 1 | ||
fi | ||
} | ||
|
||
if [ -z "$SETUP_PATH" ]; then | ||
>&2 echo "must provide setup_path: ./load_secrets.sh <setup_path>" | ||
exit 1 | ||
fi | ||
|
||
# load secrets | ||
echo ">> load secrets into project ${PROJECT}" | ||
is_yq_installed | ||
if ! curl --output /dev/null --silent ${HOST}/ping; then | ||
>&2 echo "can't connect to optimus host ${HOST}" | ||
exit 1 | ||
fi | ||
|
||
yq '.secrets[] | (.name | . + " ") + (.value | @base64)' ${SETUP_PATH} >> s.tmp | ||
while read key value; do | ||
resp=$(curl -XPOST -H "Content-Type: application/json" \ | ||
"${HOST}/api/v1beta1/project/${PROJECT}/secret/${key}" \ | ||
-d '{"value": "'${value}'"}' -s -o s.result -w "%{http_code}") | ||
if [ $resp -eq 200 ]; then echo "set secret ${key}: success"; else echo "set secret ${key}: fail\n$(cat s.result)"; fi | ||
rm s.result | ||
done < s.tmp && rm s.tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: echo | ||
description: Echo sample plugin for optimus | ||
plugintype: task | ||
pluginversion: 0.1.0 | ||
image: docker.io/busybox | ||
questions: | ||
- name: HELLO | ||
prompt: Hello World | ||
help: Example | ||
minlength: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
plugins: | ||
- https://raw.githubusercontent.com/odpf/transformers/main/task/bq2bq/optimus-plugin-bq2bq.yaml | ||
- ./plugins/optimus-plugin-echo.yaml | ||
secrets: | ||
- name: BQ_SERVICE_ACCOUNT | ||
value: > | ||
{ | ||
"type": "service_account", | ||
"project_id": "default", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\nEXAMPLE==\n-----END PRIVATE KEY-----\n", | ||
} | ||
- name: EXAMPLE | ||
value: > | ||
{ | ||
"type": "service_account", | ||
"project_id": "default", | ||
"private_key": "-----BEGIN PRIVATE KEY-----\nEXAMPLE==\n-----END PRIVATE KEY-----\n", | ||
} |