Skip to content

Commit

Permalink
Feature: break glass input helm-args and set globals for subcharts …
Browse files Browse the repository at this point in the history
…to use. (#62)

* break glass

* disable test
  • Loading branch information
Benbentwo authored Jul 12, 2024
1 parent c6a83a1 commit a83d2c0
Show file tree
Hide file tree
Showing 3 changed files with 208 additions and 0 deletions.
190 changes: 190 additions & 0 deletions .github/disabled/test-helm-raw-additional-args.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: Test - Helm raw with additional args
on:
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered
# #
# # Added pull_request to register workflow from the PR.
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo
# pull_request: {}
workflow_dispatch: {}

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Setup
run: echo "Do setup"

- id: random
shell: bash
run: |-
echo "password=$(echo $RANDOM | md5sum | head -c 20)" >> $GITHUB_OUTPUT
outputs:
random: ${{ steps.random.outputs.password }}

test:
runs-on: ubuntu-latest
continue-on-error: true
needs: [setup]
services:
localstack:
image: localstack/localstack:2.1.0
ports:
- 4566:4566
- 4510-4559:4510-4559
credentials:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: ./action

- run: |
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \
--name "/platform/default/staging/default_ingress_domain" \
--type "SecureString" \
--value "example.com"
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \
--name "/platform/default/staging/default_alb_ingress_group" \
--type "SecureString" \
--value "default" \
--debug
aws ${AWS_ENDPOINT_OVERRIDE:+--endpoint-url $AWS_ENDPOINT_OVERRIDE} ssm put-parameter \
--name "/platform/default/_metadata/kube_version" \
--type "SecureString" \
--value "1.15" \
--debug
env:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
## Use localhost to connect localstack because the commands runs not in a container
AWS_ENDPOINT_OVERRIDE: http://localhost:4566
- uses: ./action
id: current
with:
cluster: https://github.com/cloudposse/argocd-deploy-non-prod-test/blob/main/plat/ue2-sandbox/apps
toolchain: helm
environment: staging
namespace: staging
path: ./action/test/helm/example-app
application: test-app
ssm-path: platform/default
github-pat: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
image: nginx
image-tag: ${{ needs.setup.outputs.random }}
helm-args: --set foo=${{ needs.setup.outputs.random }}
env:
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
## Use localhost to connect localstack because the commands runs not in a container
AWS_ENDPOINT_OVERRIDE: http://localhost:4566
## Use localhost to connect localstack because chamber does not run in a container
CHAMBER_AWS_SSM_ENDPOINT: http://localhost:4566/

outputs:
status: ${{ steps.current.outcome }}
result: ${{ steps.current.outputs.webapp-url }}
sha: ${{ steps.current.outputs.sha }}

assert:
runs-on: ubuntu-latest
needs: [setup, test]
steps:
- uses: nick-fields/assert-action@v1
with:
expected: "success"
actual: "${{ needs.test.outputs.status }}"

- uses: nick-fields/assert-action@v1
with:
expected: "https://example-app.example.com/dashboard"
actual: "${{ needs.test.outputs.result }}"

- uses: nick-fields/assert-action@v1
with:
expected: ""
actual: "${{ needs.test.outputs.sha }}"
comparison: notEqual

- name: Checkout Argo Configuration
uses: actions/checkout@v3
with:
repository: cloudposse/argocd-deploy-non-prod-test
ref: ${{ needs.test.outputs.sha }}
token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }}
path: ./assert

- name: Get Image
id: image
shell: bash
run: |-
image=$( \
yq eval-all '.spec.template.spec.containers[].image | select(. != null)' \
./assert/plat/ue2-sandbox/apps/staging/test-app/manifests/resources.yaml \
)
echo "value=${image}" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
with:
expected: "nginx:${{ needs.setup.outputs.random }}"
actual: "${{ steps.image.outputs.value }}"

- name: Get Ingress
id: ingress
shell: bash
run: |-
ingress=$( \
yq eval-all 'select(.kind == "Ingress") | .apiVersion' \
./assert/plat/ue2-sandbox/apps/staging/test-app/manifests/resources.yaml \
)
echo "value=${ingress}" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
with:
expected: "networking.k8s.io/v1beta1"
actual: "${{ steps.ingress.outputs.value }}"

- name: Get Name
id: name
shell: bash
run: |-
name=$( \
yq eval-all '.name' \
./assert/plat/ue2-sandbox/apps/staging/test-app/config.yaml \
)
echo "value=${name}" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
with:
expected: "staging.test-app"
actual: "${{ steps.name.outputs.value }}"

- name: Get ConfigMap Data
id: configmap
shell: bash
run: |-
configmap=$( \
yq eval-all '.data | select(. != null)' \
./assert/plat/ue2-sandbox/apps/staging/test-app/manifests/resources.yaml \
)
echo "value=${configmap}" >> $GITHUB_OUTPUT
- uses: nick-fields/assert-action@v1
with:
expected: "foo:${{ needs.setup.outputs.random }}"
actual: "${{ steps.configmap.outputs.value }}"
teardown:
runs-on: ubuntu-latest
needs: [assert]
if: ${{ always() }}
steps:
- name: Tear down
run: echo "Do Tear down"
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ inputs:
description: 'Run helm dependency build, only for helm toolchain, `true` or `false`'
required: false
default: "false"
helm-args:
description: 'Additional helm arguments'
required: false
default: ""
outputs:
webapp-url:
description: "Web Application url"
Expand Down Expand Up @@ -277,13 +281,16 @@ runs:
helm template ${{ inputs.application }} ${{ inputs.path }} \
--set image.repository=${{ inputs.image }} \
--set global.image.repository=${{ inputs.image }} \
--set image.tag=${{ inputs.image-tag }} \
--set global.image.tag=${{ inputs.image-tag }} \
--set environment=${{ inputs.environment }} \
--create-namespace=true \
--namespace ${{ inputs.namespace }} \
--set ingress.default.hosts.example=test \
--values $(pwd)/platform.yaml \
${VALUES_STR} \
${{ inputs.helm-args }} \
${{ steps.arguments.outputs.kube_version }} \
> ${{ steps.config.outputs.tmp }}/manifests/resources.yaml
env:
Expand Down
11 changes: 11 additions & 0 deletions test/helm/example-app/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: test
data:
{{ with .Values.foo -}}
foo: '{{ . }}'
{{- end }}
{{ with .Values.bar -}}
bar: '{{ . }}'
{{- end }}

0 comments on commit a83d2c0

Please sign in to comment.