Documentation
¶
Index ¶
- func ConfigDir() (string, error)
- func DefaultConfigPath() (string, error)
- func DeleteAccessToken() error
- func FilterProjectConfig(raw map[string]interface{}) (allowed map[string]interface{}, ignored []string)
- func LocalDir() (string, error)
- func MergeProjectConfig(v *viper.Viper, dir string) (ignored []string, err error)
- func ProjectConfigFile() string
- func ProjectConfigPath() (string, error)
- func RootGitRepoDir() (string, error)
- func WarnIgnoredProjectConfigKeys(path string, ignored []string)
- func WriteAccessToken(accessToken string) error
- type Config
- type ConfigFS
- type FileConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶
DefaultConfigPath returns the default path for the config file.
func DeleteAccessToken ¶ added in v0.125.0
func DeleteAccessToken() error
func FilterProjectConfig ¶ added in v0.306.0
func FilterProjectConfig(raw map[string]interface{}) (allowed map[string]interface{}, ignored []string)
FilterProjectConfig keeps only allowlisted project settings from raw YAML. Non-allowlisted keys are returned in ignored (sorted) for caller warnings.
func MergeProjectConfig ¶ added in v0.306.0
MergeProjectConfig reads dir/.pscale.yml and merges only allowlisted keys into v. Sensitive keys such as api-url / api-token / service-token are ignored. Missing files are a no-op. Returns the list of ignored keys (may be empty).
func ProjectConfigFile ¶ added in v0.9.0
func ProjectConfigFile() string
func ProjectConfigPath ¶ added in v0.2.0
ProjectConfigPath returns the path of a configuration inside a Git repository.
func RootGitRepoDir ¶ added in v0.9.0
func WarnIgnoredProjectConfigKeys ¶ added in v0.306.0
WarnIgnoredProjectConfigKeys prints a stderr warning when a project config tried to set keys outside the allowlist (especially credentials / api-url).
func WriteAccessToken ¶ added in v0.125.0
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 (*Config) IsAuthenticated ¶
func (*Config) NewClientFromConfig ¶
NewClientFromConfig creates a PlanetScale API client from our configuration
func (*Config) ServiceTokenIsSet ¶ added in v0.163.0
func (*Config) ServiceTokenIsSwapped ¶ added in v0.219.0
type ConfigFS ¶ added in v0.19.0
type ConfigFS struct {
// contains filtered or unexported fields
}
func NewConfigFS ¶ added in v0.19.0
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.