Files
Thibault VINCENT b4f3f84086 feat!: rewrite from scratch with new architecture and toolchain
Complete rewrite of the codebase, the build pipeline, the dev loop,
and the release pipeline.

For the exporter itself, refer to the updated README and Helm chart
documentation to discover the new functionality and assess the impact
of the breaking changes on your existing setup.

Build & release:
- QA/CI pipelines now run through a Dagger Module, wrapped by
  Taskfile.yml for the developer interface.
- Releases run through GoReleaser: cross-compiled binaries × OS/arch,
  archives, checksums, multi-arch container images (busybox + scratch
  variants on linux/amd64,arm64,riscv64), pushed to ghcr/quay/docker.io.
- Everything is cosign-signed (binaries, images, Helm chart). Image
  CycloneDX SBOMs are attached as cosign attestations. SLSA-3
  provenance is attached to every GitHub Release.
- The Helm chart is published as a cosign-signed OCI artifact.
- Versioning and changelog are automated by release-please from
  Conventional Commits.

Dev experience:
- Local loop driven by Tilt + k3d + Dagger; one command brings up an
  exporter with seeded fixtures and a Prometheus scraping it.
- End-to-end tests run on a throwaway k3d cluster against the real
  rendered chart.

BREAKING CHANGE: the Helm chart is now published exclusively as an OCI
artifact at oci://quay.io/enix/charts/x509-certificate-exporter. The
legacy Helm repository at https://charts.enix.io is no longer updated;
users must switch to the OCI reference (Helm 3.8+ required).
Installation: `helm install x509-certificate-exporter
oci://quay.io/enix/charts/x509-certificate-exporter --version <vX.Y.Z>`.
BREAKING CHANGE: the Helm chart's values schema may diverge from v3 in
edge cases despite a best-effort to preserve backwards compatibility.
Review your existing values against the updated chart/values.yaml
before upgrading. A JSON schema (chart/values.schema.json) is shipped
with the chart so `helm install` / `helm upgrade` will reject any
values that no longer match the expected shape, surfacing regressions
early instead of at runtime.
BREAKING CHANGE: Alpine-based container images are no longer published.
The release pipeline now ships only the `busybox` and `scratch` variants
on linux/amd64,arm64,riscv64. Users pulling `*-alpine` tags must switch
to one of the new variants — `busybox` is the closest functional
replacement (still has a shell), `scratch` is the minimal distroless
option.
2026-04-30 20:35:54 +02:00

72 lines
1.8 KiB
Go

// Package log centralises slog initialisation and a few helpers used to
// instrument network-bound operations.
//
// Loggers are explicitly injected; the default logger is only set in
// main.go for the rare site where injection is not practical.
package log
import (
"context"
"io"
"log/slog"
"os"
"strings"
"time"
)
// Format selects the handler.
type Format int
const (
FormatText Format = iota
FormatJSON
)
// New constructs a new slog.Logger writing to out.
func New(out io.Writer, level slog.Level, format Format) *slog.Logger {
if out == nil {
out = os.Stderr
}
opts := &slog.HandlerOptions{Level: level}
switch format {
case FormatJSON:
return slog.New(slog.NewJSONHandler(out, opts))
default:
return slog.New(slog.NewTextHandler(out, opts))
}
}
// ParseLevel turns "debug"/"info"/"warn"/"error" into a slog.Level.
func ParseLevel(s string) (slog.Level, error) {
var lvl slog.Level
if err := lvl.UnmarshalText([]byte(strings.ToLower(s))); err != nil {
return slog.LevelInfo, err
}
return lvl, nil
}
// ParseFormat turns "text"/"json" into a Format.
func ParseFormat(s string) Format {
if strings.EqualFold(s, "json") {
return FormatJSON
}
return FormatText
}
// Timed runs fn and logs its duration at debug level. The returned error is
// fn's. If logger is nil this is just fn().
func Timed(ctx context.Context, logger *slog.Logger, msg string, fn func(context.Context) error, attrs ...slog.Attr) error {
if logger == nil || !logger.Enabled(ctx, slog.LevelDebug) {
return fn(ctx)
}
start := time.Now()
err := fn(ctx)
dur := time.Since(start)
all := append([]slog.Attr{slog.Int64("duration_ms", dur.Milliseconds())}, attrs...)
if err != nil {
all = append(all, slog.String("error", err.Error()))
}
logger.LogAttrs(ctx, slog.LevelDebug, msg, all...)
return err
}