docbrown/lib/tasks/fastly.rake
Alex 7149070bca
[deploy] Create FastlyConfig & refactor params safe list (#7630)
* Fastly refactor

- Create FastlyConfig
- Create FastlyConfig::Base
- Create FastlyConfig::Snippets
- Move safe_params to its own VCL file
- Rescue unauthorized errors in development
- Add FastlyConfig errors

* Move active version to method

* Update naming option --> config

* Refactor InvalidConfigsFormat msg to Error class

* Refactor active version logic

* Fix log_to_datadog call

* Move get_active_version logic back into method

* Add some specs ¯\_(ツ)_/¯

* Update Fastly rake task

* Remove old Fastly way

* Update docs for Fastly

* Move snippets to config/ & remove old config

* Change update_config to upsert_config

* Change error type to SubclassResponsibility

* Refactor get_updated_files with filter_map

* Refactor update

* Cleanup update_config --> upsert_config

* Fix updater specs
2020-05-01 11:23:48 -04:00

19 lines
437 B
Ruby

namespace :fastly do
desc "Update Fastly configs"
task update_configs: :environment do
fastly_credentials = %w[
FASTLY_API_KEY
FASTLY_SERVICE_ID
]
if fastly_credentials.any? { |cred| ApplicationConfig[cred].blank? }
Rails.logger.info(
"Fastly not configured. Please set #{fastly_credentials.join(", ")} in your environment."
)
next
end
FastlyConfig::Update.call
end
end