Documentation ¶
Index ¶
- Constants
- func Defaults() (context.Context, *http.Client)
- func FromAPIKey(ctx context.Context, client *http.Client) func(string, string, string) (Session, error)
- func FromAPIToken(_ context.Context, client *http.Client) func(string, string) (Session, error)
- func FromEnvironment(ctx context.Context, client *http.Client) func(func(string) (string, bool)) (Session, error)
- func FromGitHubToken(ctx context.Context, client *http.Client) func(string, string) (Session, error)
- type CredentialsType
- type Profile
- type ProfileManager
- func (m *ProfileManager) Create(profile *Profile) error
- func (m *ProfileManager) Current() *Profile
- func (m *ProfileManager) Delete(profileAlias string) error
- func (m *ProfileManager) Get(profileAlias string) (*Profile, error)
- func (m *ProfileManager) GetAll() []*Profile
- func (m *ProfileManager) Select(profileAlias string) error
- type Session
- type StoredCredentials
Constants ¶
const ( // EnvSpaceliftAPIEndpoint represents the name of the environment variable // pointing to the Spacelift API endpoint. // // Deprecated EnvSpaceliftAPIEndpoint = "SPACELIFT_API_ENDPOINT" // EnvSpaceliftAPIKeyEndpoint represents the name of the environment variable // pointing to the Spacelift API endpoint. EnvSpaceliftAPIKeyEndpoint = "SPACELIFT_API_KEY_ENDPOINT" //nolint: gosec // EnvSpaceliftAPIKeyID represents the name of the environment variable // pointing to the Spacelift API key ID. EnvSpaceliftAPIKeyID = "SPACELIFT_API_KEY_ID" //nolint: gosec // EnvSpaceliftAPIKeySecret represents the name of the environment variable // pointing to the Spacelift API key secret. EnvSpaceliftAPIKeySecret = "SPACELIFT_API_KEY_SECRET" // #nosec G101 // EnvSpaceliftAPIToken represents the name of the environment variable // pointing to the Spacelift API token. EnvSpaceliftAPIToken = "SPACELIFT_API_TOKEN" // #nosec G101 // EnvSpaceliftAPIGitHubToken represents the name of the environment variable // pointing to the GitHub access token used to get the Spacelift API token. EnvSpaceliftAPIGitHubToken = "SPACELIFT_API_GITHUB_TOKEN" // #nosec G101 )
const ( // SpaceliftConfigDirectory is the name of the Spacelift config directory. SpaceliftConfigDirectory = ".spacelift" // ConfigFileName is the name of the file containing the spacectl config. ConfigFileName = "config.json" )
Variables ¶
This section is empty.
Functions ¶
func Defaults ¶
Defaults returns default context and HTTP client to use by clients that don't need any further configuration.
func FromAPIKey ¶
func FromAPIKey(ctx context.Context, client *http.Client) func(string, string, string) (Session, error)
FromAPIKey builds a Spacelift session from a combination of endpoint, API key ID and API key secret.
func FromAPIToken ¶
FromAPIToken creates a session from a ready API token.
Types ¶
type CredentialsType ¶
type CredentialsType uint
CredentialsType represents the type of credentials being used.
const ( // CredentialsTypeInvalid represents an invalid zero value for the // CredentialsType. CredentialsTypeInvalid CredentialsType = iota // CredentialsTypeAPIKey represents credentials stored as an API key // id-secret pair. CredentialsTypeAPIKey // CredentialsTypeGitHubToken represents credentials stored as a GitHub // access token. CredentialsTypeGitHubToken // CredentialsTypeAPIToken represents credentials stored as a JWT // access token. CredentialsTypeAPIToken )
func (CredentialsType) String ¶
func (t CredentialsType) String() string
String returns the string representation of the type.
type Profile ¶
type Profile struct { // The alias (name) of the profile. Alias string `json:"alias,omitempty"` // The credentials used to make Spacelift API requests. Credentials *StoredCredentials `json:"credentials,omitempty"` }
A Profile represents a spacectl profile which is used to store credential information for accessing Spacelift.
type ProfileManager ¶
type ProfileManager struct { // The full path to the spacectl config file. ConfigurationFile string // The spacectl configuration. Configuration *configuration }
A ProfileManager is used to interact with Spacelift profiles.
func NewProfileManager ¶
func NewProfileManager(profilesDirectory string) (*ProfileManager, error)
NewProfileManager creates a new ProfileManager using the specified directory to store the profile data.
func UserProfileManager ¶ added in v0.17.3
func UserProfileManager() (*ProfileManager, error)
UserProfileManager creates a new ProfileManager using the user home directory to store the profile data.
func (*ProfileManager) Create ¶
func (m *ProfileManager) Create(profile *Profile) error
Create adds a new Spacelift profile.
func (*ProfileManager) Current ¶
func (m *ProfileManager) Current() *Profile
Current gets the user's currently selected profile, and returns nil if no profile is selected.
func (*ProfileManager) Delete ¶
func (m *ProfileManager) Delete(profileAlias string) error
Delete removes the profile with the specified alias, and un-selects it as the current profile if it was selected.
func (*ProfileManager) Get ¶
func (m *ProfileManager) Get(profileAlias string) (*Profile, error)
Get returns the profile with the specified alias, returning nil if that profile does not exist.
func (*ProfileManager) GetAll ¶
func (m *ProfileManager) GetAll() []*Profile
GetAll returns all the currently stored profiles, returning an empty slice if no profiles exist.
func (*ProfileManager) Select ¶
func (m *ProfileManager) Select(profileAlias string) error
Select sets the currently selected profile.
type Session ¶
type Session interface { BearerToken(ctx context.Context) (string, error) Endpoint() string Type() CredentialsType }
Session is an abstraction around session creation based on credentials from various sources.
func FromCurrentProfile ¶
FromCurrentProfile creates a session from credentials stored in the currently selected profile.
type StoredCredentials ¶
type StoredCredentials struct { Type CredentialsType `json:"type,omitempty"` Endpoint string `json:"endpoint,omitempty"` AccessToken string `json:"access_token,omitempty"` KeyID string `json:"key_id,omitempty"` KeySecret string `json:"key_secret,omitempty"` }
StoredCredentials is a filesystem representation of the credentials.