diff --git a/description_templates/_compute.gotmpl b/description_templates/_compute.gotmpl new file mode 100644 index 0000000..309f5c9 --- /dev/null +++ b/description_templates/_compute.gotmpl @@ -0,0 +1,11 @@ +{{template "_compute" . -}} +{{- define "_compute" -}} +{{$s:="\u2001"}}{{/*We need to use unicode whitespaces to make Odoo render them*/}} +Compute + +Qty: {{.Quantity | printf "%.2f"}} {{.Unit}}-Minutes +Average Usage: {{.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute +{{$s}}Memory Requests: {{.SubItems.appuio_cloud_memory_subquery_memory_request.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute +{{$s}}CPU Requests: {{.SubItems.appuio_cloud_memory_subquery_cpu_request.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute +Unit Price: CHF {{.PricePerUnit | printf "%.10f"}} / {{.Unit}} / Minute +{{- end -}} diff --git a/description_templates/_usage.gotmpl b/description_templates/_usage.gotmpl index 15decc0..261adab 100644 --- a/description_templates/_usage.gotmpl +++ b/description_templates/_usage.gotmpl @@ -1,8 +1,5 @@ {{- define "_usage" -}} Qty: {{.Quantity | printf "%.2f"}} {{.Unit}}-Minutes Average Usage: {{.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute -{{ range .SubItems -}} -Average {{.Description}}: {{.QuantityAvg | perMinute | printf "%.2f"}} {{.Unit}} / Minute -{{ end -}} Unit Price: CHF {{.PricePerUnit | printf "%.10f"}} / {{.Unit}} / Minute {{- end -}} diff --git a/description_templates/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.gotmpl b/description_templates/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.gotmpl index 62baf22..f6e9ba6 100644 --- a/description_templates/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.gotmpl +++ b/description_templates/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.gotmpl @@ -1,3 +1 @@ -Compute - -{{template "_usage" . -}} +{{template "_compute" . -}} diff --git a/description_templates/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.gotmpl b/description_templates/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.gotmpl index 62baf22..f6e9ba6 100644 --- a/description_templates/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.gotmpl +++ b/description_templates/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.gotmpl @@ -1,3 +1 @@ -Compute - -{{template "_usage" . -}} +{{template "_compute" . -}} diff --git a/description_templates/golden/appuio_cloud_loadbalancer:c-appuio-cloudscale-lpg-2.txt b/description_templates/golden/appuio_cloud_loadbalancer:c-appuio-cloudscale-lpg-2.txt index b134830..cd3b6ef 100755 --- a/description_templates/golden/appuio_cloud_loadbalancer:c-appuio-cloudscale-lpg-2.txt +++ b/description_templates/golden/appuio_cloud_loadbalancer:c-appuio-cloudscale-lpg-2.txt @@ -2,6 +2,4 @@ Service Type LoadBalancer Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute \ No newline at end of file diff --git a/description_templates/golden/appuio_cloud_loadbalancer:c-appuio-exoscale-ch-gva-2-0.txt b/description_templates/golden/appuio_cloud_loadbalancer:c-appuio-exoscale-ch-gva-2-0.txt index b1a19ed..e5483ca 100755 --- a/description_templates/golden/appuio_cloud_loadbalancer:c-appuio-exoscale-ch-gva-2-0.txt +++ b/description_templates/golden/appuio_cloud_loadbalancer:c-appuio-exoscale-ch-gva-2-0.txt @@ -2,8 +2,6 @@ Service Type LoadBalancer Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute Services of type LoadBalancer are not supported on "Exoscale - CH-GVA-2 0". \ No newline at end of file diff --git a/description_templates/golden/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.txt b/description_templates/golden/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.txt index 97cc865..494be8d 100755 --- a/description_templates/golden/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.txt +++ b/description_templates/golden/appuio_cloud_memory:c-appuio-cloudscale-lpg-2.txt @@ -1,7 +1,8 @@ + Compute Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute + Memory Requests: 0.70 UNIT / Minute + CPU Requests: 0.70 UNIT / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute \ No newline at end of file diff --git a/description_templates/golden/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.txt b/description_templates/golden/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.txt index 97cc865..494be8d 100755 --- a/description_templates/golden/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.txt +++ b/description_templates/golden/appuio_cloud_memory:c-appuio-exoscale-ch-gva-2-0.txt @@ -1,7 +1,8 @@ + Compute Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute + Memory Requests: 0.70 UNIT / Minute + CPU Requests: 0.70 UNIT / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute \ No newline at end of file diff --git a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:bulk.txt b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:bulk.txt index cde1ac7..4958d04 100755 --- a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:bulk.txt +++ b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:bulk.txt @@ -3,6 +3,4 @@ Persistent Storage Storage Type: RWO [bulk] Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute \ No newline at end of file diff --git a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:cephfs-fspool-cluster.txt b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:cephfs-fspool-cluster.txt index b674cf2..2d5ade2 100755 --- a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:cephfs-fspool-cluster.txt +++ b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:cephfs-fspool-cluster.txt @@ -3,6 +3,4 @@ Persistent Storage Storage Type: RWX [cephfs-fspool-cluster] Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute \ No newline at end of file diff --git a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:ssd.txt b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:ssd.txt index 65e118d..a6a1e86 100755 --- a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:ssd.txt +++ b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-cloudscale-lpg-2:*:*:ssd.txt @@ -3,6 +3,4 @@ Persistent Storage Storage Type: RWO [ssd] Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute \ No newline at end of file diff --git a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-exoscale-ch-gva-2-0:*:*:cephfs-fspool-cluster.txt b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-exoscale-ch-gva-2-0:*:*:cephfs-fspool-cluster.txt index b674cf2..2d5ade2 100755 --- a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-exoscale-ch-gva-2-0:*:*:cephfs-fspool-cluster.txt +++ b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-exoscale-ch-gva-2-0:*:*:cephfs-fspool-cluster.txt @@ -3,6 +3,4 @@ Persistent Storage Storage Type: RWX [cephfs-fspool-cluster] Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute \ No newline at end of file diff --git a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-exoscale-ch-gva-2-0:*:*:rbd-storagepool-cluster.txt b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-exoscale-ch-gva-2-0:*:*:rbd-storagepool-cluster.txt index 28abb76..34853e5 100755 --- a/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-exoscale-ch-gva-2-0:*:*:rbd-storagepool-cluster.txt +++ b/description_templates/golden/appuio_cloud_persistent_storage:c-appuio-exoscale-ch-gva-2-0:*:*:rbd-storagepool-cluster.txt @@ -3,6 +3,4 @@ Persistent Storage Storage Type: RWO [rbd-storagepool-cluster] Qty: 87955674.09 UNIT-Minutes Average Usage: 7.61 UNIT / Minute -Average Memory requests: 0.70 TPS / Minute -Average CPU requests in memory request equivalent: 0.70 TPS / Minute Unit Price: CHF 0.0000007460 / UNIT / Minute \ No newline at end of file diff --git a/description_templates/golden_test.go b/description_templates/golden_test.go index 7e39028..f2543a0 100644 --- a/description_templates/golden_test.go +++ b/description_templates/golden_test.go @@ -47,6 +47,7 @@ func TestGenerateGolden(t *testing.T) { baseItem := invoice.Item{ Description: "Long form query description", + QueryName: "default_query", ProductRef: invoice.ProductRef{ Target: "1919", Source: "SET ME", @@ -59,17 +60,19 @@ func TestGenerateGolden(t *testing.T) { PricePerUnit: 0.000000746, Discount: 0.33, Total: 43.962005025946798, - SubItems: []invoice.SubItem{ - { - Description: "Memory requests", + SubItems: map[string]invoice.SubItem{ + "appuio_cloud_memory_subquery_memory_request": { + Description: "Memory request aggregated by namespace", + QueryName: "appuio_cloud_memory_subquery_memory_request", Quantity: 34923234.04433424, QuantityMin: 2.251, QuantityAvg: 42.2, QuantityMax: 9001.1, Unit: "TPS", }, - { + "appuio_cloud_memory_subquery_cpu_request": { Description: "CPU requests in memory request equivalent", + QueryName: "appuio_cloud_memory_subquery_cpu_request", Quantity: 34923234.04433424, QuantityMin: 2.251, QuantityAvg: 42.2,