Skip to content

Commit

Permalink
refactor: Code cleaning from audit
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Aug 14, 2022
1 parent 5eefc15 commit aae180e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ trim_trailing_whitespace = true

[{Makefile,*.go,go.mod}]
indent_style = tab

[*.py]
indent_size = 4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ A Docker image is available for `amd64`, `arm` and `arm64` platforms on Docker H

You can configure app by passing CLI args or environment variables (cf. [Usage](#usage) section). CLI override environment variables.

You'll find a Kubernetes exemple in the [`infra/`](infra/) folder, using my [`app chart`](https://github.com/ViBiOh/charts/tree/main/app)
You'll find a Kubernetes exemple in the [`infra/`](infra) folder, using my [`app chart`](https://github.com/ViBiOh/charts/tree/main/app)

## Endpoints

Expand Down
8 changes: 4 additions & 4 deletions pkg/notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,24 +253,24 @@ func (a App) sendNotification(ctx context.Context, template string, ketchupToNot
return nil
}

for user, releases := range ketchupToNotify {
logger.Info("Sending email to %s for %d releases", user.Email, len(releases))
for ketchupUser, releases := range ketchupToNotify {
logger.Info("Sending email to %s for %d releases", ketchupUser.Email, len(releases))

sort.Sort(model.ReleaseByKindAndName(releases))

payload := map[string]any{
"releases": releases,
}

mr := mailerModel.NewMailRequest().Template(template).From("[email protected]").As("Ketchup").To(user.Email).Data(payload)
mr := mailerModel.NewMailRequest().Template(template).From("[email protected]").As("Ketchup").To(ketchupUser.Email).Data(payload)
subject := fmt.Sprintf("Ketchup - %d new release", len(releases))
if len(releases) > 1 {
subject += "s"
}
mr = mr.WithSubject(subject)

if err := a.mailerApp.Send(ctx, mr); err != nil {
return fmt.Errorf("send email to %s: %s", user.Email, err)
return fmt.Errorf("send email to %s: %s", ketchupUser.Email, err)
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/provider/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ func (a App) LatestVersions(ctx context.Context, repository string, patterns []s
return nil, fmt.Errorf("compute image details: %s", err)
}

url := fmt.Sprintf("%s/v2/%s/tags/list", registry, repository)
tagsURL := fmt.Sprintf("%s/v2/%s/tags/list", registry, repository)

for len(url) != 0 {
req := request.Get(url)
for len(tagsURL) != 0 {
req := request.Get(tagsURL)

if len(auth) != 0 {
req = req.Header("Authorization", auth)
Expand All @@ -85,7 +85,7 @@ func (a App) LatestVersions(ctx context.Context, repository string, patterns []s
return nil, err
}

url = getNextURL(resp.Header, registry)
tagsURL = getNextURL(resp.Header, registry)
}

return versions, nil
Expand Down
1 change: 1 addition & 0 deletions pkg/semver/pattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Pattern struct {
// NewPattern creates new pattern instance
func NewPattern(name string, constraints ...constraint) Pattern {
return Pattern{
Name: name,
constraints: constraints,
}
}
Expand Down

0 comments on commit aae180e

Please sign in to comment.