Skip to content

Fallback to user endpoints when not logged in as admin - #204

Open
f0086 wants to merge 2 commits into
nextfrom
GPCO-49_admin_cloud_fallback
Open

Fallback to user endpoints when not logged in as admin#204
f0086 wants to merge 2 commits into
nextfrom
GPCO-49_admin_cloud_fallback

Conversation

@f0086

@f0086 f0086 commented Aug 18, 2026

Copy link
Copy Markdown
Member

Makes the CLI usable in plain user sessions (client id + secret, no admin credentials). Previously, commands backed by admin gRPC endpoints failed with a raw Keycloak role error, even where the API offers a user-facing equivalent.

  • Actions can declare a fallback in the YAML definition: sessions without admin credentials transparently call the equivalent cloud.* endpoint instead (admin-project list/get/nodes, operating-systems list).
  • All other admin-only commands fail fast with a hint pointing at the user-facing alternative, instead of a server-side permission error.
  • The hinted alternatives now actually work out of the box:
    • flavour list-project takes --project-id and defaults to the project selected via project use (new generic field: mapping in the generator, since the proto names the field just id)
    • image list-public no longer requires the deprecated --flavour-id flag and defaults to no cloud-provider filter, so the bare command lists all public images instead of an empty AWS-filtered result
  • Clearer no-project-selected error pointing to project use / --project-id, and fixed GPCORE_CONFIG being ignored due to a duplicate init().

Breaking

flavour list-project --id <uuid> is renamed to --project-id (optional now, session fallback).

Testing

Verified live against the API in both session types: user sessions get the fallbacks/hints and clear errors, explicit --project-id overrides transmit correctly, admin sessions are unchanged. go test and build are clean.

Ticket: GPCO-49

f0086 and others added 2 commits August 17, 2026 16:19
Commands backed by admin gRPC endpoints previously failed with a raw
Keycloak role error for normal users, even when the API offers an
equivalent user-facing endpoint. Actions can now declare a fallback in
the YAML definition: in sessions without admin credentials the generated
command transparently calls the cloud endpoint instead (admin-project
list/get/nodes, operating-systems list). All other admin-only commands
now fail fast with a helpful hint (e.g. flavour list points to flavour
list-project) instead of a server-side permission error.

- add fallback/fallback-hint/admin-only to the generator YAML schema and
  emit a runtime dispatcher (RunAdmin/RunUser) per fallback action
- reject admin-only flags such as --search in user sessions with a clear
  error instead of silently dropping them
- register all commands regardless of the local admin configuration, so
  one binary serves both session types (removes generate-time CanCall)
- fix GPCORE_CONFIG being ignored: a second init() in pkg/config
  overwrote the env-provided config path with the default
- clarify the no-project-selected error to point to "project use"

Ticket: GPCO-49

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Live testing the admin-only hints from GPCO-49 showed that both hinted
alternatives were unusable as suggested. This makes them work out of the
box in user sessions.

- "flavour list-project" now takes --project-id (instead of --id) and
  defaults to the project selected via "project use", like the other
  project-scoped commands
- add an optional "field:" key to the generator param schema so a flag
  name can differ from the gRPC request field it fills (here: a
  --project-id flag filling the request field "Id")
- "image list-public" no longer requires the --flavour-id flag (marked
  deprecated and unused in the API) and defaults to no cloud-provider
  filter, so the bare command lists all public images instead of an
  empty AWS-filtered result
- the "flavour list" hint now points to "datacenter list" to resolve
  the required datacenter id

Breaking: "flavour list-project --id <uuid>" becomes --project-id.

Ticket: GPCO-49

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@f0086
f0086 requested a review from BirknerAlex August 18, 2026 08:49
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