Skip to content

Commit

Permalink
Network: add target parameter to cli for network list command
Browse files Browse the repository at this point in the history
Signed-off-by: David Edler <[email protected]>
  • Loading branch information
edlerd committed Dec 12, 2024
1 parent 4846424 commit a9a4a5f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lxc/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ type cmdNetworkList struct {
network *cmdNetwork

flagFormat string
flagTarget string
}

func (c *cmdNetworkList) command() *cobra.Command {
Expand All @@ -1007,6 +1008,7 @@ func (c *cmdNetworkList) command() *cobra.Command {

cmd.RunE = c.run
cmd.Flags().StringVarP(&c.flagFormat, "format", "f", "table", i18n.G("Format (csv|json|table|yaml|compact)")+"``")
cmd.Flags().StringVar(&c.flagTarget, "target", "", i18n.G("Cluster member name")+"``")

cmd.ValidArgsFunction = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) != 0 {
Expand Down Expand Up @@ -1044,7 +1046,14 @@ func (c *cmdNetworkList) run(cmd *cobra.Command, args []string) error {
return errors.New(i18n.G("Filtering isn't supported yet"))
}

networks, err := resource.server.GetNetworks()
client := resource.server

// Targeting.
if c.flagTarget != "" {
client = client.UseTarget(c.flagTarget)
}

networks, err := client.GetNetworks()
if err != nil {
return err
}
Expand Down

0 comments on commit a9a4a5f

Please sign in to comment.