Skip to content

Commit

Permalink
feat(load-balancer-type): show traffic details for each location in d…
Browse files Browse the repository at this point in the history
…escribe output
  • Loading branch information
apricote committed Jul 25, 2024
1 parent 1546dc0 commit 5bbccb8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
10 changes: 7 additions & 3 deletions internal/cmd/loadbalancertype/describe.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package loadbalancertype

import (
"github.com/dustin/go-humanize"
"github.com/spf13/cobra"

"github.com/hetznercloud/cli/internal/cmd/base"
Expand Down Expand Up @@ -42,9 +43,12 @@ var DescribeCmd = base.DescribeCmd{
if pricings != nil {
cmd.Printf("Pricings per Location:\n")
for _, price := range pricings {
cmd.Printf(" - Location:\t%s\n", price.Location.Name)
cmd.Printf(" Hourly:\t%s\n", util.GrossPrice(price.Hourly))
cmd.Printf(" Monthly:\t%s\n", util.GrossPrice(price.Monthly))
cmd.Printf(" - Location:\t\t%s\n", price.Location.Name)
cmd.Printf(" Hourly:\t\t%s\n", util.GrossPrice(price.Hourly))
cmd.Printf(" Monthly:\t\t%s\n", util.GrossPrice(price.Monthly))
cmd.Printf(" Included Traffic:\t%s\n", humanize.IBytes(price.IncludedTraffic))
cmd.Printf(" Additional Traffic:\t%s per TB\n", util.GrossPrice(price.PerTBTraffic))
cmd.Printf("\n")
}
}

Expand Down
19 changes: 16 additions & 3 deletions internal/cmd/loadbalancertype/describe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func TestDescribe(t *testing.T) {
Gross: "7.0000",
Currency: "EUR",
},
IncludedTraffic: 6543210,
PerTBTraffic: hcloud.Price{
Gross: "8.0000",
Currency: "EUR",
},
}},
},
{
Expand All @@ -65,6 +70,11 @@ func TestDescribe(t *testing.T) {
Gross: "2.0000",
Currency: "EUR",
},
IncludedTraffic: 654321,
PerTBTraffic: hcloud.Price{
Gross: "3.0000",
Currency: "EUR",
},
}},
},
},
Expand All @@ -80,9 +90,12 @@ Max Connections: 10000
Max Targets: 25
Max assigned Certificates: 10
Pricings per Location:
- Location: Falkenstein
Hourly: € 1.0000
Monthly: € 2.0000
- Location: Falkenstein
Hourly: € 1.0000
Monthly: € 2.0000
Included Traffic: 639 KiB
Additional Traffic: € 3.0000 per TB
`

assert.NoError(t, err)
Expand Down

0 comments on commit 5bbccb8

Please sign in to comment.