defenseunicorns / maru-runner

The Unicorn Task Runner
Apache License 2.0
8 stars 0 forks source link

Add ability to set top-level defaults for actions #36

Open zack-is-cool opened 3 months ago

zack-is-cool commented 3 months ago

Given this example (below), I find myself having to set shell over and over for each cmd. In my current project I have this for each cmd which is 15 times (and growing). It would be a nice QoL to be able to set some kind of top level default configuration to keep my task actions a lil drier. Maybe this could apply to other features like maxRetries, maxTotalSeconds, mute. Additionally the defaults need to be overridable at each individual action.

    actions:
      - task: check-env
        with:
          env: ${ENV}
      - description: "Check if bootstrap for '$env' is clean"
        cmd: |
          set -exo pipefail
          # check if ./iac/env/${INPUT_ENV}/backends/bootstrap-backend.tfconfig exists
          if [ -f ./iac/env/${INPUT_ENV}/backends/bootstrap-backend.tfconfig ]; then
            echo "terraform s3 backend environment files for ${INPUT_ENV} already exists"
            exit 1
          fi
        shell:
          linux: bash
          darwin: bash
      - description: "Init the bootstrap module"
        task: terraform-init
        with:
          root_module: bootstrap
      - description: "Apply the bootstrap module in the specified environment"
        task: terraform-apply
        with:
          env: ${ENV}
          root_module: bootstrap
          var_files: '["common.terraform.tfvars", "bootstrap.terraform.tfvars"]'
      - description: "Migrate local backend to s3"
        cmd: |
          set -exo pipefail
          cd ./iac/bootstrap
          terraform init --reconfigure --force-copy --backend-config=../env/${INPUT_ENV}/backends/bootstrap-backend.tfconfig && \
            mv terraform.tfstate "terraform-tfstate.${INPUT_ENV}-local-backend-backup"
        shell:
          linux: bash
          darwin: bash

thx

UncleGedd commented 3 months ago

Thanks @zack-is-cool we will prioritize and implement