From c9505a9a64652caf164fbf3679cec4ed818bf37d Mon Sep 17 00:00:00 2001 From: Justin Law Date: Thu, 3 Oct 2024 10:32:28 -0400 Subject: [PATCH] WIP deploy tasks --- tasks.yaml | 1 + tasks/create.yaml | 38 ++++++++++++++++++++++++++++---------- tasks/deploy.yaml | 10 ++++++---- tasks/publish.yaml | 20 ++++++++++++++++++-- tasks/setup.yaml | 12 ++++++++++++ tasks/utils.yaml | 19 +++++++++++++++++++ 6 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 tasks/utils.yaml diff --git a/tasks.yaml b/tasks.yaml index 5f6f6537c..df7f7b52e 100644 --- a/tasks.yaml +++ b/tasks.yaml @@ -38,6 +38,7 @@ includes: - publish: ./tasks/publish.yaml - setup: ./tasks/setup.yaml - deploy: ./tasks/deploy.yaml + - utils: ./tasks/utils.yaml tasks: ####### diff --git a/tasks/create.yaml b/tasks/create.yaml index e5020fdac..01b58c32a 100644 --- a/tasks/create.yaml +++ b/tasks/create.yaml @@ -35,11 +35,18 @@ tasks: cmd: | if [[ ${FLAVOR} != "upstream" || ${{ .inputs.override }} != "false" ]]; then if [ ! "$(docker ps -q -f name=${{ .inputs.name }})" ]; then - docker run -d -p ${{ .inputs.port }}:5000 --restart=always --name ${{ .inputs.name }} registry:2 -q - fi + docker run -d -p ${{ .inputs.port }}:5000 --restart=always -q --name ${{ .inputs.name }} registry:2 + echo "false" else - echo "Non-upstream flavor detected, skipping local registry build" + echo "true" fi + mute: true + setVariables: + - name: ENABLE_LOG + - task: utils:log + with: + log: "Non-upstream flavor detected, skipping local image build" + enable: ${ENABLE_LOG} ########### # REUSEABLE @@ -72,8 +79,9 @@ tasks: description: "Image repository for the image tag" required: true actions: - - cmd: | - printf "\n🐸 Creating image at ${{ .inputs.dockerfile }}\n\n" + - task: utils:log + with: + log: "Creating image at ${{ .inputs.dockerfile }}" - description: "Build the Docker image" shell: linux: bash @@ -86,9 +94,17 @@ tasks: -f ${{ .inputs.dockerfile }} \ --build-arg LOCAL_VERSION=${{ .inputs.version }} \ ${{ .inputs.buildOptions }} ${{ .inputs.buildContext }} + echo "false" else - echo "Non-upstream flavor detected, skipping image build" + echo "true" fi + mute: true + setVariables: + - name: ENABLE_LOG + - task: utils:log + with: + log: "Non-upstream flavor detected, skipping local image build" + enable: ${ENABLE_LOG} - name: package description: "Create a Zarf package" @@ -122,8 +138,9 @@ tasks: description: "Set the version of the Zarf package and target image(s)" required: true actions: - - cmd: | - printf "\n🐸 Creating package at ${{ .inputs.path }}\n\n" + - task: utils:log + with: + log: "Creating package at ${{ .inputs.path }}" - description: "Create the Zarf package" task: create-common:package env: @@ -155,8 +172,9 @@ tasks: default: "" required: false actions: - - cmd: | - printf "\n🐸 Creating bundle at ${{ .inputs.path }}\n\n" + - task: utils:log + with: + log: "Creating bundle at ${{ .inputs.path }}" - description: "Create the UDS bundle" task: create-common:test-bundle with: diff --git a/tasks/deploy.yaml b/tasks/deploy.yaml index 671750577..89510ddc2 100644 --- a/tasks/deploy.yaml +++ b/tasks/deploy.yaml @@ -25,8 +25,9 @@ tasks: default: "--log-level warn --no-progress --confirm" required: false actions: - - cmd: | - printf "\n🐸 Deploying package at ${{ .inputs.path }}\n\n" + - task: utils:log + with: + log: "Deploying package at ${{ .inputs.path }}" - description: Get the current Zarf package name cmd: cat ${{ .inputs.path }}/zarf.yaml | uds zarf tools yq .metadata.name setVariables: @@ -58,8 +59,9 @@ tasks: description: "Set the version of the UDS Bundle and target image(s)" required: true actions: - - cmd: | - printf "\n🐸 Deploying package at ${{ .inputs.path }}\n\n" + - task: utils:log + with: + log: "Deploying bundle at ${{ .inputs.path }}" - task: deploy-common:test-bundle env: - UDS_ARCH=${{ .inputs.architecture }} diff --git a/tasks/publish.yaml b/tasks/publish.yaml index 577a2885f..e2f8e1ca3 100644 --- a/tasks/publish.yaml +++ b/tasks/publish.yaml @@ -26,9 +26,17 @@ tasks: cmd: | if [[ ${FLAVOR} = "upstream" || ${{ .inputs.override }} = "true" ]]; then docker tag ${{ .inputs.current }} ${{ .inputs.new }} + echo "false" else - echo "Non-upstream flavor detected, skipping image build" + echo "true" fi + mute: true + setVariables: + - name: ENABLE_LOG + - task: utils:log + with: + log: "Non-upstream flavor detected, skipping local image re-tag" + enable: ${ENABLE_LOG} - name: docker description: "Push an existing Docker image to its tagged repository" @@ -53,6 +61,14 @@ tasks: cmd: | if [[ ${FLAVOR} = "upstream" || ${{ .inputs.override }} = "true" ]]; then docker push ${{ .inputs.tag }} ${{ .inputs.options }} + echo "false" else - echo "Non-upstream flavor detected, skipping image build" + echo "true" fi + mute: true + setVariables: + - name: ENABLE_LOG + - task: utils:log + with: + log: "Non-upstream flavor detected, skipping local image push" + enable: ${ENABLE_LOG} diff --git a/tasks/setup.yaml b/tasks/setup.yaml index 3cc710ae3..ac06b210e 100644 --- a/tasks/setup.yaml +++ b/tasks/setup.yaml @@ -19,11 +19,17 @@ tasks: - name: k3d-cpu-cluster-slim description: "Creates a UDS K3d cluster with slim UDS Core and CPU-only Capability" actions: + - task: utils:log + with: + log: "Creating a UDS K3d cluster with slim UDS Core and CPU-only Capability" - task: setup-common:k3d-test-cluster - name: k3d-gpu-cluster-slim description: "Creates a UDS K3d cluster with slim UDS Core and NVIDIA GPU Capability" actions: + - task: utils:log + with: + log: "Creating a UDS K3d cluster with slim UDS Core and NVIDIA GPU Capability" - task: create:k3d-gpu-image - task: setup-common:k3d-test-cluster with: @@ -35,6 +41,9 @@ tasks: - name: k3d-cpu-cluster-full description: "Creates a UDS K3d cluster with full UDS Core and CPU-only Capability" actions: + - task: utils:log + with: + log: "Creating a UDS K3d cluster with full UDS Core and CPU-only Capability" - task: setup-common:k3d-full-cluster with: version: 0.27.3 @@ -44,6 +53,9 @@ tasks: - name: k3d-gpu-cluster-full description: "Creates a UDS K3d cluster with full UDS Core and NVIDIA GPU Capability" actions: + - task: utils:log + with: + log: "Creating a UDS K3d cluster with full UDS Core and NVIDIA GPU Capability" - task: create:k3d-gpu-image - task: setup-common:k3d-full-cluster with: diff --git a/tasks/utils.yaml b/tasks/utils.yaml new file mode 100644 index 000000000..c8fa4f709 --- /dev/null +++ b/tasks/utils.yaml @@ -0,0 +1,19 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/defenseunicorns/uds-cli/v0.14.0/tasks.schema.json + +tasks: + - name: log + description: "LeapfrogAI logger" + inputs: + log: + description: "Content to be logged to the CLI" + required: true + enable: + description: "Whether to enable or disable the logging" + default: "true" + required: false + actions: + - cmd: | + if [[ ${{ .inputs.enable }} = "true" ]] + printf "\n🐸 ${{ .inputs.log }}\n\n" + fi + mute: true