Skip to content

Commit

Permalink
deploy: Fix deploy defaults for non-zero flag values (e.g. maxDeletes…
Browse files Browse the repository at this point in the history
…, invalidateCDN)

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
  • Loading branch information
bep committed Jun 18, 2023
1 parent 8a04d47 commit a577d4e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 2 additions & 0 deletions commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ documentation.
return deployer.Deploy(ctx)
},
withc: func(cmd *cobra.Command, r *rootCommand) {
// Note that the default values for the non-zero values are set in deploy/deployConfig.go.
// The flag values will only be used if set by the user.
cmd.Flags().String("target", "", "target deployment from deployments section in config file; defaults to the first one")
cmd.Flags().Bool("confirm", false, "ask for confirmation before making changes to the target")
cmd.Flags().Bool("dryRun", false, "dry run")
Expand Down
11 changes: 8 additions & 3 deletions deploy/deployConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions testscripts/commands/deploy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
Expand Down

0 comments on commit a577d4e

Please sign in to comment.