]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
deploy: Fix deploy defaults for non-zero flag values (e.g. maxDeletes, invalidateCDN)
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 18 Jun 2023 16:35:11 +0000 (18:35 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sun, 18 Jun 2023 17:38:34 +0000 (19:38 +0200)
This was broken in the config rewrite in Hugo 0.112.0.

The workaround is to be explicit about setting these flag values (even if just using the defaults), e.g.:

```
hugo deploy --invalidateCDN --maxDeletes 256
```

Fixes #11127

commands/deploy.go
deploy/deployConfig.go
testscripts/commands/deploy.txt

index 82127adf4c7c42b430f99cd02e1e55f7c9ce3033..ce1af95469c7d43ad9e2f0e891200da65d64826b 100644 (file)
@@ -63,9 +63,9 @@ documentation.
                        cmd.Flags().Bool("confirm", false, "ask for confirmation before making changes to the target")
                        cmd.Flags().Bool("dryRun", false, "dry run")
                        cmd.Flags().Bool("force", false, "force upload of all files")
-                       cmd.Flags().Bool("invalidateCDN", true, "invalidate the CDN cache listed in the deployment target")
-                       cmd.Flags().Int("maxDeletes", 256, "maximum # of files to delete, or -1 to disable")
-                       cmd.Flags().Int("workers", 10, "number of workers to transfer files. defaults to 10")
+                       cmd.Flags().Bool("invalidateCDN", deploy.DefaultConfig.InvalidateCDN, "invalidate the CDN cache listed in the deployment target")
+                       cmd.Flags().Int("maxDeletes", deploy.DefaultConfig.MaxDeletes, "maximum # of files to delete, or -1 to disable")
+                       cmd.Flags().Int("workers", deploy.DefaultConfig.Workers, "number of workers to transfer files. defaults to 10")
                },
        }
 }
index 3f54651711a8f0c511773856cd2558c775425239..5bbec5ab4db58609ac721a5fd20dcee50bc1eda2 100644 (file)
@@ -127,11 +127,16 @@ func (m *Matcher) Matches(path string) bool {
        return m.re.MatchString(path)
 }
 
+var DefaultConfig = DeployConfig{
+       Workers:       10,
+       InvalidateCDN: true,
+       MaxDeletes:    256,
+}
+
 // DecodeConfig creates a config from a given Hugo configuration.
 func DecodeConfig(cfg config.Provider) (DeployConfig, error) {
-       var (
-               dcfg DeployConfig
-       )
+
+       dcfg := DefaultConfig
 
        if !cfg.IsSet(deploymentConfigKey) {
                return dcfg, nil
index b21bf0b38e7cadfe090f73ee03bfe5888c14499b..0afe1fc44efdbc2623dd2b56f22c5c2e5ae879de 100644 (file)
@@ -3,10 +3,10 @@
 hugo deploy -h
 stdout 'Deploy your site to a Cloud provider\.'
 mkdir mybucket
-hugo deploy --target mydeployment
+hugo deploy --target mydeployment --invalidateCDN=false
 grep 'hello' mybucket/index.html
 replace  public/index.html 'hello' 'changed'
-hugo deploy --target mydeployment --invalidateCDN --dryRun
+hugo deploy --target mydeployment --dryRun
 stdout 'Would upload: index.html'
 stdout 'Would invalidate CloudFront CDN with ID foobar'
 -- hugo.toml --