diff --git a/Dockerfile b/Dockerfile index 751e6a0b..96efc04b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,9 @@ FROM scratch ENV ZONEINFO zoneinfo.zip EXPOSE 1080 -ENV API_PORT 1080 -ENV API_CSP "default-src 'self'; base-uri 'self'; script-src 'self' 'unsafe-inline' unpkg.com/swagger-ui-dist@3/; style-src 'self' 'unsafe-inline' unpkg.com/swagger-ui-dist@3/; img-src 'self' data:" -ENV API_SWAGGER_TITLE ketchup +ENV KETCHUP_PORT 1080 +ENV KETCHUP_CSP "default-src 'self'; base-uri 'self'; script-src 'self' 'unsafe-inline' unpkg.com/swagger-ui-dist@3/; style-src 'self' 'unsafe-inline' unpkg.com/swagger-ui-dist@3/; img-src 'self' data:" +ENV KETCHUP_SWAGGER_TITLE ketchup HEALTHCHECK --retries=5 CMD [ "/ketchup", "-url", "http://localhost:1080/health" ] ENTRYPOINT [ "/ketchup" ] diff --git a/pkg/github/github.go b/pkg/github/github.go index c7e74eb8..8a6004fe 100644 --- a/pkg/github/github.go +++ b/pkg/github/github.go @@ -17,8 +17,9 @@ const ( // Release describes a Github Release type Release struct { - TagName string `json:"tag_name"` - Body string `json:"body"` + Repository string `json:"repository"` + TagName string `json:"tag_name"` + Body string `json:"body"` } // App of package @@ -71,5 +72,7 @@ func (a app) LastRelease(repository string) (Release, error) { return release, fmt.Errorf("unable to parse release body for %s: %s", repository, err) } + release.Repository = repository + return release, err } diff --git a/pkg/ketchup/ketchup.go b/pkg/ketchup/ketchup.go index 3da89d57..609a8fb3 100644 --- a/pkg/ketchup/ketchup.go +++ b/pkg/ketchup/ketchup.go @@ -78,7 +78,7 @@ func (a app) checkUpdates(_ time.Time) error { } if release.TagName != target.LatestVersion { - logger.Info("New version available for %s", target.Repository) + logger.Info("New version available for %s: %s", target.Repository, release.TagName) target.LatestVersion = release.TagName newReleases = append(newReleases, release) @@ -92,7 +92,9 @@ func (a app) checkUpdates(_ time.Time) error { } if len(newReleases) > 0 { - if err := mailer.NewEmail(a.mailerApp).Template("ketchup").From("ketchup@vibioh.fr").As("Ketchup").WithSubject("Ketchup - New version available").To(a.emailTo).Data(newReleases).Send(context.Background()); err != nil { + if a.mailerApp == nil || !a.mailerApp.Enabled() { + logger.Warn("mailer is not configured") + } else if err := mailer.NewEmail(a.mailerApp).Template("ketchup").From("ketchup@vibioh.fr").As("Ketchup").WithSubject("Ketchup - New update").To(a.emailTo).Data(newReleases).Send(context.Background()); err != nil { logger.Error("unable to send email to %s: %s", a.emailTo, err) } }