diff --git a/CHANGELOG.md b/CHANGELOG.md index 492e007b..1d138d18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/sapcc/limesctl/compare/v3.3.2...HEAD) +### Removed + +- Removed everything related to Bursting + ## 3.3.2 - 2024-01-03 ### Changed diff --git a/go.mod b/go.mod index 1d8a00bd..d2120550 100644 --- a/go.mod +++ b/go.mod @@ -6,9 +6,9 @@ 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.11.0 - github.com/sapcc/go-bits v0.0.0-20240429130232-fdc0102c61a4 - github.com/sapcc/gophercloud-sapcc v0.0.0-20240429130228-bc9d8c12dd20 + github.com/sapcc/go-api-declarations v1.11.2 + github.com/sapcc/go-bits v0.0.0-20240516084938-1c041b7a84ce + github.com/sapcc/gophercloud-sapcc v0.0.0-20240510132707-01d47d03e5d9 github.com/spf13/cobra v1.8.0 ) diff --git a/go.sum b/go.sum index 03b58524..42e452a3 100644 --- a/go.sum +++ b/go.sum @@ -15,12 +15,12 @@ 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.11.0 h1:k/U/Hdv2UbBdAyxfnWUyhs8hl74fCrNn8aIWj+k42u4= -github.com/sapcc/go-api-declarations v1.11.0/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI= -github.com/sapcc/go-bits v0.0.0-20240429130232-fdc0102c61a4 h1:h7xYkyFcGmqPcgNPL3LLrOTANeuZwKYq5WriV0e2Dvg= -github.com/sapcc/go-bits v0.0.0-20240429130232-fdc0102c61a4/go.mod h1:4gsmI0EEDRETgw6+TWm/l627KZMA9/MAxNxMsY1S7bs= -github.com/sapcc/gophercloud-sapcc v0.0.0-20240429130228-bc9d8c12dd20 h1:wmqC1VU1BK2lxM4dyBJ/70m4ntVhNWs6c+oNalSSNaQ= -github.com/sapcc/gophercloud-sapcc v0.0.0-20240429130228-bc9d8c12dd20/go.mod h1:KWKJEgcBm/70+VAra07oLZm1ixEUJ1MTsSf2DGAns5g= +github.com/sapcc/go-api-declarations v1.11.2 h1:CFVxgWqrs4WBJhbA0nJNQ/0mBpAxmNFuUZtuEITltFU= +github.com/sapcc/go-api-declarations v1.11.2/go.mod h1:83R3hTANhuRXt/pXDby37IJetw8l7DG41s33Tp9NXxI= +github.com/sapcc/go-bits v0.0.0-20240516084938-1c041b7a84ce h1:cMrOXCHbUuxCJX3vkaXvMcmUKkQQ65BPwtCj7MMebCA= +github.com/sapcc/go-bits v0.0.0-20240516084938-1c041b7a84ce/go.mod h1:dGC65DP50Yuu0P+DsrtXIZU+P0HluN7HXnAA3xNCVBk= +github.com/sapcc/gophercloud-sapcc v0.0.0-20240510132707-01d47d03e5d9 h1:MeUExAMelWyNKK2ODNqsKLlZeJVKAbTgBiQIdS3e9+8= +github.com/sapcc/gophercloud-sapcc v0.0.0-20240510132707-01d47d03e5d9/go.mod h1:UIHKHyFEKUoGAJIA08PBpGyzOykFHYKTl/+j6jUYhko= github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= diff --git a/internal/core/cluster.go b/internal/core/cluster.go index 9a3128e5..daf837e8 100644 --- a/internal/core/cluster.go +++ b/internal/core/cluster.go @@ -28,7 +28,7 @@ type ClusterReport struct { var csvHeaderClusterLong = []string{ "cluster id", "area", "service", "category", "resource", "capacity", - "domains quota", "usage", "physical usage", "burst usage", "unit", "scraped at (UTC)", + "domains quota", "usage", "physical usage", "unit", "scraped at (UTC)", } var csvHeaderClusterDefault = []string{ @@ -75,13 +75,13 @@ func (c ClusterReport) render(opts *OutputOpts) CSVRecords { valToStr, unit := getValToStrFunc(opts.Humanize, cSrvRes.Unit, []uint64{ zeroIfNil(capacity), zeroIfNil(physU), zeroIfNil(domsQ), - cSrvRes.Usage, cSrvRes.BurstUsage, + cSrvRes.Usage, }) if opts.CSVRecFmt == CSVRecordFormatLong { 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), + string(unit), timestampToString(cSrv.MinScrapedAt), ) } else { r = append(r, c.ID, string(cSrv.Type), string(cSrvRes.Name), emptyStrIfNil(capacity, valToStr), diff --git a/internal/core/domain.go b/internal/core/domain.go index e2ae5491..00df62db 100644 --- a/internal/core/domain.go +++ b/internal/core/domain.go @@ -40,7 +40,7 @@ var csvHeaderDomainDefault = []string{"domain id", "service", "resource", "quota var csvHeaderDomainLong = []string{ "domain id", "domain name", "area", "service", "category", "resource", - "quota", "projects quota", "usage", "physical usage", "burst usage", "unit", "scraped at (UTC)", + "quota", "projects quota", "usage", "physical usage", "unit", "scraped at (UTC)", } const domainName = "domain name" @@ -90,13 +90,13 @@ func (d DomainReport) render(opts *OutputOpts) CSVRecords { valToStr, unit := getValToStrFunc(opts.Humanize, dSrvRes.Unit, []uint64{ zeroIfNil(physU), zeroIfNil(domQ), zeroIfNil(projectsQ), - dSrvRes.Usage, dSrvRes.BurstUsage, + dSrvRes.Usage, }) if opts.CSVRecFmt == CSVRecordFormatLong { 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), + emptyStrIfNil(physU, valToStr), string(unit), timestampToString(dSrv.MinScrapedAt), ) } else { nameOrID := d.UUID diff --git a/internal/core/fixtures/domain-list-filtered.csv b/internal/core/fixtures/domain-list-filtered.csv index 8068d342..2c1a7ab0 100644 --- a/internal/core/fixtures/domain-list-filtered.csv +++ b/internal/core/fixtures/domain-list-filtered.csv @@ -1,3 +1,3 @@ -domain id;domain name;area;service;category;resource;quota;projects quota;usage;physical usage;burst usage;unit;scraped at (UTC) -uuid-for-france;france;shared;shared;;things;0;10;2;;0;;1970-01-01T00:01:06Z -uuid-for-germany;germany;shared;shared;;things;30;20;4;;0;;1970-01-01T00:00:22Z +domain id;domain name;area;service;category;resource;quota;projects quota;usage;physical usage;unit;scraped at (UTC) +uuid-for-france;france;shared;shared;;things;0;10;2;;;1970-01-01T00:01:06Z +uuid-for-germany;germany;shared;shared;;things;30;20;4;;;1970-01-01T00:00:22Z diff --git a/internal/core/fixtures/project-list-filtered.csv b/internal/core/fixtures/project-list-filtered.csv index dcc075bd..0a278403 100644 --- a/internal/core/fixtures/project-list-filtered.csv +++ b/internal/core/fixtures/project-list-filtered.csv @@ -1,3 +1,3 @@ -domain id;domain name;project id;project name;area;service;category;resource;quota;burst quota;usage;physical usage;burst usage;unit;scraped at (UTC) -uuid-for-germany;germany;uuid-for-berlin;berlin;shared;shared;;things;10;;2;;0;;1970-01-01T00:00:22Z -uuid-for-germany;germany;uuid-for-dresden;dresden;shared;shared;;things;10;;2;;0;;1970-01-01T00:00:44Z +domain id;domain name;project id;project name;area;service;category;resource;quota;usage;physical usage;unit;scraped at (UTC) +uuid-for-germany;germany;uuid-for-berlin;berlin;shared;shared;;things;10;2;;;1970-01-01T00:00:22Z +uuid-for-germany;germany;uuid-for-dresden;dresden;shared;shared;;things;10;2;;;1970-01-01T00:00:44Z diff --git a/internal/core/project.go b/internal/core/project.go index b584e340..53a129dd 100644 --- a/internal/core/project.go +++ b/internal/core/project.go @@ -52,7 +52,7 @@ var csvHeaderProjectDefault = []string{"domain id", "project id", "service", "re var csvHeaderProjectLong = []string{ "domain id", "domain name", "project id", "project name", "area", "service", - "category", "resource", "quota", "burst quota", "usage", "physical usage", "burst usage", "unit", "scraped at (UTC)", + "category", "resource", "quota", "usage", "physical usage", "unit", "scraped at (UTC)", } // GetHeaderRow implements the LimesReportRenderer interface. @@ -99,28 +99,14 @@ func (p ProjectResourcesReport) render(opts *OutputOpts) CSVRecords { quota := pSrvRes.Quota usage := pSrvRes.Usage - // We use a *uint64 for burstQuota instead of an uint64 for - // consistency with Limes' API, i.e. if quota has a null value - // then burstQuota should also be null instead of zero. - var burstQuota *uint64 - var burstUsage uint64 - if quota != nil && p.Bursting != nil && p.Bursting.Enabled { - q := *quota - bq := p.Bursting.Multiplier.ApplyTo(q, pSrvRes.QuotaDistributionModel) - burstQuota = &bq - if usage > q { - burstUsage = usage - q - } - } - valToStr, unit := getValToStrFunc(opts.Humanize, pSrvRes.Unit, []uint64{ - zeroIfNil(burstQuota), burstUsage, zeroIfNil(physU), zeroIfNil(quota), usage, + zeroIfNil(physU), zeroIfNil(quota), usage, }) if opts.CSVRecFmt == CSVRecordFormatLong { 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), + string(pSrvRes.Name), emptyStrIfNil(quota, valToStr), valToStr(usage), + emptyStrIfNil(physU, valToStr), string(unit), timestampToString(pSrv.ScrapedAt), ) } else { projectNameOrID := p.UUID diff --git a/vendor/github.com/sapcc/go-api-declarations/limes/resources/input.go b/vendor/github.com/sapcc/go-api-declarations/limes/resources/input.go deleted file mode 100644 index 45fc1200..00000000 --- a/vendor/github.com/sapcc/go-api-declarations/limes/resources/input.go +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* -* -* Copyright 2017 SAP SE -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You should have received a copy of the License along with this -* program. If not, you may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*******************************************************************************/ - -package limesresources - -import ( - "encoding/json" - "sort" - - "github.com/sapcc/go-api-declarations/limes" -) - -// QuotaRequest contains new quota values for resources in multiple services. -// This type is used to serialize JSON request bodies in PUT requests on domains and projects. -type QuotaRequest map[limes.ServiceType]ServiceQuotaRequest - -// ServiceQuotaRequest contains new quota values for resources in a single service. -// This type appears in type QuotaRequest. -type ServiceQuotaRequest map[ResourceName]ResourceQuotaRequest - -// ResourceQuotaRequest contains new quota values for a single resource. -// This type appears in type ServiceQuotaRequest. -type ResourceQuotaRequest limes.ValueWithUnit - -type pureResourceQuotaRequest struct { - Name ResourceName `json:"name"` - Quota uint64 `json:"quota"` - Unit *limes.Unit `json:"unit"` -} - -type pureServiceQuotaRequest struct { - Type limes.ServiceType `json:"type"` - Resources []pureResourceQuotaRequest `json:"resources"` -} - -// MarshalJSON implements the json.Marshaler interface. -func (r QuotaRequest) MarshalJSON() ([]byte, error) { - list := []pureServiceQuotaRequest{} - for srvType, srvReq := range r { - sReq := pureServiceQuotaRequest{ - Type: srvType, - Resources: []pureResourceQuotaRequest{}, - } - - for resName, resReq := range srvReq { - unit := resReq.Unit - sReq.Resources = append(sReq.Resources, pureResourceQuotaRequest{ - Name: resName, - Quota: resReq.Value, - Unit: &unit, - }) - } - - // ensure test reproducibility - sort.Slice(sReq.Resources, func(i, j int) bool { - return sReq.Resources[i].Name < sReq.Resources[j].Name - }) - list = append(list, sReq) - } - - // ensure test reproducibility - sort.Slice(list, func(i, j int) bool { - return list[i].Type < list[j].Type - }) - - return json.Marshal(list) -} - -// UnmarshalJSON implements the json.Unmarshaler interface. -func (r *QuotaRequest) UnmarshalJSON(input []byte) error { - var data []pureServiceQuotaRequest - err := json.Unmarshal(input, &data) - if err != nil { - return err - } - - // remove existing content - for key := range *r { - delete(*r, key) - } - if *r == nil { - *r = make(QuotaRequest, len(data)) - } - - // add new content - for _, sReq := range data { - srvReq := make(ServiceQuotaRequest, len(sReq.Resources)) - - for _, rReq := range sReq.Resources { - unit := limes.UnitUnspecified - if rReq.Unit != nil { - unit = *rReq.Unit - } - srvReq[rReq.Name] = ResourceQuotaRequest{ - Value: rReq.Quota, - Unit: unit, - } - } - (*r)[sReq.Type] = srvReq - } - return nil -} diff --git a/vendor/github.com/sapcc/go-api-declarations/limes/resources/metadata.go b/vendor/github.com/sapcc/go-api-declarations/limes/resources/metadata.go index 923d14d3..6462bfbf 100644 --- a/vendor/github.com/sapcc/go-api-declarations/limes/resources/metadata.go +++ b/vendor/github.com/sapcc/go-api-declarations/limes/resources/metadata.go @@ -20,9 +20,6 @@ package limesresources import ( - "fmt" - "math" - "github.com/sapcc/go-api-declarations/limes" ) @@ -39,10 +36,6 @@ type ResourceInfo struct { // service into subgroups. If it is used, it should be set on all // ResourceInfos reported by the same QuotaPlugin. Category string `json:"category,omitempty"` - // If AutoApproveInitialQuota is non-zero, when a new project is scraped for - // the first time, a backend quota equal to this value will be approved - // automatically (i.e. Quota will be set equal to BackendQuota). - AutoApproveInitialQuota uint64 `json:"-"` // If NoQuota is true, quota is not tracked at all for this resource. The // resource will only report usage. This field is not shown in API responses. // Check `res.Quota == nil` instead. @@ -53,30 +46,6 @@ type ResourceInfo struct { ContainedIn ResourceName `json:"contained_in,omitempty"` } -// BurstingMultiplier is a multiplier for quota bursting. -type BurstingMultiplier float64 - -// ApplyTo returns the bursted backend quota for the given approved quota. -func (m BurstingMultiplier) ApplyTo(quota uint64, qdModel QuotaDistributionModel) uint64 { - switch qdModel { - case AutogrowQuotaDistribution: - return quota - case HierarchicalQuotaDistribution: - return uint64(math.Floor((1 + float64(m)) * float64(quota))) - default: - panic(fmt.Sprintf("unknown quota distribution model: %q", string(qdModel))) - } -} - -// ScalingBehavior appears in type DomainResourceReport and type -// ProjectResourceReport and describes the scaling behavior of a single -// resource. -type ScalingBehavior struct { - ScalesWithResourceName ResourceName `json:"resource_name"` - ScalesWithServiceType limes.ServiceType `json:"service_type"` - ScalingFactor float64 `json:"factor"` -} - // QuotaDistributionModel is an enum. type QuotaDistributionModel string diff --git a/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_cluster.go b/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_cluster.go index 6972a45b..62d2cd6e 100644 --- a/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_cluster.go +++ b/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_cluster.go @@ -58,7 +58,6 @@ type ClusterResourceReport struct { CapacityPerAZ ClusterAvailabilityZoneReports `json:"per_availability_zone,omitempty"` DomainsQuota *uint64 `json:"domains_quota,omitempty"` Usage uint64 `json:"usage"` - BurstUsage uint64 `json:"burst_usage,omitempty"` PhysicalUsage *uint64 `json:"physical_usage,omitempty"` Subcapacities json.RawMessage `json:"subcapacities,omitempty"` } @@ -92,6 +91,9 @@ type ClusterAZResourceReport struct { UnusedCommitments uint64 `json:"unused_commitments,omitempty"` PendingCommitments map[string]uint64 `json:"pending_commitments,omitempty"` PlannedCommitments map[string]uint64 `json:"planned_commitments,omitempty"` + // UncommittedUsage can also be derived as Usage - (Committed.Values().Sum() - UnusedCommitments), + // so this is only reported for convenience purposes. + UncommittedUsage uint64 `json:"uncommitted_usage,omitempty"` // PhysicalUsage is collected per project and then aggregated, same as ProjectsUsage. PhysicalUsage *uint64 `json:"physical_usage,omitempty"` Subcapacities json.RawMessage `json:"subcapacities,omitempty"` diff --git a/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_domain.go b/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_domain.go index eeab566e..f342c748 100644 --- a/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_domain.go +++ b/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_domain.go @@ -49,14 +49,9 @@ type DomainResourceReport struct { DomainQuota *uint64 `json:"quota,omitempty"` ProjectsQuota *uint64 `json:"projects_quota,omitempty"` Usage uint64 `json:"usage"` - BurstUsage uint64 `json:"burst_usage,omitempty"` PhysicalUsage *uint64 `json:"physical_usage,omitempty"` BackendQuota *uint64 `json:"backend_quota,omitempty"` InfiniteBackendQuota *bool `json:"infinite_backend_quota,omitempty"` - Scaling *ScalingBehavior `json:"scales_with,omitempty"` - // Annotations may contain arbitrary metadata that was configured for this - // resource in this scope by Limes' operator. - Annotations map[string]any `json:"annotations,omitempty"` } // DomainAZResourceReport is a substructure of DomainResourceReport containing @@ -73,6 +68,9 @@ type DomainAZResourceReport struct { UnusedCommitments uint64 `json:"unused_commitments,omitempty"` PendingCommitments map[string]uint64 `json:"pending_commitments,omitempty"` PlannedCommitments map[string]uint64 `json:"planned_commitments,omitempty"` + // UncommittedUsage can also be derived as Usage - (Committed.Values().Sum() - UnusedCommitments), + // so this is only reported for convenience purposes. + UncommittedUsage uint64 `json:"uncommitted_usage,omitempty"` } // DomainServiceReports provides fast lookup of services using a map, but serializes diff --git a/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_project.go b/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_project.go index 5dfb27fb..6a437d5c 100644 --- a/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_project.go +++ b/vendor/github.com/sapcc/go-api-declarations/limes/resources/report_project.go @@ -28,18 +28,9 @@ import ( // ProjectReport contains all data about resource usage in a project. type ProjectReport struct { limes.ProjectInfo - Bursting *ProjectBurstingInfo `json:"bursting,omitempty"` Services ProjectServiceReports `json:"services"` } -// ProjectBurstingInfo is a substructure of ProjectReport containing information about -// quota bursting. (It is omitted if bursting is not supported for the project's -// cluster.) -type ProjectBurstingInfo struct { - Enabled bool `json:"enabled"` - Multiplier BurstingMultiplier `json:"multiplier"` -} - // ProjectServiceReport is a substructure of ProjectReport containing data for // a single backend service. type ProjectServiceReport struct { @@ -61,14 +52,9 @@ type ProjectResourceReport struct { UsableQuota *uint64 `json:"usable_quota,omitempty"` MaxQuota *uint64 `json:"max_quota,omitempty"` // refers to max_quota constraint maintained via API Usage uint64 `json:"usage"` - BurstUsage uint64 `json:"burst_usage,omitempty"` PhysicalUsage *uint64 `json:"physical_usage,omitempty"` BackendQuota *int64 `json:"backend_quota,omitempty"` Subresources json.RawMessage `json:"subresources,omitempty"` - Scaling *ScalingBehavior `json:"scales_with,omitempty"` - // Annotations may contain arbitrary metadata that was configured for this - // resource in this scope by Limes' operator. - Annotations map[string]any `json:"annotations,omitempty"` } // ProjectAZResourceReport is a substructure of ProjectResourceReport containing diff --git a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/requests.go b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/requests.go index 78cd7f3b..6269e87e 100644 --- a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/requests.go +++ b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/requests.go @@ -16,8 +16,6 @@ package domains import ( - "net/http" - "github.com/gophercloud/gophercloud" "github.com/sapcc/go-api-declarations/limes" limesresources "github.com/sapcc/go-api-declarations/limes/resources" @@ -64,7 +62,7 @@ func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) (r CommonResult) { url += q } - resp, err := c.Get(url, &r.Body, &gophercloud.RequestOpts{ //nolint:bodyclose // already closed by gophercloud + resp, err := c.Get(url, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: headers, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) @@ -112,50 +110,9 @@ func Get(c *gophercloud.ServiceClient, domainID string, opts GetOptsBuilder) (r url += q } - resp, err := c.Get(url, &r.Body, &gophercloud.RequestOpts{ //nolint:bodyclose // already closed by gophercloud + resp, err := c.Get(url, &r.Body, &gophercloud.RequestOpts{ MoreHeaders: headers, }) _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) return } - -// UpdateOptsBuilder allows extensions to add additional parameters to the Update request. -type UpdateOptsBuilder interface { - ToDomainUpdateMap() (map[string]string, map[string]interface{}, error) -} - -// UpdateOpts contains parameters to update a domain. -type UpdateOpts struct { - Services limesresources.QuotaRequest `json:"services"` -} - -// ToDomainUpdateMap formats a UpdateOpts into a map of headers and a request body. -func (opts UpdateOpts) ToDomainUpdateMap() (headers map[string]string, requestBody map[string]interface{}, err error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, nil, err - } - - b, err := gophercloud.BuildRequestBody(opts, "domain") - if err != nil { - return nil, nil, err - } - - return h, b, nil -} - -// Update modifies the attributes of a domain. -func Update(c *gophercloud.ServiceClient, domainID string, opts UpdateOptsBuilder) (r UpdateResult) { - url := updateURL(c, domainID) - h, b, err := opts.ToDomainUpdateMap() - if err != nil { - r.Err = err - return - } - resp, err := c.Put(url, b, nil, &gophercloud.RequestOpts{ //nolint:bodyclose // already closed by gophercloud - OkCodes: []int{http.StatusAccepted}, - MoreHeaders: h, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - return -} diff --git a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/results.go b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/results.go index 1d0eb4bd..7dc30e43 100644 --- a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/results.go +++ b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/results.go @@ -25,12 +25,6 @@ type CommonResult struct { gophercloud.Result } -// UpdateResult is the result of an Update operation. Call its appropriate -// ExtractErr method to extract the error from the result. -type UpdateResult struct { - gophercloud.ErrResult -} - // ExtractDomains interprets a CommonResult as a slice of Domains. func (r CommonResult) ExtractDomains() ([]limesresources.DomainReport, error) { var s struct { diff --git a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/urls.go b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/urls.go index 97867cb1..9152b4d9 100644 --- a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/urls.go +++ b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/domains/urls.go @@ -23,7 +23,3 @@ func listURL(client *gophercloud.ServiceClient) string { func getURL(client *gophercloud.ServiceClient, domainID string) string { return client.ServiceURL("domains", domainID) } - -func updateURL(client *gophercloud.ServiceClient, domainID string) string { - return client.ServiceURL("domains", domainID) -} diff --git a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/requests.go b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/requests.go index 463a86a6..c2e0aaa3 100644 --- a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/requests.go +++ b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/requests.go @@ -15,7 +15,6 @@ package projects import ( - "io" "net/http" "github.com/gophercloud/gophercloud" @@ -121,54 +120,6 @@ func Get(c *gophercloud.ServiceClient, domainID, projectID string, opts GetOptsB return } -// UpdateOptsBuilder allows extensions to add additional parameters to the Update request. -type UpdateOptsBuilder interface { - ToProjectUpdateMap() (map[string]string, map[string]interface{}, error) -} - -// UpdateOpts contains parameters to update a project. -type UpdateOpts struct { - Services limesresources.QuotaRequest `json:"services"` - Bursting *limesresources.ProjectBurstingInfo `json:"bursting,omitempty"` -} - -// ToProjectUpdateMap formats a UpdateOpts into a map of headers and a request body. -func (opts UpdateOpts) ToProjectUpdateMap() (headers map[string]string, requestBody map[string]interface{}, err error) { - h, err := gophercloud.BuildHeaders(opts) - if err != nil { - return nil, nil, err - } - - b, err := gophercloud.BuildRequestBody(opts, "project") - if err != nil { - return nil, nil, err - } - - return h, b, nil -} - -// Update modifies the attributes of a project and returns the response body which contains non-fatal error messages. -func Update(c *gophercloud.ServiceClient, domainID, projectID string, opts UpdateOptsBuilder) (r UpdateResult) { - url := updateURL(c, domainID, projectID) - h, b, err := opts.ToProjectUpdateMap() - if err != nil { - r.Err = err - return - } - resp, err := c.Put(url, b, nil, &gophercloud.RequestOpts{ - OkCodes: []int{http.StatusAccepted}, - MoreHeaders: h, - KeepResponseBody: true, - }) - _, r.Header, r.Err = gophercloud.ParseResponse(resp, err) - if r.Err != nil { - return - } - defer resp.Body.Close() - r.Body, r.Err = io.ReadAll(resp.Body) - return -} - // Sync schedules a sync task that pulls a project's data from the backing services // into Limes' local database. func Sync(c *gophercloud.ServiceClient, domainID, projectID string) (r SyncResult) { diff --git a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/results.go b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/results.go index 72fee817..b79792a8 100644 --- a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/results.go +++ b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/results.go @@ -25,18 +25,6 @@ type CommonResult struct { gophercloud.Result } -// UpdateResult is the result of an Update operation. Call its appropriate -// Extract method to extract the error and the warning body from the result. -type UpdateResult struct { - gophercloud.Result - Body []byte -} - -// Extract interprets a UpdateResult as an update warning body and error -func (r UpdateResult) Extract() ([]byte, error) { - return r.Body, r.Err -} - // SyncResult is the result of an Sync operation. Call its appropriate // ExtractErr method to extract the error from the result. type SyncResult struct { diff --git a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/urls.go b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/urls.go index 9cdc6aad..12157600 100644 --- a/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/urls.go +++ b/vendor/github.com/sapcc/gophercloud-sapcc/resources/v1/projects/urls.go @@ -24,10 +24,6 @@ func getURL(client *gophercloud.ServiceClient, domainID, projectID string) strin return client.ServiceURL("domains", domainID, "projects", projectID) } -func updateURL(client *gophercloud.ServiceClient, domainID, projectID string) string { - return client.ServiceURL("domains", domainID, "projects", projectID) -} - func syncURL(client *gophercloud.ServiceClient, domainID, projectID string) string { return client.ServiceURL("domains", domainID, "projects", projectID, "sync") } diff --git a/vendor/modules.txt b/vendor/modules.txt index 2603f98a..98a39fd9 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -34,19 +34,19 @@ github.com/mitchellh/go-homedir # github.com/olekukonko/tablewriter v0.0.5 ## explicit; go 1.12 github.com/olekukonko/tablewriter -# github.com/sapcc/go-api-declarations v1.11.0 +# github.com/sapcc/go-api-declarations v1.11.2 ## explicit; go 1.21 github.com/sapcc/go-api-declarations/bininfo github.com/sapcc/go-api-declarations/internal/marshal github.com/sapcc/go-api-declarations/limes github.com/sapcc/go-api-declarations/limes/rates github.com/sapcc/go-api-declarations/limes/resources -# github.com/sapcc/go-bits v0.0.0-20240429130232-fdc0102c61a4 +# github.com/sapcc/go-bits v0.0.0-20240516084938-1c041b7a84ce ## explicit; go 1.22 github.com/sapcc/go-bits/logg github.com/sapcc/go-bits/osext github.com/sapcc/go-bits/secrets -# github.com/sapcc/gophercloud-sapcc v0.0.0-20240429130228-bc9d8c12dd20 +# github.com/sapcc/gophercloud-sapcc v0.0.0-20240510132707-01d47d03e5d9 ## explicit; go 1.21 github.com/sapcc/gophercloud-sapcc/clients github.com/sapcc/gophercloud-sapcc/rates/v1/clusters