summaryrefslogtreecommitdiff
path: root/cmd/commands.go
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2021-11-08 13:35:46 -0500
committerGitHub <noreply@github.com>2021-11-08 11:35:46 -0700
commit749e55c738bf702b5f1265f85018c450a7b4e3b4 (patch)
treeb2e93a4b87a050e6fdfce0bbea99bda4b67d33f6 /cmd/commands.go
parent24fda7514ddeebf19a1e872343b45ec523eefcba (diff)
caddycmd: Add `--keep-backup` to upgrade commands (#4387)
* caddycmd: Add `--skip-cleanup` to upgrade commands This is a partial fix for https://github.com/caddyserver/caddy/issues/4057, making it possible to retain the old build of Caddy, in case something went wrong. * caddycmd: Fix duplicate error message The error message "download succeeded, but unable to execute" was repeated, because it was both in the `listModules`/`showVersion` functions and in the calling `upgradeBuild` function. Oversight when this was refactored. * caddycmd: Implement fix for performing cleanup on Windows Without this, the cleanup operation would fail with an error message like this: upgrade: download succeeded, but unable to clean up backup binary: remove C:\caddy\caddy.exe.tmp: Access is denied. * caddycmd: Rename to `--keep-backup`, simplify build constraints
Diffstat (limited to 'cmd/commands.go')
-rw-r--r--cmd/commands.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmd/commands.go b/cmd/commands.go
index f562430..1e2c40d 100644
--- a/cmd/commands.go
+++ b/cmd/commands.go
@@ -296,6 +296,11 @@ is always printed to stdout.`,
Long: `
Downloads an updated Caddy binary with the same modules/plugins at the
latest versions. EXPERIMENTAL: May be changed or removed.`,
+ Flags: func() *flag.FlagSet {
+ fs := flag.NewFlagSet("upgrade", flag.ExitOnError)
+ fs.Bool("keep-backup", false, "Keep the backed up binary, instead of deleting it")
+ return fs
+ }(),
})
RegisterCommand(Command{
@@ -308,6 +313,11 @@ Downloads an updated Caddy binary with the specified packages (module/plugin)
added. Retains existing packages. Returns an error if the any of packages are
already included. EXPERIMENTAL: May be changed or removed.
`,
+ Flags: func() *flag.FlagSet {
+ fs := flag.NewFlagSet("add-package", flag.ExitOnError)
+ fs.Bool("keep-backup", false, "Keep the backed up binary, instead of deleting it")
+ return fs
+ }(),
})
RegisterCommand(Command{
@@ -320,6 +330,11 @@ Downloads an updated Caddy binaries without the specified packages (module/plugi
Returns an error if any of the packages are not included.
EXPERIMENTAL: May be changed or removed.
`,
+ Flags: func() *flag.FlagSet {
+ fs := flag.NewFlagSet("remove-package", flag.ExitOnError)
+ fs.Bool("keep-backup", false, "Keep the backed up binary, instead of deleting it")
+ return fs
+ }(),
})
}