Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deploy defaults for non-zero flag values (e.g. maxDeletes, invalidateCDN) #11129

Merged
merged 1 commit into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
},
}
}
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
Loading