configurationhttp

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package configurationhttp is the configuration module's HTTP adapter: the artifactory spec's system operations (version, license, service id, readiness, liveness and the reverse proxy configuration), the probes and telemetry sinks the router mounts beside them, and the YAML descriptor PATCH.

Role

configuration module, HTTP adapter layer. The composition root mounts what this package exports; nothing else in the module serves HTTP. It applies the descriptor only through configuration/api, imports no server or router package and no artifacts or access package, and takes the error profile of each path from the request, where the router puts it.

Inputs

  • Driving: the router, which embeds SystemAPI in the artifactory spec's strict server beside the generated stubs, mounts the probe, sink, router health and descriptor handlers, and installs the error profile rules the handlers write their errors with (httpkit.ErrorProfile).
  • Deps, from the composition root: the instance store, the binary store, the compatibility version and revision, the base URL, configapi.Settings, the configuration API and the logger.

Outputs

  • SystemAPI, built by New over Deps: the system operations; the probe handlers ArtifactoryPing, AccessPing, AccessReadiness, RouterReadiness and RouterHealth; and PatchConfiguration.
  • Liveness, SinkHandler, and SinkBodyLimit, the bound of the sinks' bodies.
  • The router's contributions: PublicRoutes, the system half of the routes that answer without credentials, and HealthRequest, the probes that the request limits and the API restriction check let pass.

Invariants

  • The probe paths answer without credentials (PublicRoutes) and outside the request limits and API restrictions (HealthRequest), so that orchestrators and clients reach them before they authenticate and while the server is busy.
  • A failed probe names the part that failed and never the store's own error, which can carry a host, a user, a path or a bucket; the cause goes to the access log. The liveness probes probe no store.
  • The descriptor PATCH keeps its strict parse and answers 400 for an invalid descriptor (decision 0009).
  • Statuses, envelopes and error and log text stay byte-identical, because JFrog's clients and the operators' logs read them.

