Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSandro2000 committed Aug 2, 2023
1 parent e7f5789 commit 73b163b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/api/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (p *v1Provider) FindDomainFromRequest(w http.ResponseWriter, r *http.Reques
var domain db.Domain
err := p.DB.SelectOne(&domain, `SELECT * FROM domains WHERE uuid = $1`, domainUUID)
switch {
case err == sql.ErrNoRows:
case errors.Is(err, sql.ErrNoRows):
http.Error(w, "no such domain (if it was just created, try to POST /domains/discover)", http.StatusNotFound)
return nil
case respondwith.ErrorText(w, err):
Expand Down Expand Up @@ -241,7 +241,7 @@ func (p *v1Provider) FindProjectFromRequestIfExists(w http.ResponseWriter, r *ht
project = &db.Project{}
err := p.DB.SelectOne(project, `SELECT * FROM projects WHERE uuid = $1`, projectUUID)
switch {
case err == sql.ErrNoRows:
case errors.Is(err, sql.ErrNoRows):
return nil, true
case err == nil && domain.ID != project.DomainID:
http.Error(w, "no such project", http.StatusNotFound)
Expand Down
1 change: 1 addition & 0 deletions internal/api/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (p *v1Provider) putOrSimulatePutProjectQuotas(w http.ResponseWriter, r *htt
//validate inputs (within the DB transaction, to ensure that we do not apply
//inconsistent values later)
err := updater.ValidateInput(serviceQuotas, dbi)
//nolint:errorlint // not applicable
if _, ok := err.(MissingProjectReportError); ok {
//MissingProjectReportError indicates that the project is new and initial
//scraping is not yet done -> ask the user to wait until that's done, with
Expand Down
1 change: 1 addition & 0 deletions internal/api/rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ func (p *v1Provider) putOrSimulatePutProjectRates(w http.ResponseWriter, r *http
//validate inputs (within the DB transaction, to ensure that we do not apply
//inconsistent values later)
err := updater.ValidateInput(parseTarget.Project.Services, dbi)
//nolint:errorlint // not applicable
if _, ok := err.(MissingProjectReportError); ok {
//MissingProjectReportError indicates that the project is new and initial
//scraping is not yet done -> ask the user to wait until that's done, with
Expand Down
3 changes: 2 additions & 1 deletion internal/collector/ratescrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package collector

import (
"database/sql"
"errors"
"fmt"
"math/big"
"time"
Expand Down Expand Up @@ -83,7 +84,7 @@ func (c *Collector) ScrapeRates(serviceType string) {
Scan(&serviceID, &serviceRatesScrapedAt, &serviceRatesScrapeState, &project.Name, &project.UUID, &project.ParentUUID, &project.Domain.Name, &project.Domain.UUID)
if err != nil {
//ErrNoRows is okay; it just means that nothing needs scraping right now
if err != sql.ErrNoRows {
if !errors.Is(err, sql.ErrNoRows) {
c.LogError("cannot select next project for which to scrape %s rate data: %s", serviceType, err.Error())
}
if c.Once {
Expand Down
3 changes: 2 additions & 1 deletion internal/collector/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package collector
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"time"

Expand Down Expand Up @@ -85,7 +86,7 @@ func (c *Collector) Scrape(serviceType string) {
dbDomain, dbProject, srv, err := c.selectProjectForResourceScrape(serviceType, scrapeStartedAt)
if err != nil {
//ErrNoRows is okay; it just means that nothing needs scraping right now
if err != sql.ErrNoRows {
if !errors.Is(err, sql.ErrNoRows) {
c.LogError("cannot select next project for which to scrape %s resource data: %s", serviceType, err.Error())
}
if c.Once {
Expand Down
2 changes: 2 additions & 0 deletions internal/plugins/neutron.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func (p *neutronPlugin) Init(provider *gophercloud.ProviderClient, eo gopherclou
continue
}
_, err := extensions.Get(p.NeutronV2, resource.Extension).Extract()
//nolint:errorlint // not applicable
switch err.(type) {
case gophercloud.ErrDefault404:
p.hasExtension[resource.Extension] = false
Expand All @@ -173,6 +174,7 @@ func (p *neutronPlugin) Init(provider *gophercloud.ProviderClient, eo gopherclou

// Octavia supported?
p.OctaviaV2, err = openstack.NewLoadBalancerV2(provider, eo)
//nolint:errorlint // not applicable
switch err.(type) {
case *gophercloud.ErrEndpointNotFound:
p.hasOctavia = false
Expand Down
1 change: 1 addition & 0 deletions internal/plugins/nova.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ func (p *novaPlugin) findOSTypeForImage(imageID string) (string, error) {
err := images.Get(p.GlanceV2, imageID).ExtractInto(&result)
if err != nil {
//report a dummy value if image has been deleted...
//nolint:errorlint // not applicable
if _, ok := err.(gophercloud.ErrDefault404); ok {
return "image-deleted", nil
}
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ func findProjectForTesting(cluster *core.Cluster, projectUUID string) (core.Keys
func dumpGeneratedPrometheusMetrics() {
metricFamilies, err := prometheus.DefaultGatherer.Gather()
if err != nil {
//nolint:errorlint // not applicable
if merr, ok := err.(prometheus.MultiError); ok {
for _, err := range merr {
logg.Error("error while gathering Prometheus metrics: " + err.Error())
Expand Down

0 comments on commit 73b163b

Please sign in to comment.