Skip to content

Commit

Permalink
fix: Some UPSUN environment variables are now PLATFORM_ environment v…
Browse files Browse the repository at this point in the history
…ariables (ddev#6620) [skip ci]
  • Loading branch information
rfay authored Oct 17, 2024
1 parent 8b508fc commit f3d01a8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
8 changes: 4 additions & 4 deletions docs/content/users/providers/upsun.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ You need to obtain and configure an API token first. This only needs to be done
## Upsun Per-Project Configuration

1. Check out the Upsun site and configure it with [`ddev config`](../usage/commands.md#config). You’ll want to use [`ddev start`](../usage/commands.md#start) and make sure the basic functionality is working.
2. Add `UPSUN_PROJECT` and `UPSUN_ENVIRONMENT` variables to your project.
2. Add `PLATFORM_PROJECT` and `PLATFORM_ENVIRONMENT` variables to your project.

* Either in `.ddev/config.yaml` or a `.ddev/config.*.yaml` file:

```yaml
web_environment:
- UPSUN_PROJECT=nf4amudfn23biyourproject
- UPSUN_ENVIRONMENT=main
- PLATFORM_PROJECT=nf4amudfn23biyourproject
- PLATFORM_ENVIRONMENT=main
```

* Or with a command from your terminal:

```bash
ddev config --web-environment-add="UPSUN_PROJECT=nf4amudfn23bi,UPSUN_ENVIRONMENT=main"
ddev config --web-environment-add="PLATFORM_PROJECT=nf4amudfn23bi,PLATFORM_ENVIRONMENT=main"
```

3. Run [`ddev restart`](../usage/commands.md#restart).
Expand Down
35 changes: 20 additions & 15 deletions pkg/ddevapp/dotddev_assets/providers/upsun.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# ```
# You can also do this with `ddev config global --web-environment-add="UPSUN_CLI_TOKEN=abcdeyourtoken"`.
#
# 3. Add UPSUN_PROJECT and UPSUN_ENVIRONMENT variables to your project `.ddev/config.yaml` or a `.ddev/config.upsun.yaml`
# 3. Add PLATFORM_PROJECT and PLATFORM_ENVIRONMENT variables to your project `.ddev/config.yaml` or a `.ddev/config.upsun.yaml`
# ```yaml
# web_environment:
# - UPSUN_PROJECT=nf4amudfn23biyourproject
# - UPSUN_ENVIRONMENT=main
# - PLATFORM_PROJECT=nf4amudfn23biyourproject
# - PLATFORM_ENVIRONMENT=main
# ```
# You can also do this with `ddev config --web-environment-add="UPSUN_PROJECT=nf4amudfn23biyourproject,UPSUN_ENVIRONMENT=main"`.
# You can also do this with `ddev config --web-environment-add="PLATFORM_PROJECT=nf4amudfn23biyourproject,PLATFORM_ENVIRONMENT=main"`.
#
# 4. `ddev restart`
# 5. Run `ddev pull upsun`. After you agree to the prompt, the current upstream database and files will be downloaded.
Expand All @@ -33,44 +33,49 @@
auth_command:
command: |
set -eu -o pipefail
export PLATFORM_PROJECT="${PLATFORM_PROJECT:-${UPSUN_PROJECT:-}}"
export PLATFORM_ENVIRONMENT="${PLATFORM_ENVIRONMENT:-${UPSUN_ENVIRONMENT:-}}"
if [ -z "${UPSUN_CLI_TOKEN:-}" ]; then echo "Please make sure you have set UPSUN_CLI_TOKEN." && exit 1; fi
if [ -z "${UPSUN_PROJECT:-}" ]; then echo "Please make sure you have set UPSUN_PROJECT." && exit 1; fi
if [ -z "${UPSUN_ENVIRONMENT:-}" ]; then echo "Please make sure you have set UPSUN_ENVIRONMENT." && exit 1; fi
if [ -z "${PLATFORM_PROJECT:-}" ]; then echo "Please make sure you have set PLATFORM_PROJECT." && exit 1; fi
if [ -z "${PLATFORM_ENVIRONMENT:-}" ]; then echo "Please make sure you have set PLATFORM_ENVIRONMENT." && exit 1; fi
db_pull_command:
command: |
# set -x # You can enable bash debugging output by uncommenting
set -eu -o pipefail
export PLATFORM_PROJECT="${PLATFORM_PROJECT:-${UPSUN_PROJECT:-}}"
export PLATFORM_ENVIRONMENT="${PLATFORM_ENVIRONMENT:-${UPSUN_ENVIRONMENT:-}}"
export UPSUN_CLI_NO_INTERACTION=1
ls /var/www/html/.ddev >/dev/null # This just refreshes stale NFS if possible
upsun db:dump --yes --gzip --file=/var/www/html/.ddev/.downloads/db.sql.gz --project="${UPSUN_PROJECT}" --environment="${UPSUN_ENVIRONMENT}"
upsun db:dump --yes --gzip --file=/var/www/html/.ddev/.downloads/db.sql.gz --project="${PLATFORM_PROJECT}" --environment="${PLATFORM_ENVIRONMENT}"
files_import_command:
command: |
# set -x # You can enable bash debugging output by uncommenting
set -eu -o pipefail
export PLATFORM_PROJECT="${PLATFORM_PROJECT:-${UPSUN_PROJECT:-}}"
export PLATFORM_ENVIRONMENT="${PLATFORM_ENVIRONMENT:-${UPSUN_ENVIRONMENT:-}}"
export UPSUN_CLI_NO_INTERACTION=1
# Use $UPSUN_MOUNTS if it exists to get list of mounts to download, otherwise just web/sites/default/files (drupal)
declare -a mounts=(${UPSUN_MOUNTS:-/web/sites/default/files})
upsun mount:download --all --yes --quiet --project="${UPSUN_PROJECT}" --environment="${UPSUN_ENVIRONMENT}" --target=/var/www/html
upsun mount:download --all --yes --quiet --project="${PLATFORM_PROJECT}" --environment="${PLATFORM_ENVIRONMENT}" --target=/var/www/html
# push is a dangerous command. If not absolutely needed it's better to delete these lines.
db_push_command:
command: |
# set -x # You can enable bash debugging output by uncommenting
set -eu -o pipefail
export PLATFORM_PROJECT="${PLATFORM_PROJECT:-${UPSUN_PROJECT:-}}"
export PLATFORM_ENVIRONMENT="${PLATFORM_ENVIRONMENT:-${UPSUN_ENVIRONMENT:-}}"
export UPSUN_CLI_NO_INTERACTION=1
ls /var/www/html/.ddev >/dev/null # This just refreshes stale NFS if possible
pushd /var/www/html/.ddev/.downloads >/dev/null
gzip -dc db.sql.gz | upsun db:sql --project="${UPSUN_PROJECT}" --environment="${UPSUN_ENVIRONMENT}"
gzip -dc db.sql.gz | upsun db:sql --project="${PLATFORM_PROJECT}" --environment="${PLATFORM_ENVIRONMENT}"
# push is a dangerous command. If not absolutely needed it's better to delete these lines.
# TODO: This is a naive, Drupal-centric push, which needs adjustment for the mount to be pushed.
files_push_command:
command: |
# set -x # You can enable bash debugging output by uncommenting
set -eu -o pipefail
export PLATFORM_PROJECT="${PLATFORM_PROJECT:-${UPSUN_PROJECT:-}}"
export PLATFORM_ENVIRONMENT="${PLATFORM_ENVIRONMENT:-${UPSUN_ENVIRONMENT:-}}"
export UPSUN_CLI_NO_INTERACTION=1
ls "${DDEV_FILES_DIR}" >/dev/null # This just refreshes stale NFS if possible
upsun mount:upload --yes --quiet --project="${UPSUN_PROJECT}" --environment="${UPSUN_ENVIRONMENT}" --source="${DDEV_FILES_DIR}" --mount=web/sites/default/files
upsun mount:upload --yes --quiet --project="${PLATFORM_PROJECT}" --environment="${PLATFORM_ENVIRONMENT}" --source="${DDEV_FILES_DIR}" --mount=web/sites/default/files
8 changes: 4 additions & 4 deletions pkg/ddevapp/providerUpsun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func TestUpsunPull(t *testing.T) {
provider, err := app.GetProvider("upsun")
require.NoError(t, err)

provider.EnvironmentVariables["UPSUN_PROJECT"] = upsunTestSiteID
provider.EnvironmentVariables["UPSUN_ENVIRONMENT"] = upsunPullTestSiteEnvironment
provider.EnvironmentVariables["PLATFORM_PROJECT"] = upsunTestSiteID
provider.EnvironmentVariables["PLATFORM_ENVIRONMENT"] = upsunPullTestSiteEnvironment
provider.EnvironmentVariables["UPSUN_CLI_TOKEN"] = token

err = app.Start()
Expand Down Expand Up @@ -148,8 +148,8 @@ func TestUpsunPush(t *testing.T) {
provider, err := app.GetProvider("upsun")
require.NoError(t, err)

provider.EnvironmentVariables["UPSUN_PROJECT"] = upsunTestSiteID
provider.EnvironmentVariables["UPSUN_ENVIRONMENT"] = upsunPushTestSiteEnvironment
provider.EnvironmentVariables["PLATFORM_PROJECT"] = upsunTestSiteID
provider.EnvironmentVariables["PLATFORM_ENVIRONMENT"] = upsunPushTestSiteEnvironment
provider.EnvironmentVariables["UPSUN_CLI_TOKEN"] = token

err = app.Start()
Expand Down

0 comments on commit f3d01a8

Please sign in to comment.