config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultClientConfigPath = userConfigDir() + string(os.PathSeparator) + "client.conf"
)
View Source
var ErrParserError = errors.New("parser error")

Functions

This section is empty.

Types

type Client

type Client struct {
	Server           []string `toml:"server,omitempty"`
	UserJWT          *string  `toml:"user_jwt,omitempty"`
	UserKey          *string  `toml:"user_key,omitempty"`
	AccountJWT       *string  `toml:"account_jwt,omitempty"`
	AccountKey       *string  `toml:"account_key,omitempty"`
	TLSCACertificate *string  `toml:"tls_ca_certificate,omitempty"`
}

func MergeClient

func MergeClient(confs ...*Client) *Client

func NewDefaultClient

func NewDefaultClient() (*Client, error)

func ParseClientFlags

func ParseClientFlags(fn func(string) (any, bool)) (*Client, error)

func (*Client) SetAccountJWT

func (c *Client) SetAccountJWT(jwt string)

func (*Client) SetAccountKey

func (c *Client) SetAccountKey(key string)

func (*Client) SetServer

func (c *Client) SetServer(server []string)

func (*Client) SetTLSCACert

func (c *Client) SetTLSCACert(cert string)

func (*Client) SetUserJWT

func (c *Client) SetUserJWT(jwt string)

func (*Client) SetUserKey

func (c *Client) SetUserKey(key string)

type Common

type Common struct {
	DataDir  *string `toml:"data_dir,omitempty"`
	LogLevel *string `toml:"log_level,omitempty"`
	NoColor  *bool   `toml:"no_color,omitempty"`
}

func MergeCommon

func MergeCommon(confs ...*Common) *Common

func NewDefaultCommon

func NewDefaultCommon() (*Common, error)

func ParseCommonFlags

func ParseCommonFlags(fn func(string) (any, bool)) (*Common, error)

func (*Common) SetDataDir

func (c *Common) SetDataDir(dataDir string)

func (*Common) SetLogLevel

func (c *Common) SetLogLevel(level string)

func (*Common) SetNoColor

func (c *Common) SetNoColor(noColor bool)

type Config

type Config struct {
	*Common `toml:",inline"`
	Client  *Client `toml:"client"`
	Server  *Server `toml:"server"`
}

func Merge

func Merge(confs ...*Config) *Config

func NewDefault

func NewDefault() (*Config, error)

func ParseFile

func ParseFile(file string) (*Config, error)

func ParseFlags

func ParseFlags(fn func(string) (any, bool)) (*Config, error)

func (*Config) Bytes

func (c *Config) Bytes() []byte

func (*Config) String

func (c *Config) String() string

type Server

type Server struct {
	Host             *string `toml:"host,omitempty"`
	Port             *int64  `toml:"port,omitempty"`
	OperatorJWT      *string `toml:"operator_jwt,omitempty"`
	OperatorKey      *string `toml:"operator_key,omitempty"`
	AccountJWT       *string `toml:"account_jwt,omitempty"`
	AccountKey       *string `toml:"account_key,omitempty"`
	SystemAccountJWT *string `toml:"system_account_jwt,omitempty"`
	SystemAccountKey *string `toml:"system_account_key,omitempty"`
	TLSCertificate   *string `toml:"tls_certificate,omitempty"`
	TLSKey           *string `toml:"tls_key,omitempty"`
}

func MergeServer

func MergeServer(confs ...*Server) *Server

func NewDefaultServer

func NewDefaultServer() (*Server, error)

func ParseServerFlags

func ParseServerFlags(fn func(string) (any, bool)) (*Server, error)

func (*Server) SetAccountJWT

func (s *Server) SetAccountJWT(jwt string)

func (*Server) SetAccountKey

func (s *Server) SetAccountKey(key string)

func (*Server) SetHost

func (s *Server) SetHost(host string)

func (*Server) SetOperatorJWT

func (s *Server) SetOperatorJWT(jwt string)

func (*Server) SetOperatorKey

func (s *Server) SetOperatorKey(key string)

func (*Server) SetPort

func (s *Server) SetPort(port int64)

func (*Server) SetSystemAccountJWT

func (s *Server) SetSystemAccountJWT(jwt string)

func (*Server) SetSystemAccountKey

func (s *Server) SetSystemAccountKey(key string)

func (*Server) SetTLSCert

func (s *Server) SetTLSCert(cert string)

func (*Server) SetTLSKey

func (s *Server) SetTLSKey(key string)

Jump to

Keyboard shortcuts

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