config

package
v0.1.7-dev8 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIEndpoint    = "api.scale.sh"
	DefaultAuthEndpoint   = "auth.scale.sh"
	DefaultUIEndpoint     = "scale.sh"
	DefaultUpdateEndpoint = "dl.scale.sh"
	DefaultSessionDomain  = "scale.sh"
)

Variables

View Source
var (
	ErrAPIEndpointRequired    = errors.New("api endpoint is required")
	ErrAuthEndpointRequired   = errors.New("auth endpoint is required")
	ErrUpdateEndpointRequired = errors.New("update endpoint is required")
	ErrUIEndpointRequired     = errors.New("ui endpoint is required")
	ErrSessionDomainRequired  = errors.New("session domain is required")

	ErrNoSession = errors.New("no session found")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	APIEndpoint       string           `mapstructure:"api_endpoint"`
	AuthEndpoint      string           `mapstructure:"auth_endpoint"`
	UIEndpoint        string           `mapstructure:"ui_endpoint"`
	UpdateEndpoint    string           `mapstructure:"update_endpoint"`
	SessionDomain     string           `mapstructure:"session_domain"`
	DisableAutoUpdate bool             `mapstructure:"disable_auto_update"`
	NoTelemetry       bool             `mapstructure:"no_telemetry"`
	StorageDirectory  string           `mapstructure:"storage_directory"`
	Session           *session.Session `mapstructure:"-"`
	// contains filtered or unexported fields
}

Config is dynamically sourced from various files and environment variables.

func New

func New() *Config

func (*Config) APIClient

func (c *Config) APIClient() *apiClient.ScaleAPIV1

func (*Config) AuthClient

func (c *Config) AuthClient() *authClient.AuthAPIV1

func (*Config) DefaultConfigDir

func (c *Config) DefaultConfigDir() (string, error)

func (*Config) DefaultConfigFile

func (c *Config) DefaultConfigFile() string

func (*Config) DefaultConfigPath

func (c *Config) DefaultConfigPath() (string, error)

func (*Config) DefaultLogFile

func (c *Config) DefaultLogFile() string

func (*Config) DefaultLogPath

func (c *Config) DefaultLogPath() (string, error)

func (*Config) GetConfigFile

func (c *Config) GetConfigFile() string

func (*Config) GetLogFile

func (c *Config) GetLogFile() string

func (*Config) GlobalRequiredFlags

func (c *Config) GlobalRequiredFlags(_ *cobra.Command) error

func (*Config) IsAuthenticated

func (c *Config) IsAuthenticated() bool

func (*Config) NewAuthenticatedAPIClient

func (c *Config) NewAuthenticatedAPIClient() (*apiClient.ScaleAPIV1, error)

NewAuthenticatedAPIClient creates an Authenticated Scale API client from our configuration

func (*Config) NewAuthenticatedAuthClient

func (c *Config) NewAuthenticatedAuthClient() (*authClient.AuthAPIV1, error)

NewAuthenticatedAuthClient creates an Authenticated Scale Auth API client from our configuration

func (*Config) NewUnauthenticatedAPIClient

func (c *Config) NewUnauthenticatedAPIClient() *apiClient.ScaleAPIV1

NewUnauthenticatedAPIClient creates an Unauthenticated Scale API client from our configuration

func (*Config) NewUnauthenticatedAuthClient

func (c *Config) NewUnauthenticatedAuthClient() *authClient.AuthAPIV1

NewUnauthenticatedAuthClient creates an Unauthenticated Scale Auth API client from our configuration

func (*Config) RootPersistentFlags

func (c *Config) RootPersistentFlags(flags *pflag.FlagSet)

func (*Config) SessionCookieURL added in v0.1.7

func (c *Config) SessionCookieURL() *url.URL

func (*Config) SessionPath

func (c *Config) SessionPath() (string, error)

SessionPath is the path for the session file

func (*Config) SetAPIClient

func (c *Config) SetAPIClient(apiClient *apiClient.ScaleAPIV1)

func (*Config) SetAuthClient

func (c *Config) SetAuthClient(authClient *authClient.AuthAPIV1)

func (*Config) SetConfigFile

func (c *Config) SetConfigFile(file string)

func (*Config) SetLogFile

func (c *Config) SetLogFile(file string)

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) WriteSession

func (c *Config) WriteSession() error

Jump to

Keyboard shortcuts

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