config

package
v0.206.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() (string, error)

ConfigDir is the directory for PlanetScale config.

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the default path for the config file.

func DeleteAccessToken added in v0.125.0

func DeleteAccessToken() error

func LocalDir added in v0.157.0

func LocalDir() (string, error)

LocalDir returns the path within the current working directory

func ProjectConfigFile added in v0.9.0

func ProjectConfigFile() string

func ProjectConfigPath added in v0.2.0

func ProjectConfigPath() (string, error)

ProjectConfigPath returns the path of a configuration inside a Git repository.

func RootGitRepoDir added in v0.9.0

func RootGitRepoDir() (string, error)

func WriteAccessToken added in v0.125.0

func WriteAccessToken(accessToken string) error

Types

type Config

type Config struct {
	AccessToken  string
	BaseURL      string
	Organization string

	ServiceTokenID string
	ServiceToken   string

	// Project Configuration
	Database string
	Branch   string
}

Config is dynamically sourced from various files and environment variables.

func New

func New() (*Config, error)

func (*Config) IsAuthenticated

func (c *Config) IsAuthenticated() error

func (*Config) NewClientFromConfig

func (c *Config) NewClientFromConfig(clientOpts ...ps.ClientOption) (*ps.Client, error)

NewClientFromConfig creates a PlanetScale API client from our configuration

func (*Config) ServiceTokenIsSet added in v0.163.0

func (c *Config) ServiceTokenIsSet() bool

type ConfigFS added in v0.19.0

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

func NewConfigFS added in v0.19.0

func NewConfigFS(fsys fs.FS) *ConfigFS

func (*ConfigFS) DefaultConfig added in v0.19.0

func (c *ConfigFS) DefaultConfig() (*FileConfig, error)

DefaultConfig returns the file config from the default config path.

func (*ConfigFS) NewFileConfig added in v0.19.0

func (c *ConfigFS) NewFileConfig(path string) (*FileConfig, error)

NewFileConfig reads the file config from the designated path and returns a new FileConfig.

func (*ConfigFS) ProjectConfig added in v0.19.0

func (c *ConfigFS) ProjectConfig() (*FileConfig, error)

ProjectConfig returns the file config from the git project

type FileConfig added in v0.9.0

type FileConfig struct {
	Organization string `yaml:"org" json:"org"`
	Database     string `yaml:"database,omitempty" json:"database,omitempty"`
	Branch       string `yaml:"branch,omitempty" json:"branch,omitempty"`
}

FileConfig defines a pscale configuration from a file.

func (*FileConfig) Write added in v0.9.0

func (f *FileConfig) Write(path string) error

Write persists the file config at the designated path.

func (*FileConfig) WriteDefault added in v0.9.0

func (f *FileConfig) WriteDefault() error

WriteDefault creates the config directory and persists the file config to the default global path.

func (*FileConfig) WriteProject added in v0.9.0

func (f *FileConfig) WriteProject() error

WriteProject persists the file config at the default path which is pulled from the root of the git repository if a user is in one.

Jump to

Keyboard shortcuts

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