agent

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentConfig

type AgentConfig struct {
	Db   DbConfig         `embed:"" prefix:"db-" group:"db"`
	Grpc GrpcClientConfig `embed:"" prefix:"grpc-" group:"grpc"`
}

type DbConfig

type DbConfig struct {
	// The database names that are reserved and cannot be created.
	ReserveNames []string `default:"postgres,template0,template1"`

	// The pg instance host.
	HostTemplate string `env:"PG_HELPER_DB_HOST_TEMPLATE"`
	InstanceName string `env:"PG_HELPER_DB_INSTANCE"`
	// The pg instance port.
	Port int `default:"5432"`
	// The pg instance super user.
	User string `default:"postgres"`
	// The default database use by super user
	Name string `default:"postgres"`
	// The password of the super user.
	Password string `env:"PG_HELPER_DB_PASSWORD" name:"password"`
	// The file save the password
	PasswordFile string `env:"PG_HELPER_DB_PASSWORD_FILE"`
	// The max connections to the database.
	MaxConns int32 `default:"4"`

	// The path of the database backups.
	BackupRootPath string `default:"/var/lib/pg-helper/backups"`
	// The majar version of the database that pg-helper work with.
	CurrentVersion int32 `env:"PG_MAJOR"`
	// contains filtered or unexported fields
}

func (*DbConfig) AfterApply

func (c *DbConfig) AfterApply() error

func (*DbConfig) BackupDbDir

func (c *DbConfig) BackupDbDir(dbName string) string

func (*DbConfig) Host

func (c *DbConfig) Host(info *InstanceInfo) string

func (*DbConfig) IsReservedName

func (c *DbConfig) IsReservedName(name string) bool

func (*DbConfig) NewBackupFile

func (c *DbConfig) NewBackupFile(dbName string) string

The backup file is relative to the BackupRootPath

func (*DbConfig) NewPoolConfig

func (c *DbConfig) NewPoolConfig() *pgxpool.Config

func (*DbConfig) Url

func (c *DbConfig) Url(dbName string, info *InstanceInfo) string

func (*DbConfig) ValidateBackupPath

func (c *DbConfig) ValidateBackupPath(backupPath string, dbName string) (pgVersionInPath int32, err error)

type GrpcClientConfig

type GrpcClientConfig struct {
	Tls TlsConfig `embed:"" prefix:"tls-" group:"grpc-tls"`

	Url        string `validate:"required,grpcurl" help:"The url that grpc client to connect to"`
	ServerName string `validate:"omitempty,fqdn" help:"The server name that grpc client to connect to"`

	AuthTokenFile string `validate:"omitempty,file" env:"PG_HELPER_GRPC_AUTH_TOKEN_FILE" group:"grpc-auth"`
}

func (*GrpcClientConfig) AuthToken

func (g *GrpcClientConfig) AuthToken() (string, error)

type InstanceInfo

type InstanceInfo struct {
	InstanceName string
}

type TlsConfig

type TlsConfig struct {
	Enabled              bool   `default:"false" help:"Enable Tls"`
	ClientTrustedCaCerts string `validate:"omitempty,file" help:"Path to the client trusted ca certs"`

	MTLSEnabled bool   `name:"mtls-enabled" default:"false" help:"Enable mutual tls" group:"grpc-mtls"`
	ClientCert  string `validate:"required_if=MTLSEnabled true,omitempty,file" help:"Path to the client tls cert" group:"grpc-mtls"`
	ClientKey   string `validate:"required_if=MTLSEnabled true,omitempty,file" help:"Path to the client tls key" group:"grpc-mtls"`
}

func (*TlsConfig) Credentials

func (t *TlsConfig) Credentials() (credentials.TransportCredentials, error)

func (*TlsConfig) TlsConfig

func (t *TlsConfig) TlsConfig() (*tls.Config, error)

Jump to

Keyboard shortcuts

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