accesstoken

package
v0.46.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package accesstoken holds the project access token workflows behind the volcano access-tokens subcommands.

Index

Constants

Scope values a token can be minted with.

View Source
const DefaultUsageDays = 30

DefaultUsageDays matches the API default for the usage series.

View Source
const MaxListLimit = 100

MaxListLimit matches the API's ceiling on a page size.

View Source
const MaxUsageDays = 60

MaxUsageDays matches the API's ceiling, which is also how long per-day counts are retained.

Variables

This section is empty.

Functions

func ParseExpiry

func ParseExpiry(value string) (*time.Time, error)

ParseExpiry converts an RFC3339 expiry flag into the API's optional expires_at. An empty value means the token never expires.

func Scopes

func Scopes() []string

Scopes returns the scopes a token can be minted with, for help text and flag validation.

func ValidateListWindow

func ValidateListWindow(page, limit int) error

ValidateListWindow rejects a page or page size outside what the contract allows, so a typo fails naming the flag the user typed rather than as whatever the API makes of it. Same reason as ValidateUsageDays, though unlike --days these values do at least reach the request.

func ValidateScope

func ValidateScope(scope string) error

ValidateScope rejects a scope the API does not define, so a typo fails before the request instead of as an opaque 400.

func ValidateUsageDays

func ValidateUsageDays(days int) error

ValidateUsageDays rejects a window the API does not accept.

The lower bound matters more than the upper one: a non-positive value used to be dropped from the request entirely, so asking for -5 days quietly returned the 30-day default with a success exit code — a plausible answer to a different question.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service performs authenticated Volcano project access token workflows.

func NewService

func NewService(deps cliruntime.Deps) Service

NewService returns a project access token service.

func (Service) Create

Create mints one access token in the current project.

func (Service) Get

func (s Service) Get(ctx context.Context, identifier string) (*apiclient.ProjectAccessToken, error)

Get returns one access token by name or ID.

func (Service) ListPage

ListPage returns one access token page in the current project.

func (Service) ProjectUsage

func (s Service) ProjectUsage(ctx context.Context, days int) ([]apiclient.ProjectAccessTokenUsage, error)

ProjectUsage returns the daily request counts for every access token in the current project, revoked tokens included.

The API admits a project access token on the usage reads, so this one is not account-scoped: a CI job holding nothing but the pt- token it runs with can still report its own consumption.

func (Service) Revoke

func (s Service) Revoke(ctx context.Context, token *apiclient.ProjectAccessToken) error

Revoke revokes a token the caller already resolved, so the token that was confirmed is the token that is revoked.

func (Service) TokenUsage

func (s Service) TokenUsage(ctx context.Context, tokenID uuid.UUID, days int) (*apiclient.ProjectAccessTokenUsage, error)

TokenUsage returns the daily request counts for one access token by ID, reading no metadata first.

That is what makes it reachable with a project access token: the API admits one on the usage routes but not on the token records, so the only route to a token's own day-by-day series is to address it by ID. Resolving a name needs the account-only list endpoint, so a CI job reporting its own consumption has to name the ID it was given when the token was minted.

func (Service) Usage

Usage returns the daily request counts for a token the caller already resolved.

It takes the token rather than the name the user typed because Get has resolved that by the time usage is wanted: resolving it again costs a second paginated walk, and a transient failure there would report a token that does not exist moments after reading it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL