Skip to content

config: move Secret into its own package - #1024

Merged
SuperQ merged 2 commits into
prometheus:mainfrom
mrueg:config-secret-package
Nov 10, 2026
Merged

SuperQ merged 2 commits into
prometheus:mainfrom
mrueg:config-secret-package

Conversation

@mrueg

@mrueg mrueg commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Importing github.com/prometheus/common/config just to use Secret pulls in all the dependencies of the HTTP client configuration: client_golang, client_model, procfs, protobuf, oauth2, jwt, uuid, go-conntrack, backoff, x/net, x/text, … Go links whole packages, so this happens even though Secret itself only needs encoding/json.

exporter-toolkit's web package is affected: it uses only config.Secret (plus JoinDir, which it can inline). Every exporter importing it inherits those dependencies.

Changes

  • New package config/secret, which contains Secret and its marshal/unmarshal methods and depends only on the standard library.
  • config.Secret becomes a type alias of secret.Secret, so existing code (including config.Secret("...") conversions and reflection) is unaffected.
  • config.MarshalSecretValue remains the single switch for exposing secret values. Go can't alias a variable, so secret reads the switch through a pointer in config/internal/secretvalue, and config points that pointer at MarshalSecretValue in init. When config isn't linked at all, secrets are always redacted.

Effect

I tested this with exporter-toolkit switched to config/secret (via a local replace). The modules linked by its web package went from 23 to 10, and its tests pass. I'll send the exporter-toolkit change once this is released.

🤖 Generated with Claude Code

Importing package config only to use Secret pulls in the dependencies of
the HTTP client configuration (client_golang, protobuf, oauth2, jwt,
uuid, go-conntrack, ...). Libraries such as exporter-toolkit use nothing
but Secret from it.

Move Secret into config/secret, which only depends on the standard
library, and keep config.Secret as a type alias so existing code is
unaffected.

config.MarshalSecretValue stays the switch for exposing secret values.
Since a variable can't be aliased, the secret package reads it through a
pointer in an internal package that config points at its own variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Manuel Rüger <manuel@rueg.eu>

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@SuperQ
SuperQ merged commit e8b548e into prometheus:main Nov 10, 2026
8 checks passed
@SuperQ SuperQ mentioned this pull request Nov 11, 2026
SuperQ added a commit that referenced this pull request Nov 12, 2026
What's Changed
* expfmt: add ABNF parser for OpenMetrics 2.0 by @bwplotka in #1016
* build(deps): bump ossf/scorecard-action from 2.4.4 to 2.5.0 by @dependabot[bot] in #1032
* build(deps): bump actions/upload-artifact from 7.0.1 to 7.0.2 by @dependabot[bot] in #1033
* build(deps): bump golang.org/x/net from 0.61.0 to 0.62.0 in the golang-org-x group across 1 directory by @dependabot[bot] in #1030
* expfmt: bump go-abnf to v0.5.5 by @PerryLink in #1029
* config: move Secret into its own package by @mrueg in #1024
* build(deps): bump the codeql group with 4 updates by @dependabot[bot] in #1031
* version: fix Slog godoc example to compile by @sueun-dev in #935
* build(deps): bump go.yaml.in/yaml/v2 from 2.4.4 to 2.4.5 by @dependabot[bot] in #1043
* build(deps): bump golang.org/x/oauth2 from 0.37.0 to 0.38.0 in the golang-org-x group across 1 directory by @dependabot[bot] in #1042
* expfmt: support Prometheus text format 1.0.0 by @ArthurSens in #1035

New Contributors
* @PerryLink made their first contribution in #1029
* @sueun-dev made their first contribution in #935

**Full Changelog**: v0.73.1...v0.74.0

Signed-off-by: SuperQ <superq@gmail.com>
mrueg added a commit to mrueg/exporter-toolkit that referenced this pull request Nov 16, 2026
web only used Secret and JoinDir from that package, but importing it links
everything the HTTP client configuration needs, so every exporter using web
inherited client_golang, oauth2, jwt, protobuf and more.

Bump prometheus/common to the merge commit of prometheus/common#1024, which
moved Secret into config/secret, and use that package. Inline JoinDir, the
only other use. config.Secret is an alias of secret.Secret, so the exported
fields stay compatible.

The modules linked by web go from 25 to 10.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants