config

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigPath added in v0.9.0

func DefaultConfigPath() (string, error)

func DefaultValidator added in v0.9.0

func DefaultValidator(cfg *Config) error

func GetConfigDir

func GetConfigDir() (string, error)

func SanitizeInput

func SanitizeInput(input string) string

SanitizeInput trims whitespaces and newlines from a string.

func XdgConfigPath added in v0.9.0

func XdgConfigPath() (string, error)

helper function to get the XDG config path.

Types

type APIKeyStorage added in v0.9.0

type APIKeyStorage interface {
	GetAPIKey() (string, error)
	SetAPIKey(apiKey string) error
	ClearAPIKey() error
}

type ClientProvider added in v0.9.0

type ClientProvider interface {
	NewClientFromConfig() (*openai.Client, error)
}

type Config

type Config struct {
	Endpoint        string `yaml:"endpoint"`
	ModelDeployment string `yaml:"modelDeployment"`
	ExcludeGitDir   bool   `yaml:"excludeGitDir"`
	UseGitignore    bool   `yaml:"useGitignore"`
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(endpoint, modelDeployment string) *Config

NewConfig creates a new Config object.

func (*Config) APIKey

func (c *Config) APIKey() string

APIKey returns the confidential field apiKey.

func (*Config) SetAPIKey

func (c *Config) SetAPIKey(apiKey string)

SetAPIKey sets the confidential field apiKey.

type DefaultProvider added in v0.9.0

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

func NewDefaultProvider added in v0.9.0

func NewDefaultProvider() *DefaultProvider

func NewDefaultProviderWithOptions added in v0.9.0

func NewDefaultProviderWithOptions(opts DefaultProviderOptions) *DefaultProvider

func (*DefaultProvider) ClearConfig added in v0.9.0

func (c *DefaultProvider) ClearConfig() error

func (*DefaultProvider) GetConfig added in v0.9.0

func (c *DefaultProvider) GetConfig() (*Config, error)

func (*DefaultProvider) GetConfigDir added in v0.9.0

func (c *DefaultProvider) GetConfigDir() (string, error)

func (*DefaultProvider) NewFromConfigFile added in v0.9.0

func (c *DefaultProvider) NewFromConfigFile() (openai.ClientConfig, error)

func (*DefaultProvider) SaveConfig added in v0.9.0

func (c *DefaultProvider) SaveConfig(config *Config) error

type DefaultProviderOptions added in v0.9.0

type DefaultProviderOptions struct {
	ConfigPath  string
	FileManager FileManager
	Marshaller  Marshaller
	Validator   Validator
	KeyStore    APIKeyStorage
}

type FileManager added in v0.9.0

type FileManager interface {
	Read(path string) ([]byte, error)
	Write(path string, content []byte, perm os.FileMode) error
}

type FileReader added in v0.9.0

type FileReader func(path string) ([]byte, error)

type KeyRingAPIKeyStorage added in v0.9.0

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

func NewKeyRingAPIKeyStorage added in v0.9.0

func NewKeyRingAPIKeyStorage(serviceName string, usernameRetriever UsernameRetriever) *KeyRingAPIKeyStorage

func (*KeyRingAPIKeyStorage) ClearAPIKey added in v0.9.0

func (k *KeyRingAPIKeyStorage) ClearAPIKey() error

func (*KeyRingAPIKeyStorage) GetAPIKey added in v0.9.0

func (k *KeyRingAPIKeyStorage) GetAPIKey() (string, error)

func (*KeyRingAPIKeyStorage) SetAPIKey added in v0.9.0

func (k *KeyRingAPIKeyStorage) SetAPIKey(apiKey string) error

type Marshaller added in v0.9.0

type Marshaller interface {
	Unmarshal(in []byte, out interface{}) error
	Marshal(in interface{}) ([]byte, error)
}

type OSFileManager added in v0.9.0

type OSFileManager struct{}

func (*OSFileManager) Read added in v0.9.0

func (y *OSFileManager) Read(path string) ([]byte, error)

func (*OSFileManager) Write added in v0.9.0

func (y *OSFileManager) Write(path string, content []byte, perm os.FileMode) error

type OpenAIClientProvider added in v0.9.0

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

func NewOpenAIClientProvider added in v0.9.0

func NewOpenAIClientProvider(provider Provider) *OpenAIClientProvider

func (*OpenAIClientProvider) NewClientFromConfig added in v0.9.0

func (c *OpenAIClientProvider) NewClientFromConfig() (*openai.Client, error)

type Parser added in v0.9.0

type Parser func(in []byte, out interface{}) error

type Provider added in v0.9.0

type Provider interface {
	GetConfig() (*Config, error)
	NewFromConfigFile() (openai.ClientConfig, error)
	GetConfigDir() (string, error)
	SaveConfig(config *Config) error
	ClearConfig() error
}

type UsernameRetriever added in v0.9.0

type UsernameRetriever func() (*user.User, error)

type Validator added in v0.9.0

type Validator func(cfg *Config) error

type YamlMarshaller added in v0.9.0

type YamlMarshaller struct{}

func (*YamlMarshaller) Marshal added in v0.9.0

func (y *YamlMarshaller) Marshal(data interface{}) ([]byte, error)

func (*YamlMarshaller) Unmarshal added in v0.9.0

func (y *YamlMarshaller) Unmarshal(data []byte, out interface{}) error

Jump to

Keyboard shortcuts

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