Skip to content

Commit

Permalink
fix(primary-ip): list does now allow to output IP column
Browse files Browse the repository at this point in the history
Since IP is a *hcloud.PrimaryIP, AddAllowedFields() only adds columns for primitive types and a field function for IP was missing, you were not able to output the IP column using output flags.

Closes #591
  • Loading branch information
phm07 committed Oct 31, 2023
1 parent 7e511d9 commit c0f73db
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/cmd/primaryip/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ var ListCmd = base.ListCmd{
OutputTable: func(client hcapi2.Client) *output.Table {
return output.NewTable().
AddAllowedFields(hcloud.PrimaryIP{}).
AddFieldFn("ip", output.FieldFn(func(obj interface{}) string {
primaryIP := obj.(*hcloud.PrimaryIP)
if primaryIP.Network != nil {
return primaryIP.Network.String()
}
return primaryIP.IP.String()
})).
AddFieldFn("dns", output.FieldFn(func(obj interface{}) string {
primaryIP := obj.(*hcloud.PrimaryIP)
var dns string
Expand Down

0 comments on commit c0f73db

Please sign in to comment.