Fallback to user endpoints when not logged in as admin - #204
Open
f0086 wants to merge 2 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
fallbackin the YAML definition: sessions without admin credentials transparently call the equivalentcloud.*endpoint instead (admin-project list/get/nodes, operating-systems list).flavour list-projecttakes--project-idand defaults to the project selected viaproject use(new genericfield:mapping in the generator, since the proto names the field justid)image list-publicno longer requires the deprecated--flavour-idflag and defaults to no cloud-provider filter, so the bare command lists all public images instead of an empty AWS-filtered resultproject use/--project-id, and fixedGPCORE_CONFIGbeing ignored due to a duplicateinit().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-idoverrides transmit correctly, admin sessions are unchanged.go testand build are clean.Ticket: GPCO-49