mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-09 01:35:18 +02:00
fix(cli,server): correct remaining --target references to --graph
L6 renamed the flag but left stragglers. Two were functional: the `resolve_target_uri` "URI must be provided …" error still named `--target`, and `docker/entrypoint.sh` passed `--target` to omnigraph-server (which now only accepts `--graph`) — so the container failed to boot. Both fixed (plus the entrypoint smoke test's expected args). The rest are code comments across the config/server/cli crates and tests, and the cheat sheet, swept `--target` → `--graph`. `--target-branch` (policy explain) is a distinct flag and untouched; past release notes keep `--target` (accurate for those versions).
This commit is contained in:
parent
eb3c36d8aa
commit
c2db7b5002
8 changed files with 16 additions and 16 deletions
|
|
@ -1771,7 +1771,7 @@ struct QueriesListOutput {
|
|||
/// Resolve the selected graph to `(local URI, registry selection)` from one
|
||||
/// precedence, so a command's schema and its stored-query registry can never
|
||||
/// come from different graphs. A **positional URI is anonymous** (top-level
|
||||
/// registry, ignoring the configured default graph); otherwise `--target`
|
||||
/// registry, ignoring the configured default graph); otherwise `--graph`
|
||||
/// or the configured `cli.graph` names the graph (its per-graph block).
|
||||
/// Mirrors the server's single-mode identity rule.
|
||||
fn resolve_selected_graph(
|
||||
|
|
@ -1861,7 +1861,7 @@ async fn execute_queries_validate(
|
|||
) -> Result<()> {
|
||||
let config = load_cli_config(config_path)?;
|
||||
// One selection drives both the schema URI and the registry, so a
|
||||
// positional URI and a `--target` can't validate different graphs.
|
||||
// positional URI and a `--graph` can't validate different graphs.
|
||||
let (uri, selected) =
|
||||
resolve_selected_graph(&config, uri, target.as_deref(), "queries validate")?;
|
||||
let registry = load_registry_or_report(&config, selected.as_deref())?;
|
||||
|
|
|
|||
|
|
@ -1028,7 +1028,7 @@ graphs:
|
|||
)],
|
||||
);
|
||||
|
||||
// Client config — the CLI's `--target dev` resolves to `server.base_url`.
|
||||
// Client config — the CLI's `--graph dev` resolves to `server.base_url`.
|
||||
let client_config_path = cfg_dir.path().join("client.yaml");
|
||||
fs::write(
|
||||
&client_config_path,
|
||||
|
|
|
|||
|
|
@ -498,7 +498,7 @@ impl OmnigraphConfig {
|
|||
/// with a populated top-level block is rejected;
|
||||
/// * an unknown name errors with the **same** message
|
||||
/// [`OmnigraphConfig::resolve_target_uri`] produces, so a command that
|
||||
/// opens no URI rejects an unknown `--target` exactly like the
|
||||
/// opens no URI rejects an unknown `--graph` exactly like the
|
||||
/// URI-resolving commands do;
|
||||
/// * an anonymous selection (`None`, e.g. a bare URI) stays anonymous,
|
||||
/// resolving to the top-level registry downstream (top-level honored).
|
||||
|
|
@ -781,7 +781,7 @@ impl OmnigraphConfig {
|
|||
}
|
||||
|
||||
let target_name = explicit_target.or(default_target).ok_or_else(|| {
|
||||
color_eyre::eyre::eyre!("URI must be provided via <URI>, --target, or config")
|
||||
color_eyre::eyre::eyre!("URI must be provided via <URI>, --graph, or config")
|
||||
})?;
|
||||
let target = self.graphs.get(target_name).ok_or_else(|| {
|
||||
color_eyre::eyre::eyre!(
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ const SERVER_SOURCE_VERSION: Option<&str> = option_env!("OMNIGRAPH_SOURCE_VERSIO
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct ServerConfig {
|
||||
/// Server topology + the graphs to open at startup. Single-mode
|
||||
/// invocations (`omnigraph-server <URI>` or `--target <name>`)
|
||||
/// invocations (`omnigraph-server <URI>` or `--graph <name>`)
|
||||
/// produce `ServerConfigMode::Single`; multi-mode invocations
|
||||
/// (`--config omnigraph.yaml` with a non-empty `graphs:` map and
|
||||
/// no single-mode selector) produce `ServerConfigMode::Multi`.
|
||||
|
|
@ -159,7 +159,7 @@ pub struct ServerConfig {
|
|||
pub enum ServerConfigMode {
|
||||
/// Legacy invocation — one graph at the given URI. Either:
|
||||
/// * `omnigraph-server <URI>` (CLI positional), or
|
||||
/// * `omnigraph-server --target <name> --config omnigraph.yaml`, or
|
||||
/// * `omnigraph-server --graph <name> --config omnigraph.yaml`, or
|
||||
/// * `omnigraph-server --config omnigraph.yaml` with `server.graph`
|
||||
/// set to a named target.
|
||||
Single {
|
||||
|
|
@ -937,13 +937,13 @@ pub fn load_server_settings(
|
|||
// MR-668 decision 2 — four-rule mode inference matrix.
|
||||
//
|
||||
// 1. CLI `<URI>` positional → Single (URI = the value)
|
||||
// 2. CLI `--target <name>` → Single (URI = graphs.<name>.uri)
|
||||
// 2. CLI `--graph <name>` → Single (URI = graphs.<name>.uri)
|
||||
// 3. `server.graph` in config → Single (URI = graphs.<server.graph>.uri)
|
||||
// 4. `--config` + non-empty `graphs:` + no single-mode selector
|
||||
// → Multi (every entry in `graphs:`)
|
||||
// 5. otherwise → error with migration hint
|
||||
//
|
||||
// Rules 1-3 are mutually compatible (CLI URI wins over `--target`
|
||||
// Rules 1-3 are mutually compatible (CLI URI wins over `--graph`
|
||||
// wins over `server.graph`), reusing the existing
|
||||
// `resolve_target_uri` precedence.
|
||||
let has_cli_uri = cli_uri.is_some();
|
||||
|
|
@ -3388,7 +3388,7 @@ server:
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
// `--target dev` overrides `server.graph: local`, resolving the named
|
||||
// `--graph dev` overrides `server.graph: local`, resolving the named
|
||||
// embedded graph. (A remote target is now rejected — see
|
||||
// `single_mode_rejects_named_remote_graph` in tests/server.rs.)
|
||||
let settings =
|
||||
|
|
|
|||
|
|
@ -5642,7 +5642,7 @@ graphs:
|
|||
}
|
||||
}
|
||||
|
||||
/// Rule 2: --target picks one graph from `graphs:` map → Single.
|
||||
/// Rule 2: --graph picks one graph from `graphs:` map → Single.
|
||||
#[test]
|
||||
fn mode_inference_cli_target_is_single() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
|
|
@ -5772,7 +5772,7 @@ graphs:
|
|||
|
||||
#[test]
|
||||
fn single_mode_named_graph_rejects_top_level_blocks() {
|
||||
// Serving a graph by name (`--target`/`server.graph`) uses its
|
||||
// Serving a graph by name (`--graph`/`server.graph`) uses its
|
||||
// per-graph block; a populated top-level block would be silently
|
||||
// shadowed, so boot refuses and names the per-graph location.
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
|
|
@ -5799,7 +5799,7 @@ graphs:
|
|||
|
||||
#[test]
|
||||
fn single_mode_named_graph_uses_per_graph_policy_and_queries() {
|
||||
// The identity rule: `--target prod` attaches `graphs.prod`'s own
|
||||
// The identity rule: `--graph prod` attaches `graphs.prod`'s own
|
||||
// policy + queries, not the top-level ones (which are absent here).
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
fs::write(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ fi
|
|||
|
||||
if [ -n "${OMNIGRAPH_CONFIG:-}" ]; then
|
||||
if [ -n "${OMNIGRAPH_TARGET:-}" ]; then
|
||||
exec "$SERVER_BIN" --config "${OMNIGRAPH_CONFIG}" --target "${OMNIGRAPH_TARGET}" --bind "${bind}"
|
||||
exec "$SERVER_BIN" --config "${OMNIGRAPH_CONFIG}" --graph "${OMNIGRAPH_TARGET}" --bind "${bind}"
|
||||
fi
|
||||
exec "$SERVER_BIN" --config "${OMNIGRAPH_CONFIG}" --bind "${bind}"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ check "CONFIG only" \
|
|||
|
||||
got=$(OMNIGRAPH_CONFIG="/etc/omnigraph/omnigraph.yaml" OMNIGRAPH_TARGET="active" OMNIGRAPH_BIND="0.0.0.0:8080" sh "$ep")
|
||||
check "CONFIG + TARGET" \
|
||||
"ARGS: --config /etc/omnigraph/omnigraph.yaml --target active --bind 0.0.0.0:8080" "$got"
|
||||
"ARGS: --config /etc/omnigraph/omnigraph.yaml --graph active --bind 0.0.0.0:8080" "$got"
|
||||
|
||||
got=$(sh "$ep" some-uri --bind 1.2.3.4:9 --extra)
|
||||
check "explicit args passthrough" \
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ omnigraph check --query ./queries.gq s3://bucket/repo
|
|||
Use `omnigraph.yaml` target resolution:
|
||||
|
||||
```bash
|
||||
omnigraph lint --query ./queries.gq --target local --config ./omnigraph.yaml
|
||||
omnigraph lint --query ./queries.gq --graph local --config ./omnigraph.yaml
|
||||
```
|
||||
|
||||
> The previous `omnigraph query lint` / `omnigraph query check` spellings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue