Skip to content

Commit

Permalink
Fixed a typo in env vars passed to containers in ahoy config + tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Apr 29, 2024
1 parent d80ade2 commit ddc20de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 6 additions & 9 deletions .ahoy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,15 @@ commands:

cli:
usage: Start a shell or run a command inside the CLI service container.
# Drop into shell if no arguments were supplied.
# If arguments were supplied - a new shell will be started with environment
# variables passed from the host environment and filtered by prefix.
# This allows passing the host environment variables to a container without
# the need to restart it.
# Escape double quotes with \" (slash double-quote) when passing arguments
# containing spaces.
# Drop into a shell if no arguments are supplied, otherwise run the command.
# Environment variables are passed from the host and filtered by prefix.
# Use \" (slash followed by a double quote) to escape double quotes in
# arguments that contain spaces.
cmd: |
if [ "${#}" -ne 0 ]; then
docker compose exec $(env | cut -f1 -d= | grep "TERM\|COMPOSE_\|GITHUB_\|DOCKER_\DRUPAL_\|DREVOPS_" | sed 's/^/-e /') -T cli bash -c "$*"
docker compose exec $(env | cut -f1 -d= | grep "TERM\|COMPOSE_\|GITHUB_\|DOCKER_\|DRUPAL_\|DREVOPS_" | sed 's/^/-e /') -T cli bash -c "$*"
else
docker compose exec $(env | cut -f1 -d= | grep "TERM\|COMPOSE_\|GITHUB_\|DOCKER_\DRUPAL_\|DREVOPS_" | sed 's/^/-e /') cli bash
docker compose exec $(env | cut -f1 -d= | grep "TERM\|COMPOSE_\|GITHUB_\|DOCKER_\|DRUPAL_\|DREVOPS_" | sed 's/^/-e /') cli bash
fi
composer:
Expand Down
8 changes: 8 additions & 0 deletions .scaffold/tests/bats/_helper.workflow.bash
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ assert_ahoy_cli() {
assert_success
assert_output_not_contains "Containers are not running."
assert_output_contains "Test from inside of the container"

# Assert that only allowed filtered variables are passed from the environment.
export DRUPAL_UNFILTERED_VAR="drupalvar"
export OTHER_FILTERED_VAR="othervar"

run ahoy cli "echo \$DRUPAL_UNFILTERED_VAR"
assert_output_contains "drupalvar"
assert_output_not_contains "othervar"
}

assert_env_changes() {
Expand Down

1 comment on commit ddc20de

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.