-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,19 @@ func (c *Completion) FirewallListCompletion(cmd *cobra.Command, args []string, t | |
} | ||
return names, cobra.ShellCompDirectiveNoFileComp | ||
} | ||
|
||
func (c *Completion) FirewallEgressCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
egressrules := []string{ | ||
"[email protected]/0@443@\"allow outgoing https\"\tdefault outgoing https", | ||
"[email protected]/0@53@\"allow outgoing dns via tcp\"\tdefault outgoing dns via tcp", | ||
"[email protected]/0@53#123@\"allow outgoing dns and ntp via udp\"\tdefault outgoing dns and ntp via udp", | ||
} | ||
return egressrules, cobra.ShellCompDirectiveNoFileComp | ||
} | ||
|
||
func (c *Completion) FirewallIngressCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
ingressrules := []string{ | ||
"[email protected]/0@22@\"allow incoming ssh\"\tallow incoming ssh", | ||
} | ||
return ingressrules, cobra.ShellCompDirectiveNoFileComp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,8 +47,10 @@ func newFirewallCmd(c *config) *cobra.Command { | |
CreateCmdMutateFn: func(cmd *cobra.Command) { | ||
c.addMachineCreateFlags(cmd, "firewall") | ||
cmd.Aliases = []string{"allocate"} | ||
cmd.Flags().StringSlice("egress", nil, "egress firewall rule to deploy on creation") | ||
cmd.Flags().StringSlice("ingress", nil, "ingress firewall rule to deploy on creation") | ||
cmd.Flags().StringSlice("egress", nil, "egress firewall rule to deploy on creation format: tcp|udp@cidr#cidr@port#port@comment") | ||
cmd.Flags().StringSlice("ingress", nil, "ingress firewall rule to deploy on creation format: tcp|udp@cidr#cidr@port#port@comment") | ||
must(cmd.RegisterFlagCompletionFunc("egress", c.comp.FirewallEgressCompletion)) | ||
must(cmd.RegisterFlagCompletionFunc("ingress", c.comp.FirewallIngressCompletion)) | ||
}, | ||
ListCmdMutateFn: func(cmd *cobra.Command) { | ||
cmd.Flags().String("id", "", "ID to filter [optional]") | ||
|
@@ -213,8 +215,8 @@ func (c *firewallCmd) createRequestFromCLI() (*models.V1FirewallCreateRequest, e | |
} | ||
|
||
// parseEgressFlags input must be in the form of | ||
// proto@cidr;cidr@port;port;port@comment | ||
// [email protected]/24;2.3.4.1/32@80#443#8080#8443@"Allow apt update" | ||
// proto@cidr#cidr@port#port#port@comment | ||
// [email protected]/24#2.3.4.1/32@80#443#8080#8443@"Allow apt update" | ||
func parseEgressFlags(inputs []string) ([]*models.V1FirewallEgressRule, error) { | ||
var rules []*models.V1FirewallEgressRule | ||
|
||
|