profiles

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: BSD-3-Clause-Clear Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STORE_KEY_PROFILE = "profile"
	STORE_KEY_GLOBAL  = "global"
)
View Source
const (
	PROFILE_DRIVER_KEYRING   = "keyring"
	PROFILE_DRIVER_IN_MEMORY = "in-memory"
	PROFILE_DRIVER_DEFAULT   = PROFILE_DRIVER_KEYRING
)
View Source
const (
	PROFILE_AUTH_TYPE_CLIENT_CREDENTIALS = "client-credentials"
	PROFILE_AUTH_TYPE_ACCESS_TOKEN       = "access-token"
)
View Source
const PROFILES_VERSION_LATEST = PROFILES_VERSION_v1_0
View Source
const PROFILES_VERSION_v1_0 = "1.0"

This variable is used to store the version of the profiles. Since the profiles structure might change in the future, this variable is used to keep track of the version of the profiles and will be used to determine how to handle migration of the profiles.

Variables

View Source
var ErrDeletingDefaultProfile = errors.New("cannot delete the default profile")

Functions

func WithInMemoryStore

func WithInMemoryStore() profileConfigVariadicFunc

func WithKeyringStore

func WithKeyringStore() profileConfigVariadicFunc

Types

type AuthCredentials

type AuthCredentials struct {
	AuthType string `json:"authType"`
	ClientId string `json:"clientId"`
	// Used for client credentials
	ClientSecret string                     `json:"clientSecret,omitempty"`
	AccessToken  AuthCredentialsAccessToken `json:"accessToken,omitempty"`
}

type AuthCredentialsAccessToken

type AuthCredentialsAccessToken struct {
	PublicClientID string `json:"publicClientId"`
	AccessToken    string `json:"accessToken"`
	RefreshToken   string `json:"refreshToken"`
	Expiration     int64  `json:"expiration"`
}

type CurrentProfileStore

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

type GlobalConfig

type GlobalConfig struct {
	ProfilesVersion string   `json:"version"`
	Profiles        []string `json:"profiles"`
	DefaultProfile  string   `json:"defaultProfile"`
}

type GlobalStore

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

func LoadGlobalConfig

func LoadGlobalConfig(newStore func(string, string) StoreInterface) (*GlobalStore, error)

load global config or create a new one

func (*GlobalStore) AddProfile

func (p *GlobalStore) AddProfile(profileName string) error

func (*GlobalStore) GetDefaultProfile

func (p *GlobalStore) GetDefaultProfile() string

func (*GlobalStore) ListProfiles

func (p *GlobalStore) ListProfiles() []string

func (*GlobalStore) ProfileExists

func (p *GlobalStore) ProfileExists(profileName string) bool

func (*GlobalStore) RemoveProfile

func (p *GlobalStore) RemoveProfile(profileName string) error

func (*GlobalStore) SetDefaultProfile

func (p *GlobalStore) SetDefaultProfile(profileName string) error

type KeyringStore

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

func (*KeyringStore) Delete

func (k *KeyringStore) Delete() error

func (*KeyringStore) Exists

func (k *KeyringStore) Exists() bool

func (*KeyringStore) Get

func (k *KeyringStore) Get(value interface{}) error

func (*KeyringStore) Set

func (k *KeyringStore) Set(value interface{}) error

type MemoryStore

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

func (*MemoryStore) Delete

func (k *MemoryStore) Delete() error

func (*MemoryStore) Exists

func (k *MemoryStore) Exists() bool

func (*MemoryStore) Get

func (k *MemoryStore) Get(value interface{}) error

func (*MemoryStore) Set

func (k *MemoryStore) Set(value interface{}) error

type NewStoreInterface

type NewStoreInterface func(namespace string, key string) StoreInterface
var NewKeyringStore NewStoreInterface = func(namespace string, key string) StoreInterface {
	return &KeyringStore{
		namespace: namespace,
		key:       key,
	}
}
var NewMemoryStore NewStoreInterface = func(namespace string, key string) StoreInterface {
	memory := make(map[string]interface{})
	return &MemoryStore{
		namespace: namespace,
		key:       key,
		memory:    &memory,
	}
}

NewMemoryStore creates a new in-memory store JSON is used to serialize the data to ensure the interface is consistent with other store implementations

type Profile

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

func New

func New(opts ...profileConfigVariadicFunc) (*Profile, error)

create a new profile and load global config

func (*Profile) AddProfile

func (p *Profile) AddProfile(profileName string, endpoint string, tlsNoVerify bool, setDefault bool) error

func (*Profile) DeleteProfile

func (p *Profile) DeleteProfile(profileName string) error

func (*Profile) GetCurrentProfile

func (p *Profile) GetCurrentProfile() (*ProfileStore, error)

func (*Profile) GetGlobalConfig

func (p *Profile) GetGlobalConfig() *GlobalStore

func (*Profile) GetProfile

func (p *Profile) GetProfile(profileName string) (*ProfileStore, error)

func (*Profile) ListProfiles

func (p *Profile) ListProfiles() []string

func (*Profile) SetDefaultProfile

func (p *Profile) SetDefaultProfile(profileName string) error

func (*Profile) UseDefaultProfile

func (p *Profile) UseDefaultProfile() (*ProfileStore, error)

func (*Profile) UseProfile

func (p *Profile) UseProfile(profileName string) (*ProfileStore, error)

type ProfileConfig

type ProfileConfig struct {
	Name            string          `json:"profile"`
	Endpoint        string          `json:"endpoint"`
	TlsNoVerify     bool            `json:"tlsNoVerify"`
	AuthCredentials AuthCredentials `json:"authCredentials"`
}

type ProfileStore

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

func LoadProfileStore

func LoadProfileStore(newStore NewStoreInterface, profileName string) (*ProfileStore, error)

func NewProfileStore

func NewProfileStore(newStore NewStoreInterface, profileName string, endpoint string, tlsNoVerify bool) (*ProfileStore, error)

func (*ProfileStore) Delete

func (p *ProfileStore) Delete() error

func (*ProfileStore) Get

func (p *ProfileStore) Get() error

func (*ProfileStore) GetAuthCredentials

func (p *ProfileStore) GetAuthCredentials() AuthCredentials

func (*ProfileStore) GetEndpoint

func (p *ProfileStore) GetEndpoint() string

Endpoint

func (*ProfileStore) GetProfileName

func (p *ProfileStore) GetProfileName() string

Profile Name

func (*ProfileStore) GetTLSNoVerify

func (p *ProfileStore) GetTLSNoVerify() bool

TLS No Verify

func (*ProfileStore) Save

func (p *ProfileStore) Save() error

func (*ProfileStore) SetAuthCredentials

func (p *ProfileStore) SetAuthCredentials(authCredentials AuthCredentials) error

func (*ProfileStore) SetEndpoint

func (p *ProfileStore) SetEndpoint(endpoint string) error

func (*ProfileStore) SetTLSNoVerify

func (p *ProfileStore) SetTLSNoVerify(tlsNoVerify bool) error

type StoreInterface

type StoreInterface interface {
	Exists() bool
	Get(value interface{}) error
	Set(value interface{}) error
	Delete() error
}

Jump to

Keyboard shortcuts

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