Skip to content

Commit

Permalink
fix: Fix format strings
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpitman committed Jan 30, 2025
1 parent 795292d commit f26695c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/monaco/generate/deletefile/deletefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func createConfigAPIEntry(c config.Config, apis api.APIs, project project.Projec

nameOfRefCfg, err := refCfgNamParamVal.ResolveValue(parameter.ResolveContext{})
if err != nil {
log.Warn("Unable to create delete entry for %s: %v", err)
log.Warn("Unable to create delete entry for '%s': %v", c.Coordinate, err)
return persistence.DeleteEntry{}, err
}

Expand Down
5 changes: 3 additions & 2 deletions internal/throttle/throttle_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ package throttle

import (
"fmt"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log/field"
"time"

"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log/field"

"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/rand"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/timeutils"
Expand All @@ -34,7 +35,7 @@ func ThrottleCallAfterError(backoffMultiplier int, message string, a ...any) {
sleepDuration, humanReadableTimestamp := GenerateSleepDuration(backoffMultiplier, timelineProvider)
sleepDuration = ApplyMinMaxDefaults(sleepDuration)

log.Debug("simpleSleepRateLimitStrategy: %s, waiting %d seconds until %s to avoid Too Many Request errors", fmt.Sprintf(message, a...), sleepDuration.Seconds(), humanReadableTimestamp)
log.Debug("simpleSleepRateLimitStrategy: %s, waiting %f seconds until %s to avoid Too Many Request errors", fmt.Sprintf(message, a...), sleepDuration.Seconds(), humanReadableTimestamp)
timelineProvider.Sleep(sleepDuration)
log.Debug("simpleSleepRateLimitStrategy: Slept for %f seconds", sleepDuration.Seconds())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/dtclient/config_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ func (d *ConfigClient) findUnique(ctx context.Context, values []Value, payload [
}

if matchingObjectsFound > 1 {
log.WithCtxFields(ctx).Warn("Found %d configs with same name: %s. Please delete duplicates.", matchingObjectsFound)
log.WithCtxFields(ctx).Warn("Found %d configs with same name. Please delete duplicates.", matchingObjectsFound)
}

return objectId, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func deleteConfig(ctx context.Context, clients client.ClientSet, t string, entri
if clients.SegmentClient != nil {
return segment.Delete(ctx, clients.SegmentClient, entries)
}
log.WithCtxFields(ctx).WithFields(field.Type(t)).Warn("Skipped deletion of %d %s configuration(s) as API client was unavailable.", config.SegmentID, len(entries))
log.WithCtxFields(ctx).WithFields(field.Type(t)).Warn("Skipped deletion of %d Segment configuration(s) as API client was unavailable.", len(entries))
}
} else {
if clients.SettingsClient != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/delete/internal/automation/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"fmt"
"net/http"

"golang.org/x/net/context"

"github.com/dynatrace/dynatrace-configuration-as-code-core/api"
automationAPI "github.com/dynatrace/dynatrace-configuration-as-code-core/api/clients/automation"
"github.com/dynatrace/dynatrace-configuration-as-code-core/clients/automation"
Expand All @@ -30,7 +32,6 @@ import (
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log/field"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/delete/pointer"
"golang.org/x/net/context"
)

type client interface {
Expand Down Expand Up @@ -102,7 +103,7 @@ func DeleteAll(ctx context.Context, c client) error {

t, err := automationutils.ClientResourceTypeFromConfigType(resource)
if err != nil {
logger.Error("Failed to delete Automation objects of type %q: %v", err)
logger.Error("Failed to delete Automation objects of type '%s': %v", resource, err)
errs++
continue
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/delete/internal/bucket/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import (
"fmt"
"net/http"

"golang.org/x/net/context"

"github.com/dynatrace/dynatrace-configuration-as-code-core/api"
"github.com/dynatrace/dynatrace-configuration-as-code-core/clients/buckets"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/buckettools"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/idutils"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log/field"
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/delete/pointer"
"golang.org/x/net/context"
)

type client interface {
Expand All @@ -51,17 +52,17 @@ func Delete(ctx context.Context, c client, entries []pointer.DeletePointer) erro
bucketName = idutils.GenerateBucketName(e.AsCoordinate())
}

logger.Debug("Deleting bucket: %s.", e, bucketName)
logger.Debug("Deleting bucket: %s", bucketName)
_, err := c.Delete(ctx, bucketName)
if err != nil {
var apiErr api.APIError
if errors.As(err, &apiErr) {
if apiErr.StatusCode != http.StatusNotFound {
logger.WithFields(field.Error(err)).Error("Failed to delete Grail Bucket configuration - rejected by API: %v", e, bucketName, err)
logger.WithFields(field.Error(err)).Error("Failed to delete Grail Bucket configuration '%s': %v", bucketName, err)
deleteErrs++
}
} else {
logger.WithFields(field.Error(err)).Error("Failed to delete Grail Bucket configuration - network error: %v", e, bucketName, err)
logger.WithFields(field.Error(err)).Error("Failed to delete Grail Bucket configuration '%s': %v", bucketName, err)
deleteErrs++
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/persistence/account/writer/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,31 @@ func Write(writerContext Context, resources account.Resources) error {
policies := toPersistencePolicies(resources.Policies)
if err := persistToFile(persistence.File{Policies: policies}, writerContext.Fs, filepath.Join(projectFolder, "policies.yaml")); err != nil {
errOccurred = true
log.Error("Failed to persist policies: %w", err)
log.Error("Failed to persist policies: %v", err)
}
}

if len(resources.Groups) > 0 {
groups := toPersistenceGroups(resources.Groups)
if err := persistToFile(persistence.File{Groups: groups}, writerContext.Fs, filepath.Join(projectFolder, "groups.yaml")); err != nil {
errOccurred = true
log.Error("Failed to persist groups: %w", err)
log.Error("Failed to persist groups: %v", err)
}
}

if len(resources.Users) > 0 {
users := toPersistenceUsers(resources.Users)
if err := persistToFile(persistence.File{Users: users}, writerContext.Fs, filepath.Join(projectFolder, "users.yaml")); err != nil {
errOccurred = true
log.Error("Failed to persist users: %w", err)
log.Error("Failed to persist users: %v", err)
}
}

if featureflags.ServiceUsers.Enabled() && len(resources.ServiceUsers) > 0 {
serviceUsers := toPersistenceServiceUsers(resources.ServiceUsers)
if err := persistToFile(persistence.File{ServiceUsers: serviceUsers}, writerContext.Fs, filepath.Join(projectFolder, "service-users.yaml")); err != nil {
errOccurred = true
log.Error("Failed to persist service users: %w", err)
log.Error("Failed to persist service users: %v", err)
}
}

Expand Down

0 comments on commit f26695c

Please sign in to comment.