Skip to content

Commit

Permalink
Support getting Firewalls by label selector
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Kämmerling <[email protected]>
  • Loading branch information
LKaemmerling committed May 28, 2021
1 parent bb30002 commit 3058650
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/cmd/firewall/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,20 @@ func newListCommand(cli *state.State) *cobra.Command {
RunE: cli.Wrap(runList),
}
output.AddFlag(cmd, output.OptionNoHeader(), output.OptionColumns(listTableOutput.Columns()), output.OptionJSON())
cmd.Flags().StringP("selector", "l", "", "Selector to filter by labels")
return cmd
}

func runList(cli *state.State, cmd *cobra.Command, args []string) error {
outOpts := output.FlagsForCommand(cmd)

firewalls, err := cli.Client().Firewall.All(cli.Context)
labelSelector, _ := cmd.Flags().GetString("selector")
opts := hcloud.FirewallListOpts{
ListOpts: hcloud.ListOpts{
LabelSelector: labelSelector,
PerPage: 50,
},
}
firewalls, _, err := cli.Client().Firewall.List(cli.Context, opts)
if err != nil {
return err
}
Expand Down

0 comments on commit 3058650

Please sign in to comment.