feat(cli): Implement address flag for boundary targets create/update
This commit adds CLI support for addresses to be attached directly to a Target, for all current types of Target (ssh and tcp). It also clarifies the relevant documentation regarding the autogen of API option functionality.
This commit is contained in:
1 parent
61c90c5623
commit
c82d2efb14
12 files changed
+221
-125
No files matched your search
@@ -482,6 +482,11 @@ func (c *Command) printListTable(items []*targets.Target) string {
|
||||
fmt.Sprintf(" Description: %s", item.Description),
|
||||
)
|
||||
}
|
||||
if item.Address != "" {
|
||||
output = append(output,
|
||||
fmt.Sprintf(" Address: %s", item.Address),
|
||||
)
|
||||
}
|
||||
if len(item.AuthorizedActions) > 0 {
|
||||
output = append(output,
|
||||
" Authorized Actions:",
|
||||
@@ -516,6 +521,9 @@ func printItemTable(item *targets.Target, resp *api.Response) string {
|
||||
if item.Description != "" {
|
||||
nonAttributeMap["Description"] = item.Description
|
||||
}
|
||||
if item.Address != "" {
|
||||
nonAttributeMap["Address"] = item.Address
|
||||
}
|
||||
if item.WorkerFilter != "" {
|
||||
nonAttributeMap["Worker Filter"] = item.WorkerFilter
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ func init() {
|
||||
|
||||
func extraSshActionsFlagsMapFuncImpl() map[string][]string {
|
||||
return map[string][]string{
|
||||
"create": {"default-port", "session-max-seconds", "session-connection-limit", "egress-worker-filter", "ingress-worker-filter"},
|
||||
"update": {"default-port", "session-max-seconds", "session-connection-limit", "worker-filter", "egress-worker-filter", "ingress-worker-filter"},
|
||||
"create": {"address", "default-port", "session-max-seconds", "session-connection-limit", "egress-worker-filter", "ingress-worker-filter"},
|
||||
"update": {"address", "default-port", "session-max-seconds", "session-connection-limit", "worker-filter", "egress-worker-filter", "ingress-worker-filter"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ type extraSshCmdVars struct {
|
||||
flagWorkerFilter string
|
||||
flagEgressWorkerFilter string
|
||||
flagIngressWorkerFilter string
|
||||
flagAddress string
|
||||
}
|
||||
|
||||
func (c *SshCommand) extraSshHelpFunc(helpMap map[string]func() string) string {
|
||||
@@ -66,6 +67,12 @@ func extraSshFlagsFuncImpl(c *SshCommand, set *base.FlagSets, f *base.FlagSet) {
|
||||
|
||||
for _, name := range flagsSshMap[c.Func] {
|
||||
switch name {
|
||||
case "address":
|
||||
fs.StringVar(&base.StringVar{
|
||||
Name: "address",
|
||||
Target: &c.flagAddress,
|
||||
Usage: "Optionally, a valid network address to connect to for this target. Can not be used alongside host sources.",
|
||||
})
|
||||
case "default-port":
|
||||
fs.StringVar(&base.StringVar{
|
||||
Name: "default-port",
|
||||
@@ -188,6 +195,14 @@ func extraSshFlagsHandlingFuncImpl(c *SshCommand, _ *base.FlagSets, opts *[]targ
|
||||
*opts = append(*opts, targets.WithIngressWorkerFilter(c.flagIngressWorkerFilter))
|
||||
}
|
||||
|
||||
switch c.flagAddress {
|
||||
case "":
|
||||
case "null":
|
||||
*opts = append(*opts, targets.DefaultAddress())
|
||||
default:
|
||||
*opts = append(*opts, targets.WithAddress(c.flagAddress))
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ func init() {
|
||||
|
||||
func extraTcpActionsFlagsMapFuncImpl() map[string][]string {
|
||||
return map[string][]string{
|
||||
"create": {"default-port", "session-max-seconds", "session-connection-limit", "egress-worker-filter", "ingress-worker-filter"},
|
||||
"update": {"default-port", "session-max-seconds", "session-connection-limit", "worker-filter", "egress-worker-filter", "ingress-worker-filter"},
|
||||
"create": {"address", "default-port", "session-max-seconds", "session-connection-limit", "egress-worker-filter", "ingress-worker-filter"},
|
||||
"update": {"address", "default-port", "session-max-seconds", "session-connection-limit", "worker-filter", "egress-worker-filter", "ingress-worker-filter"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ type extraTcpCmdVars struct {
|
||||
flagWorkerFilter string
|
||||
flagEgressWorkerFilter string
|
||||
flagIngressWorkerFilter string
|
||||
flagAddress string
|
||||
}
|
||||
|
||||
func (c *TcpCommand) extraTcpHelpFunc(helpMap map[string]func() string) string {
|
||||
@@ -65,6 +66,12 @@ func extraTcpFlagsFuncImpl(c *TcpCommand, set *base.FlagSets, f *base.FlagSet) {
|
||||
|
||||
for _, name := range flagsTcpMap[c.Func] {
|
||||
switch name {
|
||||
case "address":
|
||||
fs.StringVar(&base.StringVar{
|
||||
Name: "address",
|
||||
Target: &c.flagAddress,
|
||||
Usage: "Optionally, a valid network address to connect to for this target. Can not be used alongside host sources.",
|
||||
})
|
||||
case "default-port":
|
||||
fs.StringVar(&base.StringVar{
|
||||
Name: "default-port",
|
||||
@@ -187,5 +194,13 @@ func extraTcpFlagsHandlingFuncImpl(c *TcpCommand, _ *base.FlagSets, opts *[]targ
|
||||
*opts = append(*opts, targets.WithIngressWorkerFilter(c.flagIngressWorkerFilter))
|
||||
}
|
||||
|
||||
switch c.flagAddress {
|
||||
case "":
|
||||
case "null":
|
||||
*opts = append(*opts, targets.DefaultAddress())
|
||||
default:
|
||||
*opts = append(*opts, targets.WithAddress(c.flagAddress))
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
Reference in new issue
Block a user