Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support getting Firewalls by label selector #327

Merged
merged 1 commit into from
May 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.AllWithOpts(cli.Context, opts)
if err != nil {
return err
}
Expand Down