References

  • Decision 0009: docs/research/decisions/0009-configuration-as-code.md (the descriptor PATCH).
  • Decision 0016: docs/research/decisions/0016-observability-and-health.md, lines 24 to 37 (the probes and their answers).
  • Decision 0005: docs/research/decisions/0005-authentication-and-tokens.md (the compatibility version the version operation reports).
  • Research 10: docs/research/10-scope-and-tiers.md (what the server serves, with this package's system.go as evidence).
  • Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md ("Dependency rules": a module reaches another only through its api).
  • Target layout: docs/research/architecture-options/5-modular-monolith.md, lines 302 to 314 (configuration/adapters/http).
  • https://github.com/weaveplatform/artifactweave/issues/1081

Status

Implemented P0 to P2 as the server root's system handlers (version, license, service id, readiness and liveness), with the descriptor PATCH (P3), the reverse proxy configuration of the Docker access methods (pull request 241) and the probes and router health (issue 403) added later. P9d split them into the system partial (WEB-07) and moved them here (WEB-11).

Testing

The unit tests here call the handlers directly over in-memory stores, without the router. The route suite test/server/configuration drives the probes, the service id and the descriptor PATCH through the router, and the router's guards in app (its status, principal and ledger tables) reach the system operations there too.

Index

Constants

View Source
const SinkBodyLimit = 1 << 20

SinkBodyLimit bounds the telemetry sinks' bodies. The sinks answer without credentials, so without a bound anyone could hold a connection open for as long as they kept sending (#431). The reports the JFrog CLI and the Terraform providers post are well under a kilobyte; 1 MiB leaves ample room for a larger one without letting the read run on.

Variables

This section is empty.

Functions

func HealthRequest

func HealthRequest(r *http.Request) bool

HealthRequest reports whether r is a GET of one of Artifactory's, Access's or the router's probes. The router lets those pass every request limit and the API restriction check, so that a busy or restricted server still answers its health checks.

func Liveness

func Liveness(w http.ResponseWriter, _ *http.Request)

Liveness answers the router's and Access's liveness probes. They probe no store, for the reason GetSystemLiveness gives.

func PublicRoutes

func PublicRoutes() map[string]bool

PublicRoutes returns "METHOD path" of the system routes that answer without credentials while anonymous access is off (systemPublicRoutes), in a new map, which the router merges with the other modules' public routes.

func SinkHandler

func SinkHandler(w http.ResponseWriter, r *http.Request)

SinkHandler drains and discards telemetry posted by the JFrog CLI and the Terraform providers (usage reports, jfconnect metrics). It runs behind middleware.BodyLimit(SinkBodyLimit). Reading a body within the limit to EOF lets the connection be reused; a body without a declared length that runs past the limit stops the read there and answers 413, as middleware.BodyLimit answers a declared one, and the server then closes the connection rather than drain the rest.

Types

type Deps

type Deps struct {
	// Store holds the instance identity, which the probes read to show the
	// database answers and the service id reports. Nil leaves the probes
	// nothing to probe and answers the descriptor PATCH 501, as a router
	// built to test routing alone answers. The router's store is an
	// interface, so a nil one converts to a nil Store; a typed nil pointer
	// would not.
	Store instance.Store
	// Blobs is the hot binary store, which Artifactory's probes ask for one
	// blob; nil skips that probe.
	Blobs blob.Store
	// CompatVersion is the Artifactory version GetSystemVersion reports
	// (decision 0005).
	CompatVersion string
	// Revision is the build revision GetSystemVersion reports.
	Revision string
	// BaseURL is the configured base URL, whose host the reverse proxy
	// configuration names; empty means the base URL of each request.
	BaseURL string
	// Settings holds docker.subdomain_match, which picks the Docker access
	// method the reverse proxy configuration names.
	Settings configapi.Settings
	// Configuration parses and applies the YAML descriptor the PATCH sends.
	Configuration configapi.API
	// Logger receives the handlers' internal errors; nil means slog.Default.
	Logger *slog.Logger
}

Deps is what the system handlers need, which the composition root supplies.

type SystemAPI

type SystemAPI struct {
	// contains filtered or unexported fields
}

SystemAPI implements the artifactory spec's system operations (version, license, service id, readiness and liveness) and the reverse proxy configuration, and serves the probes, the telemetry sinks and the descriptor PATCH the router mounts beside them. The compatibility version drives client behaviour (decision 0005), so it is configuration, not the build version.

func New

func New(d Deps) *SystemAPI

New returns the system handlers over d. They remember the instance id the probes last read, so router health still names the services by it while the database is down.

func (SystemAPI) AccessPing

func (s SystemAPI) AccessPing() http.HandlerFunc

AccessPing returns the handler of GET /access/api/v1/system/ping, which probes the database alone.

func (SystemAPI) AccessReadiness

func (s SystemAPI) AccessReadiness() http.HandlerFunc

AccessReadiness returns the handler of GET /access/api/v1/system/readiness, which probes the database alone.

func (SystemAPI) ArtifactoryPing

func (s SystemAPI) ArtifactoryPing() http.HandlerFunc

ArtifactoryPing returns the handler of GET /artifactory/api/system/ping, which probes the database and the binary store.

func (SystemAPI) GetReverseProxyConfiguration

GetReverseProxyConfiguration answers administrators with the reverse proxy settings, and any other signed-in user with the Docker method and the ports (getreverseproxyconfiguration.md: "Non-admin users will get the proxy method and ports"). Until the settings can be stored (P12) it describes artifactweave itself, which is what the Docker access method needs (decision 0003): SUBDOMAIN when docker.subdomain_match is on and REPOPATHPREFIX otherwise, with serverName the base URL's host and, for subdomains, its wildcard.

func (SystemAPI) GetServiceId

GetServiceId answers administrators only, as documented (getserviceid-1.md), with the stored instance id. The token service derives its jfac@ issuer from the same record, so the jfrt@<id>:admin scope jf rt atc --grant-admin builds from this body names this instance.

func (SystemAPI) GetSystemLicense

GetSystemLicense answers administrators only, as documented (getlicenseinfo.json).

func (SystemAPI) GetSystemLiveness

GetSystemLiveness answers OK while the process serves requests. It probes neither store: an orchestrator restarts a container whose liveness fails, and a restart brings back no database or bucket.

func (SystemAPI) GetSystemReadiness

GetSystemReadiness answers OK while the database and the binary store answer, and 500 with the reason otherwise (getreadinessprobe.md: "Returns HTTP error code with reason if not working properly").

func (SystemAPI) GetSystemVersion

GetSystemVersion reports the compatibility version as Artifactory's version, with the build revision and no add-ons, in the vendor type when Accept names it (versionMediaType) and as JSON otherwise. The router decides who may call it: Artifactory requires a user (RTFACT-26414).

func (SystemAPI) PatchConfiguration

func (s SystemAPI) PatchConfiguration(w http.ResponseWriter, r *http.Request)

PatchConfiguration is PATCH /api/system/configuration: the YAML descriptor as a patch (decision 0009). It is hand-written because the body is YAML, which the generated strict servers do not decode.

func (SystemAPI) RouterHealth

func (s SystemAPI) RouterHealth(w http.ResponseWriter, r *http.Request)

RouterHealth answers the JFrog router's aggregate health document: 200 while both services are healthy, 503 otherwise. One process is the router and both services, so all three share a node. Access (jfac) needs the database; Artifactory (jfrt) needs the database and the binary store.

func (SystemAPI) RouterReadiness

func (s SystemAPI) RouterReadiness() http.HandlerFunc

RouterReadiness returns the handler of GET /router/api/v1/system/readiness. The router is ready when the services behind it are, so it probes what Artifactory needs, which covers what Access needs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL