shared

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package shared contains shared provider implementations. Largely stored in this package to avoid circular dependencies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvProvider

type EnvProvider struct {
	// EnvVars is a list of environment variables to check for a token.
	EnvVars []EnvVar
}

EnvProvider implements the [token.Provider] interface using the environment variables to retrieve a token.

func (*EnvProvider) Token

func (p *EnvProvider) Token() (*Token, error)

Token returns a valid token or an error if no token is found.

type EnvVar

type EnvVar struct {
	// Name is the name of the environment variable.
	Name string

	// Type is an optional field that denotes what type of token this.
	Type string
}

EnvVar is a struct that represents an environment variable that can contain a VCS token.

type Provider

type Provider interface {
	// Token returns a valid token or an error if no token is found.
	Token() (*Token, error)
}

Provider is an interface for VCS providers to implement to provide a token from a user's machine.

type Token

type Token struct {
	// FetchedAt is the time that the token was fetched at. This does not
	// need to be set by providers as it is set by the [token.Fetch]
	// function.
	FetchedAt time.Time

	// Value is the token value.
	Value string

	// Source is the source of the token, this is set depending on the
	// provider that provided the token (e.g., `gh` for the Github CLI).
	Source string

	// Type is the type of the token, this is set depending on the
	// provider that provided the token.
	Type string
}

Token is a VCS token that can be used for API access.

Do not use the 'shared.Token' type, instead use [token.Token] which is an alias to this type.

func (*Token) Clone added in v0.4.0

func (t *Token) Clone() *Token

Clone returns a deep clone of the token.

func (*Token) IsUnauthenticated added in v0.1.2

func (t *Token) IsUnauthenticated() bool

IsUnauthenticated returns true if the token is empty.

func (*Token) String

func (t *Token) String() string

String returns a redacted version of the token to prevent accidental logging.

Jump to

Keyboard shortcuts

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