Skip to content

Commit ba96357

Browse files
thetechnickthcyron
authored andcommitted
Add datacenter and location to server describe and server list (#98)
1 parent c1016d4 commit ba96357

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## master
4+
5+
* Show datacenter in `server list` and `server describe`
6+
37
## v1.3.1
48

59
* Only poll action progress every 500ms (instead of every 100ms)

server_describe.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,18 @@ func runServerDescribe(cli *CLI, cmd *cobra.Command, args []string) error {
8888
fmt.Printf(" No Image\n")
8989
}
9090

91+
fmt.Printf("Datacenter:\n")
92+
fmt.Printf(" ID:\t\t%d\n", server.Datacenter.ID)
93+
fmt.Printf(" Name:\t\t%s\n", server.Datacenter.Name)
94+
fmt.Printf(" Description:\t%s\n", server.Datacenter.Description)
95+
fmt.Printf(" Location:\n")
96+
fmt.Printf(" Name:\t\t%s\n", server.Datacenter.Location.Name)
97+
fmt.Printf(" Description:\t%s\n", server.Datacenter.Location.Description)
98+
fmt.Printf(" Country:\t\t%s\n", server.Datacenter.Location.Country)
99+
fmt.Printf(" City:\t\t%s\n", server.Datacenter.Location.City)
100+
fmt.Printf(" Latitude:\t\t%f\n", server.Datacenter.Location.Latitude)
101+
fmt.Printf(" Longitude:\t\t%f\n", server.Datacenter.Location.Longitude)
102+
91103
fmt.Printf("Traffic:\n")
92104
fmt.Printf(" Outgoing:\t%v\n", humanize.Bytes(server.OutgoingTraffic))
93105
fmt.Printf(" Ingoing:\t%v\n", humanize.Bytes(server.IngoingTraffic))

server_list.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func runServerList(cli *CLI, cmd *cobra.Command, args []string) error {
2929
return err
3030
}
3131

32-
cols := []string{"id", "name", "status", "ipv4", "ipv6"}
32+
cols := []string{"id", "name", "status", "ipv4", "ipv6", "datacenter"}
3333
if outOpts.IsSet("columns") {
3434
cols = outOpts["columns"]
3535
}
@@ -43,6 +43,14 @@ func runServerList(cli *CLI, cmd *cobra.Command, args []string) error {
4343
AddFieldOutputFn("ipv6", fieldOutputFn(func(obj interface{}) string {
4444
server := obj.(*hcloud.Server)
4545
return server.PublicNet.IPv6.Network.String()
46+
})).
47+
AddFieldOutputFn("datacenter", fieldOutputFn(func(obj interface{}) string {
48+
server := obj.(*hcloud.Server)
49+
return server.Datacenter.Name
50+
})).
51+
AddFieldOutputFn("location", fieldOutputFn(func(obj interface{}) string {
52+
server := obj.(*hcloud.Server)
53+
return server.Datacenter.Location.Name
4654
}))
4755

4856
if err = tw.ValidateColumns(cols); err != nil {

0 commit comments

Comments
 (0)