From 96b0ace609ddf80ba6c0a4d18564c60fcd01ae47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miles=20St=C3=B6tzner?= Date: Wed, 6 Mar 2024 13:36:51 +0100 Subject: [PATCH] fix pull --- .github/actions/vintner-install/action.yaml | 4 +++ .../scripts/clean.sh | 11 +++++++ .../scripts/code.sh | 11 +++++++ .../scripts/configuration.env | 4 +++ .../scripts/configuration.sh | 29 +++++++++++++++++++ .../scripts/continue.sh | 11 +++++++ .../scripts/deploy.sh | 15 ++++++++++ .../scripts/pull.sh | 9 ++++++ .../scripts/quality.sh | 8 +++++ .../scripts/reimport.sh | 19 ++++++++++++ .../scripts/setup.sh | 14 +++++++++ .../scripts/undeploy.sh | 11 +++++++ .../templates/template-init/scripts/deploy.sh | 1 + .../templates/template-init/scripts/pull.sh | 2 +- .../template-init/scripts/reimport.sh | 1 + src/controller/template/pull.ts | 4 ++- src/controller/template/puml/types.ts | 2 +- src/utils/files.ts | 2 +- 18 files changed, 154 insertions(+), 4 deletions(-) create mode 100755 examples/unfurl-technology-maintenance/scripts/clean.sh create mode 100755 examples/unfurl-technology-maintenance/scripts/code.sh create mode 100644 examples/unfurl-technology-maintenance/scripts/configuration.env create mode 100755 examples/unfurl-technology-maintenance/scripts/configuration.sh create mode 100755 examples/unfurl-technology-maintenance/scripts/continue.sh create mode 100755 examples/unfurl-technology-maintenance/scripts/deploy.sh create mode 100644 examples/unfurl-technology-maintenance/scripts/pull.sh create mode 100644 examples/unfurl-technology-maintenance/scripts/quality.sh create mode 100755 examples/unfurl-technology-maintenance/scripts/reimport.sh create mode 100755 examples/unfurl-technology-maintenance/scripts/setup.sh create mode 100755 examples/unfurl-technology-maintenance/scripts/undeploy.sh diff --git a/.github/actions/vintner-install/action.yaml b/.github/actions/vintner-install/action.yaml index 08a867d04e..9449468089 100644 --- a/.github/actions/vintner-install/action.yaml +++ b/.github/actions/vintner-install/action.yaml @@ -115,3 +115,7 @@ runs: - name: (PREPARE) Install Vintner shell: bash run: curl -fsSL https://vintner.opentosca.org/install.sh | sudo bash - + + - name: (PREPARE) Vintner version + shell: bash + run: vintner --version diff --git a/examples/unfurl-technology-maintenance/scripts/clean.sh b/examples/unfurl-technology-maintenance/scripts/clean.sh new file mode 100755 index 0000000000..dc174b7f71 --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/clean.sh @@ -0,0 +1,11 @@ +#! /usr/bin/bash +set -e + +# Set working directory +cd "$(dirname "$0")" + +# Load configuration +source configuration.sh + +# Clean +$VINTNER setup clean --force diff --git a/examples/unfurl-technology-maintenance/scripts/code.sh b/examples/unfurl-technology-maintenance/scripts/code.sh new file mode 100755 index 0000000000..dbe3358fb5 --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/code.sh @@ -0,0 +1,11 @@ +#! /usr/bin/bash +set -e + +# Set working directory +cd "$(dirname "$0")" + +# Load configuration +source configuration.sh + +# Open VS Code +$VINTNER instances code --instance ${TEMPLATE_NAME} \ No newline at end of file diff --git a/examples/unfurl-technology-maintenance/scripts/configuration.env b/examples/unfurl-technology-maintenance/scripts/configuration.env new file mode 100644 index 0000000000..0f4d30712a --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/configuration.env @@ -0,0 +1,4 @@ +TEMPLATE_NAME="technology-maintenance" +#VINTNER="node ../../../build/cli/index.js" +VINTNER="yarn cli" +DEPLOYMENT_VARIANT="static" \ No newline at end of file diff --git a/examples/unfurl-technology-maintenance/scripts/configuration.sh b/examples/unfurl-technology-maintenance/scripts/configuration.sh new file mode 100755 index 0000000000..5e4da0d86a --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/configuration.sh @@ -0,0 +1,29 @@ +#! /usr/bin/bash +set -e + +# Set working directory +cd "$(dirname "$0")" + +# Load configuration +source configuration.env + +# Check that TEMPLATE_NAME is defined +if [[ -z ${TEMPLATE_NAME} ]]; then + echo "TEMPLATE_NAME is not defined" + exit 1 +fi + +# Check that VINTNER is defined +if [[ -z ${VINTNER} ]]; then + echo "VINTNER is not defined" + exit 1 +fi + +# Check that DEPLOYMENT_VARIANT is defined +if [[ -z ${DEPLOYMENT_VARIANT} ]]; then + echo "DEPLOYMENT_VARIANT is not defined" + exit 1 +fi + +# Set template directory +TEMPLATE_DIR=$(readlink -f $(dirname $0)/../) diff --git a/examples/unfurl-technology-maintenance/scripts/continue.sh b/examples/unfurl-technology-maintenance/scripts/continue.sh new file mode 100755 index 0000000000..76d33d7440 --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/continue.sh @@ -0,0 +1,11 @@ +#! /usr/bin/bash +set -e + +# Set working directory +cd "$(dirname "$0")" + +# Load configuration +source configuration.sh + +# Continue deployment +$VINTNER instances continue --instance ${TEMPLATE_NAME} diff --git a/examples/unfurl-technology-maintenance/scripts/deploy.sh b/examples/unfurl-technology-maintenance/scripts/deploy.sh new file mode 100755 index 0000000000..ed32821513 --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/deploy.sh @@ -0,0 +1,15 @@ +#! /usr/bin/bash +set -e + +# Set working directory +cd "$(dirname "$0")" + +# Load configuration +source configuration.sh + +$VINTNER template pull --template ${TEMPLATE_DIR} +$VINTNER templates import --template ${TEMPLATE_NAME} --path ${TEMPLATE_DIR} +$VINTNER instances init --instance ${TEMPLATE_NAME} --template ${TEMPLATE_NAME} +$VINTNER instances resolve --instance ${TEMPLATE_NAME} --presets ${DEPLOYMENT_VARIANT} +$VINTNER instances validate --instance ${TEMPLATE_NAME} --inputs ${TEMPLATE_DIR}/deployment-inputs.ignored.yaml +$VINTNER instances deploy --instance ${TEMPLATE_NAME} --inputs ${TEMPLATE_DIR}/deployment-inputs.ignored.yaml diff --git a/examples/unfurl-technology-maintenance/scripts/pull.sh b/examples/unfurl-technology-maintenance/scripts/pull.sh new file mode 100644 index 0000000000..455523ca8c --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/pull.sh @@ -0,0 +1,9 @@ +#! /usr/bin/bash +set -e + +# Load configuration +source configuration.sh + +# Pull dependencies +$VINTNER template pull --template ${TEMPLATE_DIR} + diff --git a/examples/unfurl-technology-maintenance/scripts/quality.sh b/examples/unfurl-technology-maintenance/scripts/quality.sh new file mode 100644 index 0000000000..f6ec287d7c --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/quality.sh @@ -0,0 +1,8 @@ +#! /usr/bin/bash +set -e + +# Load configuration +source configuration.sh + +# Quality +$VINTNER template quality --template ${TEMPLATE_DIR}/variable-service-template.yaml --presets ${DEPLOYMENT_VARIANT} \ No newline at end of file diff --git a/examples/unfurl-technology-maintenance/scripts/reimport.sh b/examples/unfurl-technology-maintenance/scripts/reimport.sh new file mode 100755 index 0000000000..d2ecaedfa4 --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/reimport.sh @@ -0,0 +1,19 @@ +#! /usr/bin/bash +set -e + +# Set working directory +cd "$(dirname "$0")" + +# Load configuration +source configuration.sh + +$VINTNER instances delete --instance ${TEMPLATE_NAME} + +$VINTNER templates delete --template ${TEMPLATE_NAME} + +$VINTNER template pull --template ${TEMPLATE_DIR} +$VINTNER templates import --template ${TEMPLATE_NAME} --path ${TEMPLATE_DIR} +$VINTNER instances init --instance ${TEMPLATE_NAME} --template ${TEMPLATE_NAME} +$VINTNER instances resolve --instance ${TEMPLATE_NAME} --presets ${DEPLOYMENT_VARIANT} +$VINTNER instances validate --instance ${TEMPLATE_NAME} --inputs ${TEMPLATE_DIR}/deployment-inputs.ignored.yaml +$VINTNER instances deploy --instance ${TEMPLATE_NAME} --inputs ${TEMPLATE_DIR}/deployment-inputs.ignored.yaml diff --git a/examples/unfurl-technology-maintenance/scripts/setup.sh b/examples/unfurl-technology-maintenance/scripts/setup.sh new file mode 100755 index 0000000000..93f416cc24 --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/setup.sh @@ -0,0 +1,14 @@ +#! /usr/bin/bash +set -e + +# Set working directory +cd "$(dirname "$0")" + +# Load configuration +source configuration.sh + +# Setup +$VINTNER setup init +$VINTNER orchestrators init unfurl +$VINTNER orchestrators enable --orchestrator unfurl +$VINTNER orchestrators attest --orchestrator unfurl \ No newline at end of file diff --git a/examples/unfurl-technology-maintenance/scripts/undeploy.sh b/examples/unfurl-technology-maintenance/scripts/undeploy.sh new file mode 100755 index 0000000000..799765e670 --- /dev/null +++ b/examples/unfurl-technology-maintenance/scripts/undeploy.sh @@ -0,0 +1,11 @@ +#! /usr/bin/bash +set -e + +# Set working directory +cd "$(dirname "$0")" + +# Load configuration +source configuration.sh + +# Undeploy application +$VINTNER instances undeploy --instance ${TEMPLATE_NAME} diff --git a/src/assets/templates/template-init/scripts/deploy.sh b/src/assets/templates/template-init/scripts/deploy.sh index e8f7ee4c99..3fd5157025 100644 --- a/src/assets/templates/template-init/scripts/deploy.sh +++ b/src/assets/templates/template-init/scripts/deploy.sh @@ -4,6 +4,7 @@ set -e # Load configuration source configuration.sh +$VINTNER template pull --template ${TEMPLATE_DIR} $VINTNER templates import --template ${TEMPLATE_NAME} --path ${TEMPLATE_DIR} $VINTNER instances init --instance ${TEMPLATE_NAME} --template ${TEMPLATE_NAME} $VINTNER instances resolve --instance ${TEMPLATE_NAME} --inputs ${TEMPLATE_DIR}/tests/first/inputs.yaml diff --git a/src/assets/templates/template-init/scripts/pull.sh b/src/assets/templates/template-init/scripts/pull.sh index b832306cc1..d22435bfe8 100755 --- a/src/assets/templates/template-init/scripts/pull.sh +++ b/src/assets/templates/template-init/scripts/pull.sh @@ -4,4 +4,4 @@ set -e # Load configuration source configuration.sh -$VINTNER pull ${TEMPLATE_DIR} +$VINTNER template pull --template ${TEMPLATE_DIR} diff --git a/src/assets/templates/template-init/scripts/reimport.sh b/src/assets/templates/template-init/scripts/reimport.sh index 731ba8c7ba..258c3c6962 100644 --- a/src/assets/templates/template-init/scripts/reimport.sh +++ b/src/assets/templates/template-init/scripts/reimport.sh @@ -7,6 +7,7 @@ source configuration.sh $VINTNER instances delete --instance ${TEMPLATE_NAME} $VINTNER templates delete --template ${TEMPLATE_NAME} +$VINTNER template pull --template ${TEMPLATE_DIR} $VINTNER templates import --template ${TEMPLATE_NAME} --path ${TEMPLATE_DIR} $VINTNER instances init --instance ${TEMPLATE_NAME} --template ${TEMPLATE_NAME} $VINTNER instances resolve --instance ${TEMPLATE_NAME} --inputs ${TEMPLATE_DIR}/tests/first/inputs.yaml diff --git a/src/controller/template/pull.ts b/src/controller/template/pull.ts index 8c16486b51..1c6081bcb7 100644 --- a/src/controller/template/pull.ts +++ b/src/controller/template/pull.ts @@ -32,11 +32,13 @@ export default async function (options: TemplatePullOptions) { const source = path.isAbsolute(dependency.source) ? dependency.source : path.join(options.template, dependency.source) - const target = path.join(options.template, dependency.target || '.') if (options.link) { + const target = path.join(options.template, dependency.target || '.') + await files.link(source, target) } else { + const target = path.join(options.template, dependency.target || files.getBase(source)) await files.sync(source, target) } } diff --git a/src/controller/template/puml/types.ts b/src/controller/template/puml/types.ts index ce6723815b..e6e45b880a 100644 --- a/src/controller/template/puml/types.ts +++ b/src/controller/template/puml/types.ts @@ -35,7 +35,7 @@ export default async function (options: TemplatePUMLTypesOptions) { for (const [type, plot] of Object.entries(result)) { const output = path.join( outputDir, - files.getFilename(options.path).replace(/(\.yaml|\.yml)/, '.' + type.replace('_', '-') + '.puml') + files.getBase(options.path).replace(/(\.yaml|\.yml)/, '.' + type.replace('_', '-') + '.puml') ) if (!output.endsWith('.puml')) throw new Error(`Output path "${output}" does not end with '.puml'`) diff --git a/src/utils/files.ts b/src/utils/files.ts index c2df9ffbe6..16c0fb8213 100644 --- a/src/utils/files.ts +++ b/src/utils/files.ts @@ -195,7 +195,7 @@ export function getDirectory(file: string) { return path.parse(path.resolve(file)).dir } -export function getFilename(file: string) { +export function getBase(file: string) { return path.parse(path.resolve(file)).base }