Skip to content

Commit

Permalink
bump go-api-declarations to v1.10.11
Browse files Browse the repository at this point in the history
  • Loading branch information
majewsky committed Apr 4, 2024
1 parent 3ccb070 commit def04bc
Show file tree
Hide file tree
Showing 29 changed files with 181 additions and 160 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/gophercloud/gophercloud v1.11.0
github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56
github.com/olekukonko/tablewriter v0.0.5
github.com/sapcc/go-api-declarations v1.10.10
github.com/sapcc/go-api-declarations v1.10.11
github.com/sapcc/go-bits v0.0.0-20240328092936-0e0b562825d4
github.com/sapcc/gophercloud-sapcc v0.0.0-20240328042652-ea67c703afd6
github.com/spf13/cobra v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sapcc/go-api-declarations v1.10.10 h1:1mrawZ8jink62vhOl5lffTcI54EP7Ye1hc2ZOMLqY7M=
github.com/sapcc/go-api-declarations v1.10.10/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI=
github.com/sapcc/go-api-declarations v1.10.11 h1:fxPTNfsriHX/a/eZo/9ugrGyS3oxh5z0xOTJkGmGUlQ=
github.com/sapcc/go-api-declarations v1.10.11/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI=
github.com/sapcc/go-bits v0.0.0-20240328092936-0e0b562825d4 h1:McWSE2OxvmMIxI6y1udn7AxJEZ6Ze5FS59nTbIMcTDk=
github.com/sapcc/go-bits v0.0.0-20240328092936-0e0b562825d4/go.mod h1:MfdlJwxZa92nnBfg5LvfR7F6HGxTe9N1N5K+EB09kEg=
github.com/sapcc/gophercloud-sapcc v0.0.0-20240328042652-ea67c703afd6 h1:dndMdc3nqbHZhSQ5D05UcH6KaxKfR59MZb3WdDqbf4c=
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cmd
import (
"github.com/gophercloud/gophercloud"
"github.com/sapcc/go-api-declarations/limes"
limesresources "github.com/sapcc/go-api-declarations/limes/resources"
"github.com/sapcc/gophercloud-sapcc/resources/v1/domains"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -247,7 +248,7 @@ func getDomainResourceQuotas(limesClient *gophercloud.ServiceClient, domainID st
for srv, srvReport := range rep.Services {
for res, resReport := range srvReport.Resources {
if _, ok := result[srv]; !ok {
result[srv] = make(map[string]limes.ValueWithUnit)
result[srv] = make(map[limesresources.ResourceName]limes.ValueWithUnit)
}
var val uint64
if resReport.DomainQuota != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/parse_quotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

// resourceQuotas is a map of service name to resource name to the resource's
// quota value and unit.
type resourceQuotas map[string]map[string]limes.ValueWithUnit
type resourceQuotas map[limes.ServiceType]map[limesresources.ResourceName]limes.ValueWithUnit

// splitQuotaRe is used to split the user input around the equality sign.
// Reference:
Expand Down Expand Up @@ -75,8 +75,8 @@ func parseToQuotaRequest(resValues resourceQuotas, in []string) (limesresources.
if len(serviceResource) > 2 {
return out, fmt.Errorf("expected a quota with service resource in the format: service/resource, got %q", matchList[1])
}
service := serviceResource[0]
resource := serviceResource[1]
service := limes.ServiceType(serviceResource[0])
resource := limesresources.ResourceName(serviceResource[1])
currentValWithUnit, ok := resValues[service][resource]
if !ok {
return nil, fmt.Errorf("invalid resource: %s/%s does not exist in Limes", service, resource)
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/parse_quotas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ func TestParseToQuotaRequest(t *testing.T) {
}

resQuotas := resourceQuotas{
"shared": map[string]limes.ValueWithUnit{
"shared": {
"capacity": {Value: 1024, Unit: limes.UnitMebibytes},
"capacity2": {Value: 3, Unit: limes.UnitGibibytes},
},
"unshared": map[string]limes.ValueWithUnit{
"unshared": {
"things": {Value: 10, Unit: limes.UnitNone},
"things2": {Value: 10, Unit: limes.UnitNone},
"things3": {Value: 44, Unit: limes.UnitNone},
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/gophercloud/gophercloud"
"github.com/sapcc/go-api-declarations/limes"
limesresources "github.com/sapcc/go-api-declarations/limes/resources"
ratesProjects "github.com/sapcc/gophercloud-sapcc/rates/v1/projects"
"github.com/sapcc/gophercloud-sapcc/resources/v1/projects"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -532,7 +533,7 @@ func getProjectResourceQuotas(limesClient *gophercloud.ServiceClient, pInfo *aut
for srv, srvReport := range rep.Services {
for res, resReport := range srvReport.Resources {
if _, ok := result[srv]; !ok {
result[srv] = make(map[string]limes.ValueWithUnit)
result[srv] = make(map[limesresources.ResourceName]limes.ValueWithUnit)
}
var val uint64
if resReport.Quota != nil {
Expand Down
15 changes: 8 additions & 7 deletions internal/core/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package core

import (
"sort"
"slices"

"github.com/sapcc/go-api-declarations/limes"
limesresources "github.com/sapcc/go-api-declarations/limes/resources"
)

Expand Down Expand Up @@ -48,19 +49,19 @@ func (c ClusterReport) render(opts *OutputOpts) CSVRecords {
var records CSVRecords

// Serialize service types with ordered keys
types := make([]string, 0, len(c.Services))
types := make([]limes.ServiceType, 0, len(c.Services))
for typeStr := range c.Services {
types = append(types, typeStr)
}
sort.Strings(types)
slices.Sort(types)

for _, srv := range types {
// Serialize resource names with ordered keys
names := make([]string, 0, len(c.Services[srv].Resources))
names := make([]limesresources.ResourceName, 0, len(c.Services[srv].Resources))
for nameStr := range c.Services[srv].Resources {
names = append(names, nameStr)
}
sort.Strings(names)
slices.Sort(names)

for _, res := range names {
var r []string
Expand All @@ -78,12 +79,12 @@ func (c ClusterReport) render(opts *OutputOpts) CSVRecords {
})

if opts.CSVRecFmt == CSVRecordFormatLong {
r = append(r, c.ID, cSrv.Area, cSrv.Type, cSrvRes.Category, cSrvRes.Name, emptyStrIfNil(capacity, valToStr),
r = append(r, c.ID, cSrv.Area, string(cSrv.Type), cSrvRes.Category, string(cSrvRes.Name), emptyStrIfNil(capacity, valToStr),
emptyStrIfNil(domsQ, valToStr), valToStr(cSrvRes.Usage), emptyStrIfNil(physU, valToStr),
valToStr(cSrvRes.BurstUsage), string(unit), timestampToString(cSrv.MinScrapedAt),
)
} else {
r = append(r, c.ID, cSrv.Type, cSrvRes.Name, emptyStrIfNil(capacity, valToStr),
r = append(r, c.ID, string(cSrv.Type), string(cSrvRes.Name), emptyStrIfNil(capacity, valToStr),
emptyStrIfNil(domsQ, valToStr), valToStr(cSrvRes.Usage), string(unit),
)
}
Expand Down
15 changes: 8 additions & 7 deletions internal/core/cluster_rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package core

import (
"sort"
"slices"

"github.com/sapcc/go-api-declarations/limes"
limesrates "github.com/sapcc/go-api-declarations/limes/rates"
)

Expand All @@ -41,19 +42,19 @@ func (c ClusterRatesReport) render(opts *OutputOpts) CSVRecords {
var records CSVRecords

// Serialize service types with ordered keys
types := make([]string, 0, len(c.Services))
types := make([]limes.ServiceType, 0, len(c.Services))
for typeStr := range c.Services {
types = append(types, typeStr)
}
sort.Strings(types)
slices.Sort(types)

for _, srv := range types {
// Serialize rate names with ordered keys
names := make([]string, 0, len(c.Services[srv].Rates))
names := make([]limesrates.RateName, 0, len(c.Services[srv].Rates))
for nameStr := range c.Services[srv].Rates {
names = append(names, nameStr)
}
sort.Strings(names)
slices.Sort(names)

for _, rate := range names {
var r []string
Expand All @@ -63,10 +64,10 @@ func (c ClusterRatesReport) render(opts *OutputOpts) CSVRecords {

valToStr := defaultValToStrFunc
if opts.CSVRecFmt == CSVRecordFormatLong {
r = append(r, c.ID, cSrv.Area, cSrv.Type, cSrvRate.Name, valToStr(cSrvRate.Limit),
r = append(r, c.ID, cSrv.Area, string(cSrv.Type), string(cSrvRate.Name), valToStr(cSrvRate.Limit),
cSrvRate.Window.String(), string(cSrvRate.Unit), timestampToString(cSrv.MinScrapedAt))
} else {
r = append(r, c.ID, cSrv.Type, cSrvRate.Name, valToStr(cSrvRate.Limit), cSrvRate.Window.String(), string(cSrvRate.Unit))
r = append(r, c.ID, string(cSrv.Type), string(cSrvRate.Name), valToStr(cSrvRate.Limit), cSrvRate.Window.String(), string(cSrvRate.Unit))
}

records = append(records, r)
Expand Down
15 changes: 8 additions & 7 deletions internal/core/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package core

import (
"sort"
"slices"

"github.com/sapcc/go-api-declarations/limes"
limesresources "github.com/sapcc/go-api-declarations/limes/resources"
)

Expand Down Expand Up @@ -63,19 +64,19 @@ func (d DomainReport) render(opts *OutputOpts) CSVRecords {
var records CSVRecords

// Serialize service types with ordered keys
types := make([]string, 0, len(d.Services))
types := make([]limes.ServiceType, 0, len(d.Services))
for typeStr := range d.Services {
types = append(types, typeStr)
}
sort.Strings(types)
slices.Sort(types)

for _, srv := range types {
// Serialize resource names with ordered keys
names := make([]string, 0, len(d.Services[srv].Resources))
names := make([]limesresources.ResourceName, 0, len(d.Services[srv].Resources))
for nameStr := range d.Services[srv].Resources {
names = append(names, nameStr)
}
sort.Strings(names)
slices.Sort(names)

for _, res := range names {
var r []string
Expand All @@ -93,7 +94,7 @@ func (d DomainReport) render(opts *OutputOpts) CSVRecords {
})

if opts.CSVRecFmt == CSVRecordFormatLong {
r = append(r, d.UUID, d.Name, dSrv.Area, dSrv.Type, dSrvRes.Category, dSrvRes.Name,
r = append(r, d.UUID, d.Name, dSrv.Area, string(dSrv.Type), dSrvRes.Category, string(dSrvRes.Name),
emptyStrIfNil(domQ, valToStr), emptyStrIfNil(projectsQ, valToStr), valToStr(dSrvRes.Usage),
emptyStrIfNil(physU, valToStr), valToStr(dSrvRes.BurstUsage), string(unit), timestampToString(dSrv.MinScrapedAt),
)
Expand All @@ -102,7 +103,7 @@ func (d DomainReport) render(opts *OutputOpts) CSVRecords {
if opts.CSVRecFmt == CSVRecordFormatNames {
nameOrID = d.Name
}
r = append(r, nameOrID, dSrv.Type, dSrvRes.Name, emptyStrIfNil(domQ, valToStr),
r = append(r, nameOrID, string(dSrv.Type), string(dSrvRes.Name), emptyStrIfNil(domQ, valToStr),
emptyStrIfNil(projectsQ, valToStr), valToStr(dSrvRes.Usage), string(unit),
)
}
Expand Down
17 changes: 9 additions & 8 deletions internal/core/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package core

import (
"sort"
"slices"

"github.com/sapcc/go-api-declarations/limes"
limesresources "github.com/sapcc/go-api-declarations/limes/resources"
)

Expand Down Expand Up @@ -74,19 +75,19 @@ func (p ProjectResourcesReport) render(opts *OutputOpts) CSVRecords {
var records CSVRecords

// Serialize service types with ordered keys
types := make([]string, 0, len(p.Services))
types := make([]limes.ServiceType, 0, len(p.Services))
for typeStr := range p.Services {
types = append(types, typeStr)
}
sort.Strings(types)
slices.Sort(types)

for _, srv := range types {
// Serialize resource names with ordered keys
names := make([]string, 0, len(p.Services[srv].Resources))
names := make([]limesresources.ResourceName, 0, len(p.Services[srv].Resources))
for nameStr := range p.Services[srv].Resources {
names = append(names, nameStr)
}
sort.Strings(names)
slices.Sort(names)

for _, res := range names {
var r []string
Expand Down Expand Up @@ -117,8 +118,8 @@ func (p ProjectResourcesReport) render(opts *OutputOpts) CSVRecords {
})

if opts.CSVRecFmt == CSVRecordFormatLong {
r = append(r, p.DomainID, p.DomainName, p.UUID, p.Name, pSrv.Area, pSrv.Type, pSrvRes.Category,
pSrvRes.Name, emptyStrIfNil(quota, valToStr), emptyStrIfNil(burstQuota, valToStr), valToStr(usage),
r = append(r, p.DomainID, p.DomainName, p.UUID, p.Name, pSrv.Area, string(pSrv.Type), pSrvRes.Category,
string(pSrvRes.Name), emptyStrIfNil(quota, valToStr), emptyStrIfNil(burstQuota, valToStr), valToStr(usage),
emptyStrIfNil(physU, valToStr), valToStr(burstUsage), string(unit), timestampToString(pSrv.ScrapedAt),
)
} else {
Expand All @@ -128,7 +129,7 @@ func (p ProjectResourcesReport) render(opts *OutputOpts) CSVRecords {
projectNameOrID = p.Name
domainNameOrID = p.DomainName
}
r = append(r, domainNameOrID, projectNameOrID, pSrv.Type, pSrvRes.Name,
r = append(r, domainNameOrID, projectNameOrID, string(pSrv.Type), string(pSrvRes.Name),
emptyStrIfNil(quota, valToStr), valToStr(usage), string(unit),
)
}
Expand Down
15 changes: 8 additions & 7 deletions internal/core/project_rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package core

import (
"sort"
"slices"

"github.com/sapcc/go-api-declarations/limes"
limesrates "github.com/sapcc/go-api-declarations/limes/rates"
)

Expand Down Expand Up @@ -72,19 +73,19 @@ func (p ProjectRatesReport) render(opts *OutputOpts) CSVRecords {
var records CSVRecords

// Serialize service types with ordered keys
types := make([]string, 0, len(p.Services))
types := make([]limes.ServiceType, 0, len(p.Services))
for typeStr := range p.Services {
types = append(types, typeStr)
}
sort.Strings(types)
slices.Sort(types)

for _, srv := range types {
// Serialize rate names with ordered keys
names := make([]string, 0, len(p.Services[srv].Rates))
names := make([]limesrates.RateName, 0, len(p.Services[srv].Rates))
for nameStr := range p.Services[srv].Rates {
names = append(names, nameStr)
}
sort.Strings(names)
slices.Sort(names)

for _, rate := range names {
var r []string
Expand All @@ -102,7 +103,7 @@ func (p ProjectRatesReport) render(opts *OutputOpts) CSVRecords {

valToStr := defaultValToStrFunc
if opts.CSVRecFmt == CSVRecordFormatLong {
r = append(r, p.DomainID, p.DomainName, p.UUID, p.Name, pSrv.Area, pSrv.Type, pSrvRate.Name,
r = append(r, p.DomainID, p.DomainName, p.UUID, p.Name, pSrv.Area, string(pSrv.Type), string(pSrvRate.Name),
valToStr(pSrvRate.Limit), valToStr(pSrvRate.DefaultLimit), window, defaultWindow,
pSrvRate.UsageAsBigint, string(pSrvRate.Unit), timestampToString(pSrv.ScrapedAt),
)
Expand All @@ -113,7 +114,7 @@ func (p ProjectRatesReport) render(opts *OutputOpts) CSVRecords {
projectNameOrID = p.Name
domainNameOrID = p.DomainName
}
r = append(r, domainNameOrID, projectNameOrID, pSrv.Type, pSrvRate.Name,
r = append(r, domainNameOrID, projectNameOrID, string(pSrv.Type), string(pSrvRate.Name),
valToStr(pSrvRate.Limit), window, pSrvRate.UsageAsBigint, string(pSrvRate.Unit),
)
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit def04bc

Please sign in to comment.