CLI tools
The command-line tools provide terminal workflows for evaluating feature flags and for checking or converting flag configuration. The long-running relay proxy extends that command-line surface into a service that evaluates flags, serves configuration, publishes flag changes, validates proposed flag files, and exposes health and monitoring views. The command workflows are described in CLI evaluation, generation, and linting.
Command orchestration
The CLI is organized as a small command tree. The root selects one user goal and sends it to a focused workflow. The generate branch contains the manifest workflow so generated output can grow without changing the top-level command model.
The command tree connects user intent to shared flag services as follows:
flowchart TD
A[CLI root] --> B[evaluate]
A --> C[lint]
A --> D[generate]
D --> E[manifest]
B --> F[Source access and flag evaluation]
C --> G[Configuration validation]
E --> H[OpenFeature manifest creation]
References: cmd/…/main.go• L11-27 cmd/…/evaluate_cmd.go• L56-61 cmd/…/lint_cmd.go• L12-25 cmd/…/generate_cmd.go• L11-27
Command boundaries
Each command checks the inputs needed for its goal before it starts its main work. Evaluation prepares a source description. Linting and manifest generation load local configuration. This boundary lets each command report a useful result while keeping the shared flag rules consistent.
Evaluation also accepts repeated HTTP headers and PostgreSQL column mappings. Invalid entries are ignored while the remaining values form the source description. The --check-mode path stops after source validation and prints the source description without creating a retriever.
The CLI also has a container distribution. It exposes the same command interface and lets an engineer mount local configuration into the container when a workflow needs a file.
References: cmd/…/evaluate_cmd.go• L108-157 cmd/…/evaluate_cmd.go• L280-293 cmd/…/lint_cmd.go• L28-45 cmd/…/manifest.go• L19-35 cmd/…/DOCKERHUB.md• L18-24
Configuration source model
The evaluation workflow treats a flag source as a retriever. A retriever obtains flag configuration from a supported local or remote source. The CLI maps user input to one common source description, checks that description, and then selects the matching retriever.
Source selection
The --kind value selects the source family. Other inputs then describe that source. For example, --path points to a local file for a file source but can identify a remote file for a Git source. The model covers file, HTTP, GitHub, GitLab, Bitbucket, S3, Google Cloud Storage, Kubernetes ConfigMap, MongoDB, Redis, Azure Blob Storage, and PostgreSQL sources.
Source setup follows this order:
- The command maps its flags to the common source description.
- The description checks the source kind and required values.
- The retriever service creates the selected source handler.
- The evaluation workflow performs any required initialization before it reads flags.
References: cmd/…/evaluate_cmd.go• L112-157 cmdhelpers/…/retriever_conf.go• L21-109 cmdhelpers/…/retriever_init.go• L27-58 cmd/…/check-azure.json• L1-39 cmd/…/check-http.json• L1-47 cmd/…/check-postgres.json• L1-42
Local configuration loading
Linting and manifest generation use a shared loader for local flag configuration. The loader accepts a named file or searches common default locations when no file is named. It supports YAML, JSON, and TOML, then presents the result as the common flag configuration model.
References: cmdhelpers/…/read_config_file.go• L14-24 cmdhelpers/…/read_config_file.go• L36-54 cmdhelpers/…/read_config_file.go• L57-83 cmd/…/linter.go• L14-27
Evaluation and artifact workflows
The CLI exposes three outcomes from flag configuration: a runtime evaluation result, a configuration validity result, or an OpenFeature manifest. Evaluation reads flags through a retriever. Linting checks the configuration without evaluating flags. Manifest generation creates a document for OpenFeature tools.
Evaluation workflow
The evaluate workflow validates its source description, creates the selected retriever, and performs required initialization. It then starts flag evaluation with the requested context. An engineer can evaluate one named flag with --flag or evaluate all flags available from the loaded source.
The --ctx value is JSON. Its targetingKey identifies the evaluation subject for targeting rules. The command prints variation results as indented JSON. In --check-mode, it validates and prints the source description without creating a retriever or evaluating a flag.
References: cmd/…/evaluate_cmd.go• L146-157 cmd/…/evaluate_cmd.go• L235-315 cmd/…/evaluate.go• L22-107
Manifest workflow
The generate manifest workflow reads local flag configuration and produces an OpenFeature flag manifest. The artifact describes each included flag with its type, default value, and description. The destination is required because the workflow writes a JSON file for downstream OpenFeature tools.
Conversion warnings and errors remain part of the command output. A flag without usable variations or a default value can be left out of the artifact while the command reports why it was not included.
References: cmd/…/manifest_cmd.go• L13-44 cmd/…/manifest.go• L19-35 cmd/…/manifest.go• L42-75 cmd/…/flag_manifest.go• L9-27 cmdhelpers/…/generate_definition.go• L12-56
Lint workflow
The lint workflow loads one local YAML, JSON, or TOML file and applies the shared flag validation rules to every flag. It returns file-qualified errors when loading or validation fails. A valid file produces no validation errors and the command reports success.
The relay proxy uses the same flag rules through its authenticated validation endpoint. This gives a deployment or publishing workflow a way to check a proposed file without changing the configuration currently served by the proxy.
References: cmd/…/linter.go• L9-27 cmd/…/lint_cmd.go• L12-45 cmd/…/validate_flags.go• L46-69 cmd/…/validate_flags.go• L103-130
Relay proxy startup and monitoring
The relay proxy is the long-running command-line service that loads flag sets, exposes evaluation and administration APIs, and publishes service updates. Startup validates its configuration before it creates the API and stream services. It also connects the loaded flag sets to Prometheus monitoring so operators can see service health and the flags held by the proxy.
The startup and shutdown flow is:
sequenceDiagram
participant P as Relay proxy
participant C as Configuration
participant F as Flagset manager
participant M as Prometheus metrics
participant A as API and streams
P->>C: Load and validate configuration
P->>F: Create flagset manager
P->>M: Register loaded-flag collector
P->>A: Start API and stream services
A-->>P: Serve requests and updates
P->>A: Close streams and stop API
P->>F: Close flag sets and flush exporters
References: cmd/…/main.go• L53-133 cmd/…/main.go• L135-152 cmd/…/config.go• L186-197 cmd/…/config_validator.go• L12-39
Relay proxy configuration sources
The relay proxy combines command-line flags, a local configuration file, environment variables, and the optional version value into one configuration. Flag sets normally come from the local configuration. When studio.url is set, the proxy gets only its flag sets from GO Feature Flag Studio while the rest of its settings still come from the normal configuration sources.
The proxy can poll the Studio document and use a configured cache when Studio is not reachable. It accepts a document only after its flag sets pass validation. A local flagSets section and studio.url cannot be used together, so the proxy has one clear source for its flag sets.
Endpoint limits are part of the same configuration model. The flag-file validation endpoint accepts byte counts as plain integers or human-readable sizes. A zero value selects the format default, while environment variables override file values through the normal configuration precedence.
References: cmd/…/config_loader.go• L83-100 cmd/…/config_loader.go• L296-328 cmd/…/config_studio.go• L13-53 cmd/…/config.go• L101-112 cmd/…/config_endpoints.go• L12-23 cmd/…/config_endpoints.go• L56-109 cmd/…/config_envvar.go• L13-50 cmd/…/config_endpoints_test.go• L135-201
Flag set isolation
Each flag set groups flags under its own retrievers, notifiers, exporters, and API keys. The proxy uses the request API key to select the flag set. Each configured flag set must have at least one key and no key can identify more than one flag set.
The default mode uses one shared configuration when no flag sets are configured. Flag-set mode instead gives each group its own configuration and does not inherit settings between groups.
Named flag sets can be added or removed during a configuration reload. Their API keys can also change or move between named flag sets. Other changes to an existing named flag set remain deferred until restart. A flag set with no explicit name, or with the reserved name default, receives a generated name and cannot be managed in this way.
References: cmd/…/flagset.go• L21-104 cmd/…/config_validator.go• L81-127 cmd/…/flagset_manager.go• L30-49 cmd/…/flagset_manager.go• L313-383 cmd/…/flagset_manager.go• L336-347
Flag evaluation interfaces
The relay proxy exposes a native GO Feature Flag evaluation API and an OpenFeature Remote Evaluation Protocol (OFREP) API. Both select a flag set from the request credentials and evaluate against the supplied context. The native API returns a usable value with failure details, while OFREP maps evaluation errors to protocol status responses.
OFREP bulk evaluation can evaluate all flags or a requested subset. When enabled, its response also advertises the server-sent event stream that providers can use for flag changes. Flag names are decoded from URL paths before lookup, so names with reserved characters remain addressable.
References: cmd/…/flag_eval.go• L30-52 cmd/…/flag_eval.go• L53-107 cmd/…/evaluate.go• L42-60 cmd/…/evaluate.go• L60-145 cmd/…/evaluate.go• L147-239 cmd/…/evaluate.go• L241-264 cmd/…/echo_helper.go• L13-56 cmd/…/config_flags_special_chars.yaml• L1-6 cmd/…/valid_evaluation_special_chars.json• L1-9
Flag configuration interface
The native configuration endpoint lets a provider download the current flag definitions for local evaluation. A caller can request all flags or filter the response to named flags. The response also includes the flag-set evaluation enrichment and the cache refresh time.
References: cmd/…/flag_configuration.go• L30-46 cmd/…/flag_configuration.go• L48-62 cmd/…/flag_configuration.go• L63-115 cmd/…/flag_configuration_test.go• L25-110 cmd/…/flag_configuration_test.go• L113-250
Flag validation interface
The authenticated POST /admin/v1/flags/validate endpoint checks a proposed flag file without loading it into the running proxy. Its content type selects JSON, YAML, or TOML parsing, and each format has its own body-size limit. A valid file returns 200; a parsed file with invalid flags returns 422; unreadable or unsupported input returns 400, 413, or 415 as appropriate.
The endpoint records one Prometheus outcome for every request. The outcome is valid for a valid file, invalid for a parsed file with flag errors, and error for a request that cannot be validated. Request-body debug logging skips this route so a proposed flag file is not copied into logs.
References: cmd/…/routes_admin.go• L8-16 cmd/…/validate_flags.go• L38-44 cmd/…/validate_flags.go• L70-130 cmd/…/validate_flags.go• L133-156 cmd/…/config_endpoints.go• L56-109 cmd/…/metrics.go• L14-21 cmd/…/metrics.go• L132-137 cmd/…/body_dump_handler.go• L12-21
Flag change streams
The relay proxy sends flag-change events through server-sent events and WebSockets. Clients connect to /stream/v1/sse/flag/change or /stream/v1/ws/flag/change and authenticate before the connection opens. Each connection belongs to the selected flag set, so a change is sent only to clients for that flag set.
The former /ws/v1/flag/change WebSocket route remains as a compatibility alias. Responses mark it as deprecated and point clients to the new route. Stream payloads can include full flag details or only changed flag names, based on the relay proxy setting.
The stream services are also registered as per-flag-set notifiers. This connects a retriever change to the correct client group, including for a flag set added during a configuration reload. Failed WebSocket writes remove the affected connection, and shutdown closes streams before the API server and flag sets.
References: cmd/…/routes_stream.go• L9-44 cmd/…/websocket.go• L16-28 cmd/…/websocket.go• L51-104 cmd/…/notifier_websocket.go• L8-22 cmd/…/flagset_manager.go• L654-668 cmd/…/routes_stream_test.go• L26-65 cmd/…/routes_stream_test.go• L117-218 cmd/…/websocket_test.go• L62-101
Monitoring endpoints
The relay proxy provides health, information, and Prometheus metrics views. They can share the application listener or use a separate monitoring port. With a separate port, monitoring traffic is kept away from evaluation traffic and Kubernetes health checks use the monitoring listener.
The metrics view includes evaluation, configuration, refresh, change, and validation activity. Bulk evaluation metrics can include flag names only when the related option is enabled. Unknown flag evaluations use one shared label value instead of creating an unbounded time series for every client-supplied name.
The Helm chart exposes the optional monitoring port with the application port and uses it for health checks when configured. The chart packages the relay proxy for Kubernetes deployment and keeps its image version aligned with the chart version.
References: cmd/…/main.go• L89-118 cmd/…/server.go• L77-90 cmd/…/metrics.go• L49-73 cmd/…/metrics.go• L132-172 cmd/…/metrics.go• L223-263 cmd/…/Chart.yaml• L1-9 cmd/…/README.md• L22-52 cmd/…/server_test.go• L64-201
Runtime integrations
Each relay-proxy flag set becomes a GO Feature Flag client with its configured retrievers, exporters, and notifiers. Configuration validation checks the required fields for each integration before startup. The client setup then maps valid configuration to the corresponding runtime services and keeps the flag-set name in logs for named sets.
References: cmd/…/exporter.go• L11-127 cmd/…/exporter.go• L168-204 cmd/…/gofeatureflag_client.go• L41-101 cmd/…/gofeatureflag_client.go• L115-192 cmd/…/gofeatureflag_client.go• L194-345
Output and failure contract
CLI output serves both people and scripts. People need readable results and diagnostics. Scripts need a reliable process result that distinguishes success from failure.
Output channels
Normal results and status messages use standard output. Diagnostics and error lines use standard error. An unhandled command error reaches the fatal exit path, so a caller can use the process result as a failure signal without parsing normal output.
References: cmd/…/print_output.go• L11-18 cmd/…/print_output.go• L20-55 cmd/…/main.go• L11-15
Error states
The CLI stops before its main work when source settings are invalid, configuration cannot be found or parsed, or a retriever cannot be created or initialized. A flag-level evaluation problem can instead appear inside the returned variation result. This allows the command to return a result map while preserving the error for the affected evaluation.
References: cmd/…/evaluate_cmd.go• L146-157 cmd/…/evaluate_cmd.go• L244-269 cmd/…/evaluate.go• L93-105 cmd/…/lint_cmd.go• L34-44
Change checklist
When these files or sections are changed, remember to consider these:
- When a root or child command changes, keep its registration, required arguments, output behavior, and container usage aligned.
- When a retriever kind or required source value changes, update flag mapping, shared validation, and retriever selection together.
- When file formats or default lookup changes, check evaluation, linting, and manifest generation because they share the loader contract.
- When the manifest shape changes, update flag conversion, the OpenFeature schema envelope, and the required destination together.
- When evaluation initialization changes, check normal evaluation and
--check-mode; check mode must remain a source check only. - When output or command errors change, preserve the split between standard output, standard error, and process failure.
- When the Docker command interface changes, keep its examples and mounted-file paths aligned with the CLI.
- When relay proxy startup changes, keep configuration-source selection, validation, service registration, monitoring setup, and shutdown order aligned.
- When Studio loading changes, keep document parsing, flag-set validation, cache fallback, polling, and reload notifications aligned.
- When flag-set reload behavior changes, keep stable names, API-key routing, running clients, and rejected-change rules aligned.
- When evaluation paths change, preserve URL decoding for flag names and the distinct native and OFREP error contracts.
- When the flag validation endpoint changes, keep content-type parsing, per-format limits, shared flag rules, status codes, metrics outcomes, and the generated API description aligned.
- When endpoint size settings change, keep file keys, environment-variable paths, zero-value defaults, and startup validation aligned.
- When environment-array handling changes, keep nested flag-set retrievers, notifiers, exporters, and comma-separated list values compatible with configuration loading.
- When exporter support changes, update exporter-kind validation, required fields, runtime construction, and configuration examples together.
- When stream routes or payload settings change, keep authentication, legacy alias headers, flag-set routing, and notifier registration aligned.
- When monitoring listener behavior changes, keep application routes, health checks, metrics exposure, and Helm service ports aligned.
- When the Go module or CLI dependencies change, confirm that command startup and the supported source workflows still build against the declared Go version.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
An unsupported --kind or missing source value | Evaluation stops before source access. | Shared source validation checks the kind and required values before retriever creation. |
| A local configuration file is missing or cannot be parsed | Linting and manifest generation return an error without a result or artifact. | The shared loader checks the path and file format. |
| Retriever initialization fails | Evaluation stops before it returns flag results. | The workflow performs required initialization and returns its error. |
A targeting rule needs an identity but --ctx has no usable targetingKey | The result can contain an evaluation error and no usable value. | Provide a JSON context with the required targeting key. |
| A flag has no usable variations or default value | Manifest generation omits the flag and reports a conversion warning. | Supply the data required by the manifest contract. |
generate manifest has no destination | The command is rejected and writes no file. | Provide --flag_manifest_destination. |
| The relay proxy cannot load or validate its configuration | Startup stops before the API and stream services begin. | Provide a valid proxy configuration and pass validation before service creation. |
| Studio returns an invalid flag-set document | The update is rejected and consumers keep the last valid configuration. | Validate Studio documents before accepting them and retry after rejection. |
| Studio is unreachable with no usable cache | The proxy cannot obtain the remote flag sets. | Configure a valid Studio URL or a cache file with a last valid document. |
| A flag set has no API key or shares one with another flag set | Proxy validation fails, so requests cannot be routed safely. | Give each flag set at least one unique API key. |
| A named flag set is changed outside its API keys during a reload | The running flag set keeps its old configuration until restart. | Use a restart for retriever or other flag-set setting changes. |
| A configuration reload leaves an API key on more than one running flag set | The key is disabled for routing until the configuration is fixed. | Keep API keys unique and move them in a valid reload. |
| A request has no valid API key or the flag-set manager is unavailable | Native, OFREP, and stream handlers reject the request before evaluation or upgrade. | Send a supported credential and start the flag-set manager before serving requests. |
| A flag name with reserved URL characters is not decoded before lookup | The proxy cannot find the configured flag. | Preserve URL escaping at the route and decode the flag key before evaluation. |
| A validation request has no supported content type | The admin endpoint returns 415 and does not inspect the body. | Send JSON, YAML, or TOML with the matching Content-Type. |
| A validation request exceeds its format limit | The admin endpoint returns 413 and does not validate the file. | Set a suitable per-format limit and keep the request within it. |
| A validation request contains invalid flags | The admin endpoint returns 422 with the invalid flag names and messages. | Run the CLI lint workflow or fix the proposed flag definitions before submission. |
| An exporter kind lacks its required destination or connection fields | Proxy validation or client creation fails and the related flag set cannot start. | Validate kind-specific exporter requirements before startup. |
| A stream client uses the legacy WebSocket path without handling deprecation | The client depends on a compatibility route that may be removed later. | Migrate to /stream/v1/ws/flag/change and follow the Link header. |
| A flag set or cache is unavailable during a Prometheus scrape | The loaded-flag metric emits no series for the unavailable data. | Restore flag-set access or cache initialization; the collector skips unavailable sources. |
| A configured monitoring port is not exposed by the deployment | Kubernetes health checks cannot reach the monitoring listener. | Keep relay proxy configuration, chart ports, service ports, and probes aligned. |
Key files
| File | Why to read it |
|---|---|
| cmd/…/main.go | Shows the root command and top-level workflows. |
| cmd/…/evaluate_cmd.go | Shows source input, validation, check mode, initialization, and evaluation selection. |
| cmd/…/evaluate.go | Shows the high-level evaluation result flow. |
| cmdhelpers/…/retriever_conf.go | Defines the shared source model and validation rules. |
| cmdhelpers/…/retriever_init.go | Shows how source kinds map to retriever services. |
| cmdhelpers/…/read_config_file.go | Defines local file lookup and supported formats. |
| cmd/…/linter.go | Shows configuration-only validation and file-qualified errors. |
| cmd/…/manifest.go | Shows how loaded flags become an OpenFeature manifest. |
| cmd/…/print_output.go | Defines shared output and fatal-error behavior. |
| cmd/…/main.go | Shows relay proxy startup, service wiring, monitoring registration, and shutdown order. |
| cmd/…/config_loader.go | Shows how proxy settings and Studio flag sets are loaded and reloaded. |
| cmd/…/config_endpoints.go | Defines validation endpoint limits and their defaults. |
| cmd/…/config_envvar.go | Defines environment-variable mapping for nested and list configuration. |
| cmd/…/config_validator.go | Defines proxy, retriever, exporter, notifier, endpoint, and flag-set validation. |
| cmd/…/exporter.go | Defines exporter kinds and their required configuration. |
| cmd/…/gofeatureflag_client.go | Maps valid flag-set configuration to runtime retrievers, exporters, notifiers, and clients. |
| cmd/…/routes_admin.go | Defines authenticated administration routes. |
| cmd/…/validate_flags.go | Defines the remote flag-file validation workflow and response contract. |
| cmd/…/body_dump_handler.go | Shows the request logging boundary that protects validation payloads. |
| cmd/…/metrics.go | Defines evaluation, validation, change, and configuration metrics. |
| cmd/…/swagger.yaml | Describes the public API contract, including flag-file validation responses. |
| cmd/…/server.go | Shows middleware, controller wiring, route registration, and authentication boundaries. |
| cmd/…/routes_stream.go | Defines current and legacy flag-change stream routes. |
| cmd/…/websocket.go | Defines WebSocket registration, flag-set filtering, payload scope, and cleanup. |
| cmd/…/flag_eval.go | Shows native flag evaluation through the selected flag set. |
| cmd/…/flag_configuration.go | Shows the configuration download interface for local providers. |
| cmd/…/evaluate.go | Shows single and bulk OFREP evaluation and event-stream advertisement. |
| cmd/…/collector_flag_loaded.go | Defines the loaded-flag monitoring view and its effective disabled state. |
| cmd/…/Chart.yaml | Defines the Kubernetes chart and application version. |
| cmd/…/README.md | Describes deployment and separate monitoring-port behavior. |
| cmd/…/DOCKERHUB.md | Shows the container distribution and command usage. |
go.mod | Declares the Go version and dependency set used to build the CLI and its source integrations. |