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 status

Calls the API's health check, which needs no credential, then does what wardn whoami does.

api: ok
Ada Lovelace <[email protected]>
role: admin
LineMeaning
api: okThe API answered at the address you gave.
the name and emailWho 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 whoami

Prints your name and email, and your role in the organization:

Ada Lovelace <[email protected]>
role: admin

The 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 flagDefaultMeaning
<permission>noneRequired. A permission key, such as cluster:read, cluster:manage or pod:exec.
--scopeorgThe kind of place to ask about: org, team, environment, cluster, pipeline, app or deployment.
--onnoneThe id of that place. Required for every scope but org.

Ask about the organization

wardn can-i cluster:register
yes

Ask 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-2b1f0a9c7d10
no
you hold viewer there
error: not allowed

no 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
fi

Without --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

StatusMeaning
0The answer is yes.
1The 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.

Next

On this page