aboutsummaryrefslogtreecommitdiffhomepage
path: root/deploy/deploy.go
diff options
context:
space:
mode:
authorJosé Moreira <[email protected]>2020-10-27 20:41:15 +0100
committerBjørn Erik Pedersen <[email protected]>2020-10-28 11:19:40 +0100
commit56a343507ca28254edb891bc1c21b6c8ca017982 (patch)
treecf178d1e42013a0c850c7c7f734e5bac8b2be8a3 /deploy/deploy.go
parentd48a98c477a818d28008d9771050d2681e63e880 (diff)
downloadhugo-56a343507ca28254edb891bc1c21b6c8ca017982.tar.gz
hugo-56a343507ca28254edb891bc1c21b6c8ca017982.zip
deploy: Do not call CDN service invalidation when executing a dry run deployment
Currently, if cache invalidation is enabled when running `hugo deploy --dryRun` with , the deployer does not take the dry run flag into consideration and triggers CloudFront/GoogleCloudCDN cache invalidation if any of those services are configured. This change will instead print a feedback message if a dry run is in effect and quiet mode is not enabled. Fixes #7884
Diffstat (limited to 'deploy/deploy.go')
-rw-r--r--deploy/deploy.go28
1 files changed, 20 insertions, 8 deletions
diff --git a/deploy/deploy.go b/deploy/deploy.go
index aac0bf354..0c793bca0 100644
--- a/deploy/deploy.go
+++ b/deploy/deploy.go
@@ -262,17 +262,29 @@ func (d *Deployer) Deploy(ctx context.Context) error {
if d.invalidateCDN {
if d.target.CloudFrontDistributionID != "" {
- jww.FEEDBACK.Println("Invalidating CloudFront CDN...")
- if err := InvalidateCloudFront(ctx, d.target.CloudFrontDistributionID); err != nil {
- jww.FEEDBACK.Printf("Failed to invalidate CloudFront CDN: %v\n", err)
- return err
+ if d.dryRun {
+ if !d.quiet {
+ jww.FEEDBACK.Printf("[DRY RUN] Would invalidate CloudFront CDN with ID %s\n", d.target.CloudFrontDistributionID)
+ }
+ } else {
+ jww.FEEDBACK.Println("Invalidating CloudFront CDN...")
+ if err := InvalidateCloudFront(ctx, d.target.CloudFrontDistributionID); err != nil {
+ jww.FEEDBACK.Printf("Failed to invalidate CloudFront CDN: %v\n", err)
+ return err
+ }
}
}
if d.target.GoogleCloudCDNOrigin != "" {
- jww.FEEDBACK.Println("Invalidating Google Cloud CDN...")
- if err := InvalidateGoogleCloudCDN(ctx, d.target.GoogleCloudCDNOrigin); err != nil {
- jww.FEEDBACK.Printf("Failed to invalidate Google Cloud CDN: %v\n", err)
- return err
+ if d.dryRun {
+ if !d.quiet {
+ jww.FEEDBACK.Printf("[DRY RUN] Would invalidate Google Cloud CDN with origin %s\n", d.target.GoogleCloudCDNOrigin)
+ }
+ } else {
+ jww.FEEDBACK.Println("Invalidating Google Cloud CDN...")
+ if err := InvalidateGoogleCloudCDN(ctx, d.target.GoogleCloudCDNOrigin); err != nil {
+ jww.FEEDBACK.Printf("Failed to invalidate Google Cloud CDN: %v\n", err)
+ return err
+ }
}
}
jww.FEEDBACK.Println("Success!")