shared

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2024 License: GPL-3.0 Imports: 3 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 {
	// Value is the token value.
	Value 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) 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