Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment output was inside section only intended for runtime.extensions, fixes #54 #55

Merged
merged 4 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ post_install_actions:
}
ENDROUTES
)
PLATFORM_ROUTES="$( if base64 --version >/dev/null 2>&1; then echo -n ${platform_routes} | base64 -w0; else echo -n ${platform_routes} | base64; fi)"
BASE64_ENCODE="base64"
if base64 -w 0 </dev/null >/dev/null 2>&1; then BASE64ENCODE="base64 -w 0"; fi
rfay marked this conversation as resolved.
Show resolved Hide resolved
echo BASE64_ENCODE=${BASE64_ENCODE}
PLATFORM_ROUTES="$(echo -n ${platform_routes} | ${BASE64_ENCODE})"
PLATFORM_PROJECT_ENTROPY="$(echo $RANDOM | shasum -a 256 | awk '{print $1}')"
export relationships=()
{{ $dbtype := "" }}
Expand All @@ -177,23 +180,23 @@ post_install_actions:
{{ $dbtype = regexReplaceAll "^oracle-mysql:" $dbtype "mysql:" }}
export DBTYPE={{ regexReplaceAll ":.*$" $dbtype "" }}
export DBVERSION={{ regexReplaceAll "^.*:" $dbtype "" }}
relationships+=($(./platformsh/generate_db_relationship.sh '{{ $relationship_name }}' '{{ $dbtype }}' | base64))
relationships+=($(./platformsh/generate_db_relationship.sh '{{ $relationship_name }}' '{{ $dbtype }}' | ${BASE64_ENCODE}))
#printf "relationships length after db=${#relationships[@]}\nrelationships value=$(echo $relationships | base64 -d)"
{{ end }}

{{ if and .services.cache.type (hasPrefix "redis" .services.cache.type) }}
relationships+=($(./platformsh/generate_redis_relationship.sh | base64))
relationships+=($(./platformsh/generate_redis_relationship.sh | ${BASE64_ENCODE}))
#printf "relationships length after redis=${#relationships[@]}\nrelationships value=$(echo $relationships | base64 -d)"
{{ end }}
{{ if and .services.cache.type (hasPrefix "memcached" .services.cache.type) }}
relationships+=($(./platformsh/generate_memcached_relationship.sh | base64))
relationships+=($(./platformsh/generate_memcached_relationship.sh | ${BASE64_ENCODE}))
{{ end }}
{{ if and .services.search.type (hasPrefix "elasticsearch" .services.search.type) }}
relationships+=($(./platformsh/generate_elasticsearch_relationship.sh | base64))
relationships+=($(./platformsh/generate_elasticsearch_relationship.sh | ${BASE64_ENCODE}))
{{ end }}

#echo "Number of relationships=${#relationships[@]}"
PLATFORM_RELATIONSHIPS="$((echo '{'; for r in ${relationships[@]::${#relationships[@]}-1}; do echo $r | base64 -d; printf ', \n'; done; echo ${relationships[@]: -1:1} | base64 -d; echo ' }') | base64)"
PLATFORM_RELATIONSHIPS="$((echo '{'; for r in ${relationships[@]::${#relationships[@]}-1}; do echo $r | base64 -d; printf ', \n'; done; echo ${relationships[@]: -1:1} | base64 -d; echo ' }') | ${BASE64_ENCODE})"
#printf "PLATFORM_RELATIONSHIPS=$(echo $PLATFORM_RELATIONSHIPS | base64 -d)"

if [ -f config.platformsh.yaml ] && ! grep '#ddev-generated' config.platformsh.yaml; then
Expand All @@ -219,18 +222,17 @@ post_install_actions:
{{ $phpversion := trimPrefix "php:" .platformapp.type }}
{{ if .platformapp.runtime.extensions }}
{{ $phpextensions := without .platformapp.runtime.extensions "blackfire" "pdo_pgsql" "sodium" }}
{{range $extension := $phpextensions }}
{{range $extension := $phpextensions }}
lolautruche marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member Author

@rfay rfay Nov 9, 2022

Choose a reason for hiding this comment

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

Suggested change
{{range $extension := $phpextensions }}
{{range $extension := $phpextensions }}

- php{{$phpversion}}-{{$extension}}{{end}}
{{ if has "sodium" .platformapp.runtime.extensions }}
- php-sodium
{{end}}
{{end}}
{{/* # Add pip only if we have python3 dependencies */}}
{{ if .platformapp.dependencies.python3 }}
- python3-pip
{{ end }}

web_environment:
# TODO: Review which of these matters and which can be dummied up
- "PLATFORM_RELATIONSHIPS=${PLATFORM_RELATIONSHIPS}"
- "PLATFORM_MOUNTS={{ range $key, $value := .platformapp.mounts }}{{ $key }} {{ end }}"
- "PLATFORM_APP_DIR=/var/www/html"
Expand All @@ -244,7 +246,6 @@ post_install_actions:
{{ if .platformapp.variables.env }}
{{ range $key, $value := .platformapp.variables.env }}
- "{{$key}}={{$value}}"{{ end }}{{ end }}
{{ end }}

EOF

Expand Down
4 changes: 4 additions & 0 deletions tests/wordpress-composer.bats
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ teardown() {

run ddev exec -s db 'echo ${DDEV_DATABASE}'
assert_output "mariadb:10.4"
run ddev exec 'echo $PLATFORM_RELATIONSHIPS | base64 -d | jq -r ".database[0].username"'
assert_output "db"
run ddev exec "php --version | awk 'NR==1 { sub(/\.[0-9]+$/, \"\", \$2); print \$2 }'"
assert_output "7.4"
run ddev exec ls wordpress/wp-config.php
assert_output "wordpress/wp-config.php"
ddev describe -j >describe.json
run jq -r .raw.docroot <describe.json
assert_output "wordpress"
Expand Down