config

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TokenFileMode = 0600
)

Variables

This section is empty.

Functions

func AccessTokenPath

func AccessTokenPath() (string, error)

AccessTokenPath is the path for the access token file

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 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)

Types

type Config

type Config struct {
	AccessToken  string
	BaseURL      string
	Organization string

	ServiceTokenName 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() bool

func (*Config) NewClientFromConfig

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

NewClientFromConfig creates a PlaentScale API client from our configuration

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 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