deploy: Ensure that non-trivial default flag values are passed through.
authorRobert van Gent <rvangent@google.com>
Sat, 4 Jul 2020 17:15:46 +0000 (10:15 -0700)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 4 Jul 2020 19:19:25 +0000 (21:19 +0200)
commands/deploy.go

index ab51c9eb6fa19e213ec2663211c8d2e2ddcd11e1..7133f9a0e686b80e14072eaf42fba1ba88d2ad70 100644 (file)
@@ -25,6 +25,9 @@ var _ cmder = (*deployCmd)(nil)
 // deployCmd supports deploying sites to Cloud providers.
 type deployCmd struct {
        *baseBuilderCmd
+
+       invalidateCDN bool
+       maxDeletes    int
 }
 
 // TODO: In addition to the "deploy" command, consider adding a "--deploy"
@@ -51,6 +54,8 @@ documentation.
 
                RunE: func(cmd *cobra.Command, args []string) error {
                        cfgInit := func(c *commandeer) error {
+                               c.Set("invalidateCDN", cc.invalidateCDN)
+                               c.Set("maxDeletes", cc.maxDeletes)
                                return nil
                        }
                        comm, err := initializeConfig(true, false, &cc.hugoBuilderCommon, cc, cfgInit)
@@ -69,8 +74,8 @@ 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().BoolVar(&cc.invalidateCDN, "invalidateCDN", true, "invalidate the CDN cache listed in the deployment target")
+       cmd.Flags().IntVar(&cc.maxDeletes, "maxDeletes", 256, "maximum # of files to delete, or -1 to disable")
 
        cc.baseBuilderCmd = b.newBuilderBasicCmd(cmd)