Skip to content

feat: update Pantheon provider to use environment variables, fixes #4760 - #7475

Merged
rfay merged 6 commits into
mainfrom
20250722_rfay_pantheon_update
Jul 23, 2025
Merged

rfay merged 6 commits into
mainfrom
20250722_rfay_pantheon_update

Conversation

@rfay

@rfay rfay commented Jul 22, 2025 •

Copy link
Copy Markdown
Member

The Issue

The Pantheon provider integration required users to manually edit provider configuration files, which was inconvenient and inconsistent with other more recent providers like Acquia, Lagoon, Platform.sh, and Upsun that use environment variables.

How This PR Solves The Issue

This PR updates the Pantheon provider to use environment variables instead of requiring file editing:

  • Provider Configuration: Renamed pantheon.yaml.example to pantheon.yaml and removed hardcoded environment_variables: project: yourproject.dev section
  • Environment Variable Validation: Added validation in auth_command for required PANTHEON_SITE and PANTHEON_ENVIRONMENT variables
  • Command Updates: Updated all command references from ${project} to ${PANTHEON_SITE}.${PANTHEON_ENVIRONMENT}
  • Test Updates: Modified TestPantheonPull and TestPantheonPush to use environment variable approach instead of file editing
  • Documentation: Updated step 8 in docs/content/users/providers/pantheon.md with new configuration method

Configuration Method Change:

Before (required editing provider file):

environment_variables:
  project: yourproject.dev

After (set in project config):

web_environment:
    - PANTHEON_SITE=yourproject
    - PANTHEON_ENVIRONMENT=dev

Manual Testing Instructions

Review https://ddev--7475.org.readthedocs.build/en/7475/users/providers/pantheon/

  1. Build ddev: make
  2. Set up test project with Pantheon credentials in global config:
    ddev config global --web-environment-add="TERMINUS_MACHINE_TOKEN=your_token"
  3. Create project with Pantheon environment variables:
    web_environment:
        - PANTHEON_SITE=your_site
        - PANTHEON_ENVIRONMENT=dev
  4. Test pull: ddev pull pantheon - should download database and files
  5. Test push: ddev push pantheon - should upload database and files (ensure SSH key configured)

Automated Testing Overview

  • TestPantheonPull: Updated to use environment variable configuration, passes
  • TestPantheonPush: Updated to use environment variable configuration, passes
  • Manual Testing: Both pull and push operations verified working with real Pantheon site (Note that you have to make a backup on pantheon before pull will recognize changes done with a push. This seems awkward and there should be a better way to do this instead of relying on backups.)

Tests now configure environment variables programmatically instead of editing provider files, making them more reliable and consistent with other provider tests.

Release/Deployment Notes

This is a breaking change for users currently using the Pantheon provider if their configured pantheon.yaml has #ddev-generated in it (it shouldn't, but I'll bet lots of people do.)

  • Users will need to migrate from editing pantheon.yaml.example to setting environment variables in their project configuration
  • The provider file is now named pantheon.yaml (not .example) (it can be edited, but if edited, it needs to have the #ddev-generated line removed)
  • Documentation has been updated to guide users through the new configuration method
  • Existing installations will need to update their configuration when upgrading by removing the existing pantheon.yaml file

TODO:

🤖 Generated with Claude Code

rfay and others added 3 commits July 22, 2025 10:02


This modernizes the Pantheon provider integration to match the pattern
used by other converted providers (Acquia, Lagoon, Platform.sh, Upsun).

Changes made:
- Renamed pantheon.yaml.example to pantheon.yaml to match other providers
- Replaced hardcoded environment_variables.project with PANTHEON_SITE and PANTHEON_ENVIRONMENT
- Updated auth_command to validate required environment variables
- Changed all command references from ${project} to ${PANTHEON_SITE}.${PANTHEON_ENVIRONMENT}
- Renamed files_pull_command to files_import_command for consistency
- Added descriptive output showing which site/environment is being used
- Updated provider documentation comments with new configuration approach
- Modified tests to use app.WebEnvironment instead of file replacement
- Removed old project string replacement logic from tests
- Added support for --environment flag usage for temporary overrides

The provider now requires users to set:
- TERMINUS_MACHINE_TOKEN (global or per-project)
- PANTHEON_SITE (project-specific)
- PANTHEON_ENVIRONMENT (project-specific)

This eliminates the need for users to edit provider files directly,
following the modern pattern established by other provider integrations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Update step 8 in the Pantheon quickstart guide to reflect the new
environment variable approach instead of editing provider files directly.

Changes:
- Replace references to pantheon.yaml.example with pantheon.yaml
- Remove instructions for editing environment_variables.project
- Add instructions for setting PANTHEON_SITE and PANTHEON_ENVIRONMENT
- Include YAML configuration example
- Add ddev config --web-environment-add command example
- Document temporary --environment flag usage option
- Maintain existing site ID explanation and formatting

This completes the modernization of the Pantheon provider to match
the pattern used by other converted providers.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…on provider

The initial change incorrectly renamed files_pull_command to files_import_command,
which caused files to not be imported during `ddev pull pantheon` operations.

files_pull_command: Downloads files to .ddev/.downloads/files (required)
files_import_command: Optional command for custom import logic

The Pantheon provider should use files_pull_command to download and extract
files to the standard location where DDEV will automatically import them.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@rfay
rfay requested review from a team as code owners July 22, 2025 20:05
@rfay
rfay marked this pull request as draft July 22, 2025 20:06
@github-actions

github-actions Bot commented Jul 22, 2025 •

Copy link
Copy Markdown

@rfay

rfay commented Jul 23, 2025

Copy link
Copy Markdown
Member Author

I think I have fixed the Pantheon-pull test target with a Drupal 11 site. I'll make sure it works here, I'm hoping it can also work with existing code before this goes in, not sure.

@rfay
rfay marked this pull request as ready for review July 23, 2025 15:41
@rfay
rfay requested a review from stasadev July 23, 2025 15:45
Comment thread pkg/ddevapp/providerPantheon_test.go Outdated
Comment on lines 26 to 27
const pantheonPullTestSite = "ddev-test-site-do-not-delete.dev"
const pantheonPushTestSite = "ddev-pantheon-push.dev"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's split these in site and environment separately.

At first, it was unclear to me what PANTHEON_ENVIRONMENT is.

@stasadev stasadev Jul 23, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I also noticed that you can run this successfully:

ddev pull pantheon --environment=PANTHEON_SITE=ddev-test-site-do-not-delete.dev,PANTHEON_ENVIRONMENT=junk

But it's not our fault that it doesn't check for exact match. Pantheon thinks that these two are the same:

  • ddev-test-site-do-not-delete.dev
  • ddev-test-site-do-not-delete.dev.junk

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Split those as you suggested. Good idea.

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants