token

package
v0.0.0-...-059d9f2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteCredentialsForBucket

func DeleteCredentialsForBucket(path string, bucketName string) error

DeleteCredentialsForBucket deletes credentials for a specific bucket from the credentials file

func SaveCredentialsForBucket

func SaveCredentialsForBucket(path string, bucketName string, creds S3Credentials) error

SaveCredentialsForBucket saves credentials for a specific bucket to the credentials file

func WriteCredentials

func WriteCredentials(credentials CredentialsMap, subdir string) error

WriteCredentials writes the credentials map to the credentials file for a given profile

func WriteProfiles

func WriteProfiles(profile Profile) error

func WriteSettings

func WriteSettings(settings Settings, subdir string) error

Types

type Config

type Config struct {
	Client HTTPClient
	Out    io.Writer
}

type CredentialsMap

type CredentialsMap map[string]S3Credentials

CredentialsMap is a map of bucket names to their S3 credentials

func ReadCredentials

func ReadCredentials(path string) (CredentialsMap, error)

ReadCredentials reads the credentials file for a given profile and returns a map of bucket names to credentials

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Profile

type Profile struct {
	Name string
}

func ReadProfiles

func ReadProfiles() (Profile, string, error)

type Response

type Response struct {
	Token     string `json:"token"`
	CreatedAt string `json:"created_at"`
	ExpiresAt string `json:"expires_at"`
}

type S3Credentials

type S3Credentials struct {
	S3AccessKey string `toml:"s3_access_key"`
	S3SecretKey string `toml:"s3_secret_key"`
}

S3Credentials represents the S3 credentials for a specific bucket

func GetCredentialsForBucket

func GetCredentialsForBucket(path string, bucketName string) (S3Credentials, bool, error)

GetCredentialsForBucket retrieves credentials for a specific bucket from the credentials file

type Settings

type Settings struct {
	Token                      string
	UUID                       string
	LastCheck                  time.Time
	LastVulcanVersion          string
	AuthorizeMetricsCollection int
	ClientId                   string
	Email                      string
	ContinuationToken          string
	S3AccessKey                string
	S3SecretKey                string
	S3Bucket                   string
	// Resolved API generation for this profile, cached to avoid asking the SSO
	// service on every invocation. Absent in settings files written by older
	// CLI versions, which simply reads as a cache miss.
	APIVersion          string
	APIVersionCheckedAt time.Time
	APIVersionTokenHash string
	APIVersionEpoch     int
}

func ReadSettings

func ReadSettings(path string) (Settings, error)

func (Settings) APIVersionCache

func (s Settings) APIVersionCache() apiversion.Cache

APIVersionCache reads the profile's cached API generation.

func (*Settings) SetAPIVersionCache

func (s *Settings) SetAPIVersionCache(c apiversion.Cache)

SetAPIVersionCache records a freshly resolved API generation on the profile.

type Token

type Token struct {
	Endpoint string
	// contains filtered or unexported fields
}

func New

func New(c *Config) *Token

func (*Token) Create

func (t *Token) Create(b64 string) (*Response, error)

func (*Token) Save

func (t *Token) Save(b []byte) (string, error)

func (*Token) Validate

func (t *Token) Validate(token *string) (bool, UserInfo, error)

type TokenInterface

type TokenInterface interface {
	Validate(token *string) (bool, UserInfo, error)
	Save(b []byte) (string, error)
	Create(b64 string) (*Response, error)
}

type TokenMock

type TokenMock struct {
}

func (*TokenMock) Create

func (m *TokenMock) Create(b64 string) (*Response, error)

func (*TokenMock) Save

func (m *TokenMock) Save(b []byte) (string, error)

func (*TokenMock) Validate

func (m *TokenMock) Validate(token *string) (bool, UserInfo, error)

type UserInfo

type UserInfo struct {
	Results struct {
		ClientID string `json:"client_id"`
		Email    string `json:"email"`
	} `json:"results"`
}

Jump to

Keyboard shortcuts

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