profile

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package profile stores non-secret Jira Cloud connection metadata.

Profile selection is deliberately explicit for every invocation. This package has no active or default profile state.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProfileRequired means a caller did not explicitly select a profile.
	ErrProfileRequired = errors.New("a profile is required for every invocation")
	// ErrInvalidProfile means profile metadata failed validation.
	ErrInvalidProfile = errors.New("invalid profile")
	// ErrNotFound means the requested profile is not registered.
	ErrNotFound = errors.New("profile not found")
	// ErrAlreadyExists means Add would overwrite an existing profile.
	ErrAlreadyExists = errors.New("profile already exists")
	// ErrCorruptRegistry means the registry cannot be decoded or validated.
	ErrCorruptRegistry = errors.New("profile registry is corrupt")
	// ErrInsecurePermissions means registry metadata is accessible too broadly.
	ErrInsecurePermissions = errors.New("profile registry has insecure permissions")
)

Functions

func RequireName

func RequireName(name string) error

RequireName validates the mandatory per-invocation profile selection.

func ValidateName

func ValidateName(name string) error

ValidateName validates a profile name for exact use as a Keychain account.

func WasCommitted

func WasCommitted(err error) bool

WasCommitted identifies a post-rename registry failure.

Types

type CommitError

type CommitError struct {
	Err error
}

CommitError reports that a registry mutation reached its atomic rename but a subsequent durability step failed. Callers must treat the requested metadata state as committed and must not compensate it as a pre-commit failure.

func (*CommitError) Error

func (e *CommitError) Error() string

func (*CommitError) Unwrap

func (e *CommitError) Unwrap() error

type Profile

type Profile struct {
	Name      string     `json:"name"`
	Site      string     `json:"site"`
	Email     string     `json:"email"`
	TokenKind TokenKind  `json:"token_kind"`
	CloudID   string     `json:"cloud_id,omitempty"`
	ExpiresAt *time.Time `json:"expires_at,omitempty"`
}

Profile contains only non-secret Jira Cloud connection metadata.

func (Profile) Validate

func (p Profile) Validate() error

Validate checks all profile metadata.

type Registry

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

Registry persists profiles in a strict, non-secret JSON file.

func NewDefaultRegistry

func NewDefaultRegistry() (*Registry, error)

NewDefaultRegistry creates the default user-scoped registry.

func NewRegistry

func NewRegistry(path string) *Registry

NewRegistry creates a registry at an explicit path.

func (*Registry) Add

func (r *Registry) Add(ctx context.Context, p Profile) error

Add registers p without overwriting an existing profile.

func (*Registry) Get

func (r *Registry) Get(ctx context.Context, name string) (Profile, error)

Get returns one explicitly named profile.

func (*Registry) List

func (r *Registry) List(ctx context.Context) ([]Profile, error)

List returns all registered profiles sorted by name.

func (*Registry) Path

func (r *Registry) Path() string

Path returns the registry path.

func (*Registry) Put

func (r *Registry) Put(ctx context.Context, p Profile) error

Put registers p, replacing metadata for the same profile name.

func (*Registry) Remove

func (r *Registry) Remove(ctx context.Context, name string) error

Remove deletes one profile from the registry.

func (*Registry) WithProfileLock

func (r *Registry) WithProfileLock(ctx context.Context, name string, fn func() error) error

WithProfileLock serializes a complete credential+metadata transaction for one profile across jira-cli processes. The lock is distinct from the registry file's short read-modify-write lock.

type TokenKind

type TokenKind string

TokenKind identifies the Jira API token authentication scheme.

const (
	// TokenKindClassic is a standard Atlassian API token used with the site URL.
	TokenKindClassic TokenKind = "classic"
	// TokenKindScoped is a scoped Atlassian API token used with a cloud ID.
	TokenKindScoped TokenKind = "scoped"
)

Jump to

Keyboard shortcuts

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