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

fix: Use explicit paths in install.yaml instead of assuming pwd #126

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
30 changes: 16 additions & 14 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pre_install_actions:
read platform_project
echo "platform_project = '${platform_project}'"
# Put the platform_project in to the project's web environment
cd ${DDEV_APPROOT}
Copy link
Member

Choose a reason for hiding this comment

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

I thought it would not make impact on ddev config. So more add-ons will be affected.

Given this, maybe changing the pre_install_actions context to .ddev is too disruptive?

(There is one more ddev config inside this yaml, that call ddev config, that you didn't change.)

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cd ${DDEV_APPROOT}

ddev config --web-environment-add PLATFORM_PROJECT=${platform_project}
echo "PLATFORM_PROJECT set to ${platform_project}"
fi
Expand All @@ -83,6 +84,7 @@ pre_install_actions:
#ddev-description:Setting PLATFORM_APPLICATION_NAME
if !( {{ contains "PLATFORM_APPLICATION_NAME" (list .DdevProjectConfig.web_environment | toString) }} ); then
# Put the platform_project in to the project's web environment
cd ${DDEV_APPROOT}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cd ${DDEV_APPROOT}

ddev config --web-environment-add PLATFORM_APPLICATION_NAME={{ .platformapp.name }}
fi

Expand All @@ -108,7 +110,7 @@ post_install_actions:
- |
#ddev-nodisplay
#ddev-description:Support composer and python3 dependencies
cat <<-ENDDOCKERFILE >> web-build/Dockerfile.platformsh
cat <<-ENDDOCKERFILE >> ${DDEV_APPROOT}/.ddev/web-build/Dockerfile.platformsh
{{ if .platformapp.dependencies.php }}{{ range $pkg, $version := .platformapp.dependencies.php }}{{ if ne $pkg "composer/composer" }}
ENV COMPOSER_HOME=/usr/local/composer
RUN echo "export PATH=\${PATH}:\${COMPOSER_HOME}/vendor/bin" >/etc/bashrc/composerpath.bashrc
Expand All @@ -133,17 +135,17 @@ post_install_actions:
# The double-run here is awkward, but I didn't figure out how to do it with two '-e'
docker run -i --rm ddev/ddev-utilities perl -p -e "s!APP_URL=.*!APP_URL=${DDEV_PRIMARY_URL}!g" <.env.example | docker run -i --rm ddev/ddev-utilities perl -p -e 's!DB_(HOST|DATABASE|USERNAME|PASSWORD)=(.*)!DB_\1=db!g' >.env
;;
drupal9)
mkdir -p .drush
drupal*)
mkdir -p ${DDEV_APPROOT}/.drush
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mkdir -p ${DDEV_APPROOT}/.drush
mkdir -p ${DDEV_APPROOT}/.ddev/.drush

;;
esac

- |
#ddev-nodisplay
#ddev-description: Install .environment file into web-entrypoint.d if needed
if [ -f ../.environment ]; then
mkdir -p web-entrypoint.d
cp ../.environment web-entrypoint.d/environment.sh
if [ -f ${DDEV_APPROOT}/.environment ]; then
mkdir -p ${DDEV_APPROOT}/.ddev/web-entrypoint.d
cp ${DDEV_APPROOT}/.environment ${DDEV_APPROOT}/.ddev/web-entrypoint.d/environment.sh
fi

# Write a config.platformsh.yaml based on calculated values, php version, database, docroot
Expand Down Expand Up @@ -177,7 +179,7 @@ post_install_actions:
{{ $id = $v.id }}
{{ end }}

r=$(./platformsh/generate_route.sh "${DDEV_PRIMARY_URL}/" '{{ $id }}' '{{ $v.production_url }}' '{{ $v.upstream }}' '{{ $v.type }}' '{{ $v.original_url }}' | ${BASE64_ENCODE})
r=$(${DDEV_APPROOT}/.ddev/platformsh/generate_route.sh "${DDEV_PRIMARY_URL}/" '{{ $id }}' '{{ $v.production_url }}' '{{ $v.upstream }}' '{{ $v.type }}' '{{ $v.original_url }}' | ${BASE64_ENCODE})
#echo "r=$r"
routes+=(${r})
{{ end }}
Expand Down Expand Up @@ -219,13 +221,13 @@ post_install_actions:
printf "\n\nThere is an existing database in this project that doesn\'t match the upstream database type.\n Please use 'ddev delete' to delete the existing database and retry, or try 'ddev debug migrate-database {{ $dbtype }}' to migrate the database.\n" >&2
false
fi
# echo ./platformsh/generate_db_relationship.sh '{{ $relationship_name }}' '{{ $dbtype }}' '{{ $relationship_name }}'
relationships+=($(./platformsh/generate_db_relationship.sh '{{ $relationship_name }}' '{{ $dbtype }}' '{{ $relationship_name }}' | ${BASE64_ENCODE}))
# echo ${DDEV_APPROOT}/.ddev/platformsh/generate_db_relationship.sh '{{ $relationship_name }}' '{{ $dbtype }}' '{{ $relationship_name }}'
relationships+=($(${DDEV_APPROOT}/.ddev/platformsh/generate_db_relationship.sh '{{ $relationship_name }}' '{{ $dbtype }}' '{{ $relationship_name }}' | ${BASE64_ENCODE}))
#printf "relationships length after db=${#relationships[@]}\nrelationships value=$(echo $relationships | ${BASE64_DECODE})"
{{ end }}
{{ else if hasKey $supported_services $service_def.type }}
{{/* Other services */}}
relationships+=($(./platformsh/generate_{{ $service_def.type }}_relationship.sh '{{ $relationship_name }}' | ${BASE64_ENCODE}))
relationships+=($(${DDEV_APPROOT}/.ddev/platformsh/generate_{{ $service_def.type }}_relationship.sh '{{ $relationship_name }}' | ${BASE64_ENCODE}))
{{ $service_addon := get $supported_services $service_def.type }}
{{ if $service_addon }}
echo "Running 'ddev get {{ $service_addon }}'"
Expand All @@ -240,13 +242,13 @@ post_install_actions:

{{ $phpversion := trimPrefix "php:" .platformapp.type }}

if [ -f config.platformsh.yaml ] && ! grep '#ddev-generated' config.platformsh.yaml; then
if [ -f ${DDEV_APPROOT}/.ddev/config.platformsh.yaml ] && ! grep '#ddev-generated' ${DDEV_APPROOT}/.ddev/config.platformsh.yaml; then
echo "Existing config.platformsh.yaml does not have #ddev-generated, so can't be updated"
exit 2
fi
rm -f .config.platformsh.yaml
rm -f ${DDEV_APPROOT}/.ddev/config.platformsh.yaml

cat <<-EOF >config.platformsh.yaml
cat <<-EOF >${DDEV_APPROOT}/.ddev/config.platformsh.yaml
# #ddev-generated
# Generated configuration based on platform.sh project configuration
disable_settings_management: true
Expand Down Expand Up @@ -290,7 +292,7 @@ post_install_actions:

# Because "ENDOFHOOKS" is quoted here, no variable expansion occurs
# so everything is left alone.
cat <<-"ENDOFHOOKS" >>config.platformsh.yaml
cat <<-"ENDOFHOOKS" >>${DDEV_APPROOT}/.ddev/config.platformsh.yaml

hooks:
post-start:
Expand Down
2 changes: 1 addition & 1 deletion tests/per_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ per_test_setup() {
# If the template happens to have a .ddev directory, remove as it can break things
rm -rf .ddev
# Start with bogus settings so we know we got the right stuff when testing
ddev config --project-name=${PROJNAME} --php-version=5.6 --database=mariadb:10.1 --docroot=x --create-docroot --project-type=php --web-environment-add=PLATFORMSH_CLI_TOKEN=notokenrightnow,PLATFORM_PROJECT=notyet,PLATFORM_ENVIRONMENT=notyet
ddev config --project-name=${PROJNAME} --php-version=5.6 --database=mariadb:10.1 --docroot=x --project-type=php --web-environment-add=PLATFORMSH_CLI_TOKEN=notokenrightnow,PLATFORM_PROJECT=notyet,PLATFORM_ENVIRONMENT=notyet
echo "# doing ddev get $source with template ${template} PROJNAME=${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
ddev get ${PROJECT_SOURCE}
echo "# doing ddev restart with template ${template} PROJNAME=${PROJNAME} in ${TESTDIR} ($(pwd))" >&3
Expand Down