CLI evaluation, generation, and linting
The GO Feature Flag CLI gives engineers three related ways to work with flag configuration: inspect evaluations, create an OpenFeature manifest, and check configuration before use. These workflows share the same source selection, configuration model, and output rules. The relay proxy uses the same configuration and evaluation contracts when it serves flag data to remote clients. See the CLI tools, configuration schema and models, and relay proxy pages for related system views.
Command workflows
The root command exposes evaluate, generate, and lint. Each command turns configuration input into either an evaluation result, a machine-readable artifact, or a validation result. The generate command is a group whose current artifact workflow is generate manifest. References: cmd/…/main.go• L11-26, cmd/…/generate_cmd.go• L11-27
| Command | Main purpose | Primary result |
|---|---|---|
evaluate | Resolve one or more flags from a selected source and evaluation context | JSON evaluation results, or retriever details in check mode |
generate manifest | Convert configured flags into an OpenFeature-compatible manifest | JSON manifest written to the requested destination |
lint | Parse configuration and validate each flag definition | Success information or errors with a failing command status |
Shared configuration loading
Configuration loading is the common boundary for linting and manifest generation. The loader accepts an explicit file path and format, or searches standard locations for flags.goff files when no path is given. It parses YAML by default and also supports JSON and TOML. References: cmdhelpers/…/read_config_file.go• L14-24, cmdhelpers/…/read_config_file.go• L29-54, cmdhelpers/…/read_config_file.go• L57-83
The loaded data uses the same flag data shape as the feature-flag system. Linting converts each entry to an internal flag and checks its validity. Manifest generation converts entries to internal flags before it derives the external manifest definitions. This shared path keeps both workflows aligned with the configuration rules used by the product. References: cmd/…/linter.go• L9-30, cmd/…/manifest.go• L19-34, cmd/…/manifest.go• L42-54
Evaluation workflow
The evaluate command is a diagnostic and automation interface for asking what value a flag produces from a selected configuration source and context. It can target one flag with --flag; when that option is empty, it evaluates all available flags. The command accepts the newer --path and --auth-token options while retaining deprecated source aliases for existing scripts. References: cmd/…/evaluate_cmd.go• L55-108, cmd/…/evaluate_cmd.go• L112-157, cmd/…/evaluate_cmd.go• L162-232, cmd/…/evaluate.go• L22-40, cmd/…/evaluate.go• L75-90
Retriever selection
An evaluation source is represented by a retriever configuration. A retriever is the source adapter that obtains flag configuration from a local file, HTTP endpoint, Git provider, object store, database, cache, or Kubernetes ConfigMap. The command validates the selected kind and its required source fields before it creates the adapter. References: cmd/…/evaluate_cmd.go• L112-157, cmdhelpers/…/retriever_conf.go• L70-109, cmdhelpers/…/retriever_conf.go• L195-221
The retriever initializer maps the validated kind to its source adapter and applies shared defaults such as timeout, HTTP method, and Git branch. This lets the evaluation flow keep one command shape while source-specific connection work stays behind the retriever contract. References: cmdhelpers/…/retriever_init.go• L27-58, cmdhelpers/…/retriever_init.go• L60-188
Evaluation context
The evaluation context is the JSON object supplied with --ctx. It carries the targeting key and other attributes used by flag rules. The command converts this JSON into the SDK context model before it asks the GO Feature Flag client to resolve values. References: cmd/…/evaluate.go• L54-73
The evaluation sequence moves from source selection to client setup and then to flag resolution. The output is a JSON map of raw variation results, which makes it useful for terminal checks and CI/CD steps.
This diagram shows how source settings and context become one-flag or all-flag evaluation results.
flowchart LR
A[CLI source flags] --> B[Retriever configuration]
B --> C[Validated retriever]
C --> D[GO Feature Flag client]
E[JSON evaluation context] --> F[SDK evaluation context]
D --> G[One flag or all flags]
F --> G
G --> H[JSON results]
References: cmd/…/evaluate_cmd.go• L235-278 cmd/…/evaluate.go• L42-51 cmd/…/evaluate.go• L93-107
Check mode
Evaluation also has a check mode that stops after retriever configuration validation. It prints the resolved retriever configuration instead of loading flags or evaluating them. This gives a fast check that source selection and required connection fields are coherent.
The printed configuration uses one shared shape across source kinds. Optional object-source fields such as Pattern, Prefix, and Recursive appear with empty or false defaults when the selected source does not use them. References: cmd/…/evaluate_cmd.go• L146-157, cmd/…/evaluate_cmd.go• L281-294, cmd/…/check-azure.json• L1-36, cmd/…/check-bitbucket.json• L1-36, cmd/…/check-gcs.json• L1-36, cmd/…/check-github.json• L1-36, cmd/…/check-gitlab.json• L1-36, cmd/…/check-http.json• L1-44, cmd/…/check-k8s.json• L1-36, cmd/…/check-mongodb.json• L1-36, cmd/…/check-postgres.json• L1-39, cmd/…/check-s3.json• L1-36
Manifest generation
The generate manifest workflow turns flag configuration into a flag manifest for the OpenFeature CLI. The manifest is a machine-readable description of each eligible flag. It includes the flag type, default value, and description. The feature is marked experimental because its command and output contract may change. References: cmd/…/manifest_cmd.go• L13-44, cmd/…/flag_manifest.go• L9-27, cmdhelpers/…/flag_definition.go• L3-7
Manifest eligibility
Manifest generation uses flag metadata for information that the flag name does not provide. A flag must have defaultValue in its metadata to enter the manifest. description is optional. The generator infers the flag type from its variations and skips entries with no variations or no default value. References: cmdhelpers/…/generate_definition.go• L12-57
The generated envelope includes the OpenFeature manifest schema URL and a flags map. The command writes formatted JSON to the requested destination and reports generation messages through the shared CLI output helper. References: cmd/…/flag_manifest.go• L13-27, cmd/…/manifest.go• L62-87
Configuration linting
The lint command checks whether a flag configuration can be parsed and whether each parsed flag is valid. It reports all validation errors that it finds, then returns a command error when the configuration is not valid. A valid configuration produces an informational result. References: cmd/…/lint_cmd.go• L12-44, cmd/…/linter.go• L14-30
Linting is intended to run before configuration reaches a service or deployment. The same command works locally or in continuous integration because it has a clear success or failure result and accepts the input format explicitly. References: cmd/…/lint_cmd.go• L23-25, website/…/linter.mdx• L23-33
Relay proxy configuration sources
The relay proxy can load flag sets from local configuration or from GO Feature Flag Studio. A flag set is a group of flags with its own source, access keys, and related change handling. Studio supplies only the flag sets; the rest of the proxy configuration still comes from the file and environment sources. These modes are exclusive, so a configuration cannot define local flag sets and Studio flag sets at the same time. References: cmd/…/config.go• L101-109, cmd/…/flagset.go• L9-36, cmd/…/config_loader.go• L218-236, cmd/…/config_validator.go• L12-35
Studio configuration is fetched from a URL and can use request headers, polling, and a cache file. The loader validates a fetched document before it accepts the document or replaces the cache. If a later fetch fails, the last valid cached flag sets can continue to serve the proxy. Valid updates notify the running proxy through configuration-change callbacks. References: cmd/…/config_studio.go• L13-53, cmd/…/config_studio.go• L55-71, cmd/…/config_loader.go• L109-216, cmd/…/config_studio_test.go• L301-414
Shared relay evaluation helpers
Relay evaluation endpoints use a shared helper boundary to identify the caller and select its flag set. The helper gives X-API-Key precedence over Authorization; a Bearer value is trimmed to its token. It then maps the key to the flag-set manager and returns a clear client or server error when selection is not possible. References: cmd/…/echo_helper.go• L13-43, cmd/…/echo_helper_test.go• L17-249
The same helper also decodes escaped flag keys from request paths. This preserves flag names that contain characters such as :, /, +, spaces, or % when the request reaches a single-flag evaluation endpoint. References: cmd/…/echo_helper.go• L45-57, cmd/…/echo_helper_test.go• L272-307, cmd/…/config_flags_special_chars.yaml• L1-6, cmd/…/valid_evaluation_special_chars.json• L1-9
Relay evaluation interfaces
The relay proxy exposes a native GO Feature Flag evaluation endpoint and an OpenFeature Remote Evaluation Protocol (OFREP) interface. Both select a flag set through the shared API-key helper and resolve against the current flag cache. The native endpoint returns a raw evaluation result with a caller-supplied default, while OFREP returns the protocol response and treats evaluation errors as HTTP errors.
OFREP also supports bulk evaluation. A request can name flags through the context, or it can evaluate every available flag when no list is supplied. Results are sorted by flag key, and an enabled event-stream setting adds an SSE endpoint to the bulk response so a provider can receive later flag changes. References: cmd/…/flag_eval.go• L30-107, cmd/…/evaluate.go• L42-145, cmd/…/evaluate.go• L147-239
This diagram shows the shared request path for relay evaluation and flag configuration retrieval.
flowchart LR
A[Evaluation or configuration request] --> B[API key and flag key helpers]
B --> C[Flag-set manager]
C --> D[Current flag cache]
D --> E[Native or OFREP response]
The flag configuration endpoint supports local-evaluation providers that need the current flag definitions rather than a single resolved value. It can return all flags or only the requested names, and it includes the flag set's evaluation-context enrichment. References: cmd/…/flag_configuration.go• L30-45, cmd/…/flag_configuration.go• L48-115, cmd/…/flag_configuration_test.go• L25-249
CLI output and errors
The shared output helper gives commands one way to print normal, informational, warning, and error lines. Error lines go to standard error while other lines go to standard output. A command can therefore show diagnostics without mixing them with its normal result stream. References: cmd/…/print_output.go• L11-55
Command execution suppresses Cobra's extra usage and error text. The root command converts an unhandled command error into one fatal error message and exits with status 1. This keeps failure behavior useful for both a human terminal and an automation step. References: cmd/…/main.go• L11-15, cmd/…/evaluate_cmd.go• L159-160, cmd/…/lint_cmd.go• L20-21
Change checklist
When these files or sections are changed, remember to consider these:
- Keep retriever kinds accepted by
RetrieverConf.IsValidaligned with the factory map used byInitRetrieverand the fields exposed byevaluate. - Keep legacy source aliases aligned with their current options until the compatibility contract is removed.
- Keep configuration format handling aligned between
LoadConfigFile, command--formatflags, and default-file search. - Keep local flag-set and Studio source rules aligned with
ConfigLoader.ToConfig, validation, cache behavior, and reload callbacks. - Keep manifest metadata names and inferred flag types aligned with the OpenFeature manifest model and schema URL.
- Keep API-key precedence and escaped flag-key decoding aligned across native evaluation, OFREP evaluation, and flag configuration endpoints.
- Keep OFREP event-stream URLs aligned with the configured base URL and the caller's API-key handling.
- Keep output streams and command error status aligned so CI can distinguish a valid result from diagnostics.
- Keep check-mode result fixtures aligned with the shared retriever configuration shape when source-selection fields change.
- Keep Docker usage examples aligned with current command names, option aliases, and mounted paths.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The selected retriever kind lacks a required source field | Evaluation stops before the source adapter is created | Retriever validation checks kind-specific requirements before initialization |
| The configuration path or format is wrong | Linting or manifest generation cannot parse the input | The shared file loader checks the path and parses the declared format |
A flag has no defaultValue metadata | The flag is omitted from the generated manifest | Add defaultValue to the flag metadata before generation |
| A variation set has unsupported or mixed types | Manifest generation cannot derive a flag type | Keep variations compatible with one supported manifest type |
evaluate receives invalid context JSON | Evaluation stops before flag resolution | Pass a valid JSON object and include a targeting key when bucketing needs one |
| Local flag sets and Studio are both configured | Proxy configuration fails validation | Select one flag-set source |
| A Studio update is malformed or fails validation | The update is rejected and the last valid data remains active | Validate before accepting the document or replacing its cache |
| A request uses an unknown API key | The relay endpoint cannot select a flag set | Send a configured key through X-API-Key or a supported Authorization value |
| A flag key remains URL-escaped at evaluation time | A valid flag with reserved characters is reported as missing | Decode the path parameter before flag lookup |
| A bulk OFREP request omits its context | The endpoint returns an invalid-context response | Send a context object, even when it is empty |
| A flag needs bucketing but the context has no targeting key | Evaluation returns an error for that flag | Include targetingKey when percentage or other bucketing rules apply |
| A container run does not mount the host configuration at the path passed to the CLI | evaluate or lint cannot read the configuration | Mount the local file at the same container path used by the command option |
Key files
| File | Why to read it |
|---|---|
| cmd/…/main.go | Shows how the root CLI assembles the main workflows and handles fatal errors. |
| cmd/…/evaluate_cmd.go | Defines evaluation inputs, source aliases, retriever validation, and check mode. |
| cmd/…/evaluate.go | Shows how a retriever and evaluation context become flag results. |
| cmdhelpers/…/retriever_conf.go | Defines the shared source configuration contract and required fields. |
| cmdhelpers/…/retriever_init.go | Shows how source kinds map to retriever adapters and shared defaults. |
| cmdhelpers/…/read_config_file.go | Defines shared file lookup and YAML, JSON, and TOML loading. |
| cmd/…/manifest.go | Connects configuration loading to manifest creation and file output. |
| cmdhelpers/…/generate_definition.go | Defines which flags enter the manifest and how their types are inferred. |
| cmd/…/linter.go | Shows the configuration parse and per-flag validity check. |
| cmd/…/config_loader.go | Shows how file, environment, and Studio sources form the live proxy configuration. |
| cmd/…/config_studio.go | Defines Studio flag-set loading, validation, polling, and cache use. |
| cmd/…/config_validator.go | Defines the rules that make proxy and flag-set configuration valid. |
| cmd/…/echo_helper.go | Defines API-key selection, flag-set lookup, and escaped flag-key handling. |
| cmd/…/flag_eval.go | Shows the native single-flag evaluation contract. |
| cmd/…/evaluate.go | Shows single and bulk OFREP evaluation and event-stream advertisement. |
| cmd/…/flag_configuration.go | Shows how providers retrieve current flag definitions for local evaluation. |
| cmd/…/print_output.go | Defines shared CLI output levels and standard-output/error routing. |