Skip to main content

Crate vantage_cmd

Crate vantage_cmd 

Source
Expand description

vantage-cmd — a Vantage persistence backend that gets its data by running a local command (the aws CLI, kubectl, gh, …).

The design pins down a strict security boundary and hands everything else to a Rhai script:

  • The command is locked on the Cmd datasource — a script can never change which binary runs.
  • Environment variables are locked — the child process gets a cleared environment plus only the vars declared on the datasource / table (and PATH/HOME so the binary is locatable, toggleable via Cmd::with_pass_path).
  • The arguments and the output parsing are scripted in Rhai. When a table is read, the script runs with the table’s conditions, columns, limit, offset and id_column in scope; it builds an argv, calls the registered run(args) callback (which executes the locked command), then parses the captured output into rows.
const LOG_GROUPS: &str = r#"
    let args = ["logs", "describe-log-groups", "--output", "json"];
    for c in conditions {
        if c.field == "logGroupNamePrefix" {
            args += ["--log-group-name-prefix", c.value];
        }
    }
    let out = run(args);
    if out.exit_code != 0 { throw out.stderr; }
    parse_json(out.stdout).logGroups
"#;

let cmd = Cmd::new("aws")
    .with_env("AWS_REGION", "us-east-1")
    .with_script("log.groups", LOG_GROUPS);

let groups = Table::<Cmd, EmptyEntity>::new("log.groups", cmd)
    .with_id_column("logGroupName")
    .with_column_of::<i64>("creationTime");

Modules§

models
CmdModelFactory — maps dotted model names (iam.users, log.groups, log.group, …) to YAML-backed Vistas, mirroring vantage_aws::models::Factory.
vista
Vista integration for vantage-cmd: the YAML-facing spec types, the factory (typed-table and YAML construction), and the TableShell.

Structs§

Cmd
A command-execution datasource.
CmdOutput
Captured result of a single command invocation.
CmdSpec
Per-table configuration registered on a Cmd: the Rhai script that builds the argv and parses the output, plus optional command / env overrides that win over the datasource-level defaults.

Enums§

AnyCmdType
One value in a command-backed record, at the rendering boundary.
CmdCondition
A filter on a command-backed table.

Traits§

CmdOperation
Build conditions from a typed column without going through the expression machinery (command backends filter via CLI flags, not SQL).

Functions§

eq
field == value. Shorthand for CmdCondition::eq.