Problem/Motivation
The process to configure a site for integration with Fastly can be done programmatically, except for one of the more important steps: uploading the VCLs to fine-tune the Fastly service behavior for Drupal.
The current process requires logging into the site and manually clicking the upload button.
Proposed resolution
Fastly already exposes the VCL Handler class as a module service, and the upload button in the Fastly Settings form appears to invoke its execute() command directly, passing along a form setting flag on whether to activate the version or not.
So we should be able to extend that behavior out to a Drush command with a similar flag, like:
# Upload VCLs but do not activate the new version
drush fastly:upload-vcls
# Upload VCLs and activate the new version
drush fastly:upload-vcls --activate
Remaining tasks
Create a Merge Request with the proposed change.
Issue fork fastly-3620562
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
coolbrewed commentedComment #4
coolbrewed commentedUpdate: I've got the suggested changes created as a Merge Request. Check it out and let me know if anything needs tweaking!
To test:
drush fastly:upload-vcls(ordrush fastly:upload-vcls --activateto immediately activate the new version)And as a heads-up for any folks testing in an environment where the Fastly credentials are not already set:
Currently, the Drush command will "terminate abnormally" with the following error:
Error: Call to a member function addError() on null in Drupal\fastly\VclHandler->execute() (line 495 of /var/www/html/web/modules/contrib/fastly/src/VclHandler.php) #0 /var/www/html/web/modules/contrib/fastly/src/Commands/FastlyCommands.php(137): Drupal\fastly\VclHandler->execute()That error's due to a separate issue about the class's property assignment order (which also has a suggested fix that works great!).