Skip to content

Add dashboards import-from-classic command - #138

Open
bg451 wants to merge 4 commits into
bg451/chronoctl-sync-swagger-import-from-classicfrom
bg451/chronoctl-dashboards-import-from-classic
Open

bg451 wants to merge 4 commits into
bg451/chronoctl-sync-swagger-import-from-classicfrom
bg451/chronoctl-dashboards-import-from-classic

Conversation

@bg451

@bg451 bg451 commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Adds the hand-written chronoctl dashboards import-from-classic command for the v1 ImportDashboardFromClassic endpoint (POST /api/v1/config/dashboards:importFromClassic), which converts raw classic (Grafana) dashboard JSON into a Dashboard in one call.

chronoctl dashboards import-from-classic -f grafana.json --collection-slug <slug> \
    [--name <name>] [--slug <slug>] [--update-if-exists] [--dry-run] [-o yaml|json|jsonl]
  • -f/--filename is the raw classic dashboard JSON (not a chronoctl manifest), read whole and sent as classic_dashboard_json; - reads stdin.
  • --update-if-exists without --slug is rejected client-side with the server's wording, so the user sees the error before a network call.
  • stdout is the returned dashboard wrapped as a v1/config Dashboard manifest (same shape as dashboards create/read), so it can be piped into dashboards update -f - or committed as config. It is printed on --dry-run too, as the preview.
  • stderr carries the usual status line plus one warning line per unsupported classic feature ([LEVEL_UNSUPPORTED] <kind>: <message> (N occurrences; panels: a, b)). The API call succeeded, so the exit code stays 0; a --fail-on-unsupported flag is left as a possible follow-up.

The command lives in a new src/cmd/pkg/dashboards package (the generator wipes src/generated/cli, so hand-written commands cannot live there) and is attached to the generated dashboards command from src/cmd/root.go. Unit tests cover run() against the gomock configv1 client (request body, YAML manifest, dry run, unsupported-feature rendering, wrapped API error), the validate() table, and the registration.

Stacked PR. This branch is cut from and targets bg451/chronoctl-sync-swagger-import-from-classic (#137), which brings in the generated ImportDashboardFromClassic client this command calls. Read the diff on top of that one; when #137 merges this PR should be rebased onto its new base.

claude: pr-lifecycle

The tools module's golden tests are not run by CI (make test covers
src/ only) and had drifted from what the generator now emits. Regenerated
with UPDATE_GOLDEN_FILES=1 so the next change can rely on them.
Paths whose entity segment contains a colon, such as
/api/v1/config/dashboards:importFromClassic, are RPC-style verbs rather
than CRUD entities. The generator took the segment verbatim as an entity
name and then panicked in ScaffoldYAML because there is no schema to
scaffold. clispec now ignores those paths entirely, so syncing a spec
that carries them no longer breaks generation. Generated output for the
current specs is unchanged.
@bg451
bg451 requested a review from a team as a code owner September 15, 2026 17:45
@bg451
bg451 force-pushed the bg451/chronoctl-sync-swagger-import-from-classic branch from ad20670 to bd8b7f1 Compare September 16, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant