From faa68866e4a92e8d61f9ee311cf40bd57f4565af Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Wed, 13 Dec 2023 03:11:01 +0300 Subject: [PATCH] Get any info from atmos describe component (#17) ## what * Remove restriction to `settings` section. ## Why * To reuse this action for fetching `component_info.component_path` settings Co-authored-by: Jeremy White Co-authored-by: Erik Osterman (CEO @ Cloud Posse) --- .github/workflows/test-positive.yml | 6 +++--- README.md | 29 +++++++++++++++++++++++++++- README.yaml | 30 ++++++++++++++++++++++++++++- action.yml | 2 +- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-positive.yml b/.github/workflows/test-positive.yml index 957dba9..9903626 100644 --- a/.github/workflows/test-positive.yml +++ b/.github/workflows/test-positive.yml @@ -30,21 +30,21 @@ jobs: with: component: foo stack: core-ue1-dev - settings-path: level1.level2.level3.secrets-arn + settings-path: settings.level1.level2.level3.secrets-arn - uses: ./ id: derived with: component: derived stack: core-ue1-dev - settings-path: level1.example + settings-path: settings.level1.example - uses: ./ id: defaults with: component: test-defaults stack: core-ue1-dev - settings-path: level1.example + settings-path: settings.level1.example assert: runs-on: ubuntu-latest diff --git a/README.md b/README.md index ca0204a..4f78c38 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ components: with: component: foo stack: core-ue1-dev - settings-path: secrets-arn + settings-path: settings.secrets-arn - name: Set ENV Vars with AWS Secrets Manager Secret uses: aws-actions/aws-secretsmanager-get-secrets@v1 @@ -104,6 +104,33 @@ components: secret-ids: ${{ steps.example.outputs.value }} ``` +## Migrating from `v0` to `v1` + +Starting from `v1` the action is no longer restricted to retrieving the component config from only the `settings` section. +If you want the same behavior in `v1` as in`v0`, you should add the `settings.` prefix to the value of the `settings-path` variable. +For example, in `v1` you would provide `settings.secrets-arn` as the value to the `settings-path` +```yaml + - name: Get Atmos Setting for Secret ARN + uses: cloudposse/github-action-atmos-get-setting@v1 + id: example + with: + component: foo + stack: core-ue1-dev + settings-path: settings.secrets-arn +``` + +Which would provide the same output as passing only `secrets-arn` in `v0` + +```yaml + - name: Get Atmos Setting for Secret ARN + uses: cloudposse/github-action-atmos-get-setting@v0 + id: example + with: + component: foo + stack: core-ue1-dev + settings-path: secrets-arn +``` + diff --git a/README.yaml b/README.yaml index f3493b8..6f89df5 100644 --- a/README.yaml +++ b/README.yaml @@ -72,13 +72,41 @@ usage: |- with: component: foo stack: core-ue1-dev - settings-path: secrets-arn + settings-path: settings.secrets-arn - name: Set ENV Vars with AWS Secrets Manager Secret uses: aws-actions/aws-secretsmanager-get-secrets@v1 with: secret-ids: ${{ steps.example.outputs.value }} ``` + + ## Migrating from `v0` to `v1` + + Starting from `v1` the action is no longer restricted to retrieving the component config from only the `settings` section. + If you want the same behavior in `v1` as in`v0`, you should add the `settings.` prefix to the value of the `settings-path` variable. + For example, in `v1` you would provide `settings.secrets-arn` as the value to the `settings-path` + ```yaml + - name: Get Atmos Setting for Secret ARN + uses: cloudposse/github-action-atmos-get-setting@v1 + id: example + with: + component: foo + stack: core-ue1-dev + settings-path: settings.secrets-arn + ``` + + Which would provide the same output as passing only `secrets-arn` in `v0` + + ```yaml + - name: Get Atmos Setting for Secret ARN + uses: cloudposse/github-action-atmos-get-setting@v0 + id: example + with: + component: foo + stack: core-ue1-dev + settings-path: secrets-arn + ``` + include: - "docs/github-action.md" diff --git a/action.yml b/action.yml index ef98106..97b35c4 100644 --- a/action.yml +++ b/action.yml @@ -32,5 +32,5 @@ runs: -s ${{ inputs.stack }} \ --format json \ --file "$OUTPUT_FILE" || echo '{}' > "$OUTPUT_FILE" - value=$(jq -rc --arg key ${{ inputs.settings-path }} '.settings | getpath($key | split("."))' "$OUTPUT_FILE") + value=$(jq -rc --arg key ${{ inputs.settings-path }} '. | getpath($key | split("."))' "$OUTPUT_FILE") echo "value=$value" >> $GITHUB_OUTPUT