Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Add use-context command #50

Add use-context command

Add use-context command #50

Workflow file for this run

name: E2E Test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]
jobs:
test:
runs-on: ubuntu-latest
env:
LF_TELEMETRY_DISABLED: "1"
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.4.6
terraform_wrapper: false
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: stable
- run: go install .
- name: layerform config set-context
run: |
# validations, fails if command succeeds
! layerform config set-context test -t local # missing --dir
! layerform config set-context test -t s3 --bucket bucket # missing region
! layerform config set-context test -t s3 --region region # missing bucket
! layerform config set-context test -t cloud --url "invalid url" --email [email protected] --password strongpass
! layerform config set-context test -t cloud --url https://a.b.com --email invalid --password strongpass
! layerform config set-context test -t cloud --email invalid --password strongpass # missing url
! layerform config set-context test -t cloud --url https://a.b.com --password strongpass # missing email
! layerform config set-context test -t cloud --url https://a.b.com --email [email protected] # missing password
# set valid contexts
layerform config set-context test-s3 -t s3 --bucket bucket --region us-east-1
layerform config set-context test-cloud -t cloud --url https://demo.layerform.dev --email [email protected] --password strongpass
layerform config set-context test-local -t local --dir test
- name: layerform config use-context
run: |
# fails if command succeeds
! layerform config use-context test-does-not-exist # context does not exist
# switch context to test-local
layerform config use-context test-local
layerfrom get-contexts | tee usecontext
grep -E '^\*\s+test-local' usecontext
!grep -E '^\*\s+test-s3' usecontext
# switch context to test-s3
layerform config use-context test-s3
layerfrom get-contexts | tee usecontext
!grep -E '^\*\s+test-local' usecontext
grep -E '^\*\s+test-s3' usecontext
- name: Configure
run: |
layerform configure --file examples/local/layerform.json
- name: List definitions
run: |
layerform list definitions | tee definitions
grep -E 'foo' definitions
grep -E 'bar\s+foo' definitions
grep -E 'baz\s+foo' definitions
- name: List instances
run: |
layerform list instances | tee instances
grep 'No layer instances spawned' instances
- name: Spawn instances
run: |`

Check failure on line 86 in .github/workflows/e2e.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/e2e.yml

Invalid workflow file

You have an error in your yaml syntax on line 86
layerform spawn bar test_bar
layerform spawn baz test_baz
layerform spawn bar test_custom_foo --base foo=custom
layerform list instances | tee instances
grep -E 'default\s+foo\s+alive' instances
grep -E 'test_bar\s+bar\s+foo=default\s+alive' instances
grep -E 'test_baz\s+baz\s+foo=default\s+alive' instances
grep -E 'custom\s+foo\s+alive' instances
grep -E 'test_custom_foo\s+bar\s+foo=custom\s+alive' instances
- name: Output
run: |
layerform output bar test_bar | jq .bar_file.value | tee output
grep -E '\.layerform\/examples\/local\/foo-default\/bar-test_bar\.txt' output
layerform output bar test_bar | jq .foo_file.value | tee output
grep -E '\.layerform\/examples\/local\/foo-default\/\.keep' output
- name: Refresh
run: |
layerform refresh bar test_bar --var prefix=test-prefix-
layerform output bar test_bar | jq .bar_file.value | tee output
grep -E '\.layerform\/examples\/local\/test-prefix-foo-default\/bar-test_bar\.txt' output
layerform refresh bar test_bar
- name: Can't kill instance that has dependants
run: |
# fails if kill succeeds
! layerform kill foo default
- name: Kill instance
run: |
yes yes | layerform kill bar test_bar
layerform list instances | tee instances
# fails if instance is still there
! grep -E 'test_bar\s+bar\s+foo=default\s+alive' instances
- name: Can't spawn instance with invalid name
run: |
# fails if spawn succeeds
! layerform spawn foo 'this has spaces'
! layerform spawn foo 'this#has%special&chars'
! layerform spawn foo '_cant-start-with-underscore'
! layerform spawn foo 'cant-end-with-underscore_'
! layerform spawn foo 'cant-end-with-dash-'