mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-07-21 03:41:03 +02:00
feat(cli): omnigraph config migrate — the RFC-008 split (stage 2)
Reads a legacy omnigraph.yaml and produces the three-section split: team half as a ready-to-review cluster.yaml proposal (graphs with TODO schema pointers — the legacy file never knew schemas — per-graph queries directories, policies with applies_to bindings), personal half as an operator-config merge (actor, output/table defaults — OperatorDefaults gains the two table keys with their cascade hops — remote graphs with bearer_token_env become servers entries plus a printed login step, and legacy aliases split per the RFC: content to the catalog as a manual step, binding to an operator alias), plus a dropped-keys section with reasons. Touches nothing without --write; with it, the operator merge is key-level (existing entries always win; prior file backed up), and cluster.yaml is emitted only when absent (else cluster.yaml.proposed). --json emits the report structurally. The completeness contract is a unit test: every top-level key of the legacy schema must classify somewhere, or the RFC-008 map has a bug. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
c89d268b23
commit
cd1f175396
6 changed files with 562 additions and 4 deletions
|
|
@ -42,6 +42,7 @@ use serde::de::DeserializeOwned;
|
|||
use serde_json::Value;
|
||||
|
||||
mod embed;
|
||||
mod migrate;
|
||||
mod operator;
|
||||
mod read_format;
|
||||
|
||||
|
|
@ -73,6 +74,42 @@ async fn main() -> Result<()> {
|
|||
};
|
||||
let http_client = build_http_client()?;
|
||||
match cli.command {
|
||||
Command::Config { command } => match command {
|
||||
ConfigCommand::Migrate { config, write, json } => {
|
||||
let path = migrate::legacy_config_path(config.as_ref());
|
||||
if !path.exists() {
|
||||
bail!(
|
||||
"no legacy config at '{}' — nothing to migrate",
|
||||
path.display()
|
||||
);
|
||||
}
|
||||
let legacy = load_config(Some(&path))?;
|
||||
let report = migrate::build_report(&legacy, &path);
|
||||
if write {
|
||||
let legacy_dir = path
|
||||
.parent()
|
||||
.filter(|parent| !parent.as_os_str().is_empty())
|
||||
.unwrap_or(std::path::Path::new("."))
|
||||
.to_path_buf();
|
||||
let written = migrate::apply_report(&report, &legacy_dir)?;
|
||||
if json {
|
||||
print_json(&serde_json::json!({
|
||||
"report": report,
|
||||
"written": written,
|
||||
}))?;
|
||||
} else {
|
||||
print!("{}", migrate::render_report(&report));
|
||||
for line in written {
|
||||
println!("wrote: {line}");
|
||||
}
|
||||
}
|
||||
} else if json {
|
||||
print_json(&report)?;
|
||||
} else {
|
||||
print!("{}", migrate::render_report(&report));
|
||||
}
|
||||
}
|
||||
},
|
||||
Command::Login { name, token, json } => {
|
||||
let token = match token {
|
||||
Some(token) => token,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue