From 6559d1f59490548495c70672795bd9805c30aecd Mon Sep 17 00:00:00 2001 From: William Petit Date: Sat, 24 Jun 2023 12:27:29 -0600 Subject: [PATCH] fix(command,proxy): allow from flag to be optional --- internal/command/admin/proxy/create.go | 2 +- internal/command/admin/proxy/flag/flag.go | 4 ++-- internal/command/admin/proxy/update.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/command/admin/proxy/create.go b/internal/command/admin/proxy/create.go index 90f8bd6..0918b8d 100644 --- a/internal/command/admin/proxy/create.go +++ b/internal/command/admin/proxy/create.go @@ -19,7 +19,7 @@ func CreateCommand() *cli.Command { Name: "create", Usage: "Create proxy", Flags: proxyFlag.WithProxyFlags( - flag.ProxyTo(), + flag.ProxyTo(true), flag.ProxyFrom(), ), Action: func(ctx *cli.Context) error { diff --git a/internal/command/admin/proxy/flag/flag.go b/internal/command/admin/proxy/flag/flag.go index 932d81e..ccbf5a8 100644 --- a/internal/command/admin/proxy/flag/flag.go +++ b/internal/command/admin/proxy/flag/flag.go @@ -30,12 +30,12 @@ func ProxyName() cli.Flag { const KeyProxyTo = "proxy-to" -func ProxyTo() cli.Flag { +func ProxyTo(required bool) cli.Flag { return &cli.StringFlag{ Name: KeyProxyTo, Usage: "Set `PROXY_TO` as proxy's destination url", Value: "", - Required: true, + Required: required, } } diff --git a/internal/command/admin/proxy/update.go b/internal/command/admin/proxy/update.go index 4980bce..2d60888 100644 --- a/internal/command/admin/proxy/update.go +++ b/internal/command/admin/proxy/update.go @@ -19,7 +19,7 @@ func UpdateCommand() *cli.Command { Name: "update", Usage: "Update proxy", Flags: proxyFlag.WithProxyFlags( - flag.ProxyTo(), + flag.ProxyTo(false), flag.ProxyFrom(), flag.ProxyEnabled(), flag.ProxyWeight(),