wardn status, whoami and can-i
Check that the API answers, who your token acts as, and whether you hold a permission, before you try the thing that needs it.
Three small commands answer "is this set up right?" before you run something bigger. wardn status checks the connection, wardn whoami says who your token acts as, and wardn can-i asks whether that person may do a particular thing. Set up the CLI first (CLI).
They call the API only; they change nothing. Each takes the global flags and no others, except can-i.
wardn status
wardn statusCalls the API's health check, which needs no credential, then does what wardn whoami does.
api: ok
Ada Lovelace <[email protected]>
role: admin| Line | Meaning |
|---|---|
api: ok | The API answered at the address you gave. |
| the name and email | Who your token acts as. |
role: ... | Your organization role. |
The first line prints before your token is checked. So api: ok followed by an error means the address is right and the token is not:
api: ok
error: whoami: wardn API error: Sign in to use this API. (auth.required, HTTP 401)An address that is wrong or unreachable stops it at the first step, with error: health: reach the API at <address>: .... Use status as the first thing to run when a script cannot reach Wardn.
wardn whoami
wardn whoamiPrints your name and email, and your role in the organization:
Ada Lovelace <[email protected]>
role: adminThe role is one of owner, admin, contributor or viewer. It is the organization-wide role, not the whole picture: you may hold more on a team, an environment or a single deployment through grants. To ask about a particular place, use can-i.
An API token acts as the person who made it, with a ceiling on what it may do, so whoami shows that person. A permission the token's ceiling leaves out is refused even though the person holds it.
wardn can-i
wardn can-i <permission> [--scope <kind> --on <id>]Asks whether you hold a permission, in the organization or on one place, and prints yes or no. It is the same question the API asks before it does anything, so it is the quickest way to find out why a command or a call was refused. Permissions lists every permission key.
| Argument or flag | Default | Meaning |
|---|---|---|
<permission> | none | Required. A permission key, such as cluster:read, cluster:manage or pod:exec. |
--scope | org | The kind of place to ask about: org, team, environment, cluster, pipeline, app or deployment. |
--on | none | The id of that place. Required for every scope but org. |
Ask about the organization
wardn can-i cluster:registeryesAsk about one place
A role or grant on a team, environment, cluster or deployment reaches only that place and what sits under it, so a permission can be yes in one place and no in another:
wardn can-i cluster:manage --scope cluster --on 6f0c2a1e-8d5b-4c3a-9e47-2b1f0a9c7d10no
you hold viewer there
error: not allowedno is printed on standard output. The reason, in words for a person, and error: not allowed go to standard error. The exit status is 1, so a script can test it:
if wardn can-i deployment:manage --scope deployment --on "$DEPLOYMENT_ID"; then
wardn exec checkout -- ls /app
fiWithout --on, a scope other than org stops with --on (the id of the scope target) is required unless --scope is org, before it calls anything. Get ids from the web app, or from wardn clusters for clusters.
Exit status
| Status | Meaning |
|---|---|
0 | The answer is yes. |
1 | The answer is no, or the question could not be asked (no API address, a bad token). The first case prints no; the others print error: .... |
Most permissions are held on a place, such as a deployment, so ask with --scope and --on to see the answer that matters. A few, such as pod:exec, are never part of an organization role and are held only by a grant that names them.