Skip to content

Commit 5a78fce

Browse files
committed
feat(lb): add resolvers to show command output
1 parent 9cb314b commit 5a78fce

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

  • internal/commands/loadbalancer

internal/commands/loadbalancer/show.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package loadbalancer
22

33
import (
4+
"strings"
5+
46
"github.com/UpCloudLtd/upcloud-cli/internal/commands"
57
"github.com/UpCloudLtd/upcloud-cli/internal/completion"
68
"github.com/UpCloudLtd/upcloud-cli/internal/output"
@@ -69,6 +71,19 @@ func (s *showCommand) Execute(exec commands.Executor, uuid string) (output.Outpu
6971
})
7072
}
7173

74+
resolverRows := []output.TableRow{}
75+
for _, resolver := range lb.Resolvers {
76+
var nameservers []string
77+
for _, nameserver := range resolver.Nameservers {
78+
nameservers = append(nameservers, ui.DefaultAddressColours.Sprint(nameserver))
79+
}
80+
81+
resolverRows = append(resolverRows, output.TableRow{
82+
resolver.Name,
83+
strings.Join(nameservers, ", "),
84+
})
85+
}
86+
7287
// For JSON and YAML output, passthrough API response
7388
return output.MarshaledWithHumanOutput{
7489
Value: lb,
@@ -117,6 +132,16 @@ func (s *showCommand) Execute(exec commands.Executor, uuid string) (output.Outpu
117132
Rows: frontEndRows,
118133
},
119134
},
135+
output.CombinedSection{
136+
Title: "Resolvers:",
137+
Contents: output.Table{
138+
Columns: []output.TableColumn{
139+
{Key: "name", Header: "Name"},
140+
{Key: "nameservers", Header: "Nameservers"},
141+
},
142+
Rows: resolverRows,
143+
},
144+
},
120145
},
121146
}, nil
122147
}

0 commit comments

Comments
 (0)