pvm

package
v0.0.0-...-a962987 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0, MIT Imports: 25 Imported by: 0

Documentation

Overview

Package pvm logging.go from github.com/fergusstrange/embedded-postgres and modified (so should be considered under same license)

Package pvm these functions from github.com/fergusstrange/embedded-postgres and modified (so should be considered under same license)

Package pvm version_strategy.go from github.com/fergusstrange/embedded-postgres and modified (so should be considered under same license)

Index

Constants

View Source
const CmdQuoteChar = '\''
View Source
const NumberOfPostgresVersions uintptr = 140

Variables

View Source
var PostgresVersions [NumberOfPostgresVersions]string = [NumberOfPostgresVersions]string{}/* 140 elements not displayed */

Functions

func DownloadSubcommand

func DownloadSubcommand(args *Args, cacheLocation *string) error

func EnvSubcommand

func EnvSubcommand(config *ConfigStruct) string

func FieldAndValueWhenNonDefaultValue

func FieldAndValueWhenNonDefaultValue(configStruct *ConfigStruct) map[string]interface{}

func GetPathSubcommand

func GetPathSubcommand(directoryToFind *string, config *ConfigStruct) (string, error)

func InstallServiceSubcommand

func InstallServiceSubcommand(args *Args) error

func InstallSubcommand

func InstallSubcommand(args *Args, cacheLocation *string) error

func LsRemoteSubcommand

func LsRemoteSubcommand(args *Args) error

func LsSubcommand

func LsSubcommand(args *Args) error

func PingSubcommand

func PingSubcommand(config *ConfigStruct) error

func PostgresVersionFromLocalOrGlobal

func PostgresVersionFromLocalOrGlobal(localOptionPostgresVersion, postgresVersion, BinariesPath string) (string, error)

func ReloadPostgres

func ReloadPostgres(config *ConfigStruct) error

func SaveConfig

func SaveConfig(args *Args) error

SaveConfig will only perform write operations if the file is nonexistent or contains different values

func SetDefaultsFromEnvironment

func SetDefaultsFromEnvironment(args *Args, userHomeDir *string)

func SetField

func SetField(obj interface{}, name string, value interface{}) error

func SetVersionAndDirectories

func SetVersionAndDirectories(args *Args) error

func StartSubcommand

func StartSubcommand(args *Args, cacheLocation *string) error

func StopPostgres

func StopPostgres(config *ConfigStruct) error

func UriSubcommand

func UriSubcommand(config *ConfigStruct) string

Types

type Args

type Args struct {
	ConfigStruct

	ConfigFile    string `arg:"-c,--config" help:"Config filepath to use"`
	NoConfigRead  bool   `arg:"--no-config-read" default:"false" help:"Do not read the config file"`
	NoConfigWrite bool   `arg:"--no-config-write" default:"false" help:"Do not write to config file"`
	NoRemote      bool   `arg:"--no-remote" default:"false" help:"Disable HTTPS calls for everything except 'install'"`

	Download       *DownloadCmd       `arg:"subcommand:download" help:"Download specified PostgreSQL version"`
	Env            *EnvCmd            `arg:"subcommand:env" help:"Print out associated environment variables"`
	GetPath        *GetPathCmd        `arg:"subcommand:get-path" help:"One of: bin, data, log, runtime"`
	Install        *InstallCmd        `arg:"subcommand:install" help:"Install specified PostgreSQL version"`
	InstallService *InstallServiceCmd `arg:"subcommand:install-service" help:"Install service (daemon), e.g., systemd, openrc, windows-service"`
	Ls             *LsCmd             `arg:"subcommand:ls" help:"List what versions of PostgreSQL are installed"`
	LsRemote       *LsRemoteCmd       `arg:"subcommand:ls-remote" help:"List what versions of PostgreSQL are available"`
	Ping           *PingCmd           `arg:"subcommand:ping" help:"Confirm server is online and auth works"`
	Reload         *ReloadCmd         `arg:"subcommand:reload" help:"Reload specified PostgreSQL server"`
	Start          *StartCmd          `arg:"subcommand:start" help:"Start specified PostgreSQL server"`
	Stop           *StopCmd           `arg:"subcommand:stop" help:"Stop specific (running) PostgreSQL server"`
	Uri            *UriCmd            `arg:"subcommand:uri" help:"Print out database connection string"`
}

func (Args) Description

func (Args) Description() string

func (Args) Version

func (Args) Version() string

type CacheLocator

type CacheLocator func() (location string, exists bool)

CacheLocator retrieves the location of the Postgres binary cache returning it to location. The result of whether this cache is present will be returned to exists.

type ConfigStruct

type ConfigStruct struct {
	PostgresVersion     string `arg:"--postgres-version,env:POSTGRES_VERSION" default:"latest" json:"-"`
	Port                uint32 `arg:"-p,env:PGPORT" default:"5432"`
	Database            string `arg:"-d,env:POSTGRES_DATABASE" default:"database"`
	Username            string `arg:"-u,env:POSTGRES_USERNAME" default:"username"`
	Password            string `arg:"env:POSTGRES_PASSWORD" default:"password"`
	VersionManagerRoot  string `arg:"--version-manager-root,env:VERSION_MANAGER_ROOT" placeholder:"VERSION_MANAGER_ROOT"`
	RuntimePath         string `arg:"--runtime-path,env:RUNTIME_PATH"`
	DataPath            string `arg:"--data-path,env:PGDATA"`
	BinariesPath        string `arg:"--binary-path,env:BINARY_PATH"`
	LogsPath            string `arg:"--logs-path,env:LOGS_PATH"`
	Locale              string `arg:"--locale,env:LC_ALL" default:"en_US.UTF-8"`
	BinaryRepositoryURL string `arg:"--binary-repository-url,env:BINARY_REPOSITORY_URL" default:"https://repo1.maven.org/maven2"`
}

ConfigStruct originally from github.com/fergusstrange/embedded-postgres@v1.20.0/config.go

func GetConfigFromFileOfConfigs

func GetConfigFromFileOfConfigs(args *Args) (*ConfigStruct, error)

type ConfigStructs

type ConfigStructs []ConfigStruct

func (ConfigStructs) MarshalJSON

func (configs ConfigStructs) MarshalJSON() ([]byte, error)

func (*ConfigStructs) UnmarshalJSON

func (configs *ConfigStructs) UnmarshalJSON(bytes []byte) error

type DownloadCmd

type DownloadCmd struct {
	PostgresVersion string `arg:"positional" placeholder:"POSTGRES_VERSION" default:""`
}

type EnvCmd

type EnvCmd struct{}

type GetPathCmd

type GetPathCmd struct {
	DirectoryToFind string `arg:"positional" help:"bin|data|log|runtime"`
}

type InstallCmd

type InstallCmd struct {
	PostgresVersion string `arg:"positional" placeholder:"POSTGRES_VERSION" default:""`
}

type InstallServiceCmd

type InstallServiceCmd struct {
	OpenRc         *InstallServiceForOpenRcCmd  `arg:"subcommand:openrc" help:"Install OpenRC service"`
	Systemd        *InstallServiceForSystemdCmd `arg:"subcommand:systemd" help:"Install systemd service"`
	WindowsService *InstallServiceForWindowsCmd `arg:"subcommand:windows-service" help:"Install Windows Service"`
}

type InstallServiceForOpenRcCmd

type InstallServiceForOpenRcCmd struct {
	Group              string `arg:"--group" default:"postgres"`
	ConfigInstallPath  string `arg:"--config-install-path" default:"/etc/conf.d/postgresql"`
	ServiceInstallPath string `arg:"--service-install-path" default:"/etc/init.d/postgresql"`
	User               string `arg:"--user" default:"postgres"`
}

type InstallServiceForSystemdCmd

type InstallServiceForSystemdCmd struct {
	Group              string `arg:"--group" default:"postgres"`
	ServiceInstallPath string `arg:"--service-install-path" default:"/etc/systemd/system/postgresql.service"`
	User               string `arg:"--user" default:"postgres"`
}

type InstallServiceForWindowsCmd

type InstallServiceForWindowsCmd struct {
	Name        string `arg:"--service-name" default:"PostgreSQL"`
	Description string `arg:"--service-description" default:"open-source relational database management system"`
}

type LsCmd

type LsCmd struct{}

type LsRemoteCmd

type LsRemoteCmd struct{}

type Metadata

type Metadata struct {
	XMLName    xml.Name `xml:"metadata"`
	Text       string   `xml:",chardata"`
	GroupId    string   `xml:"groupId"`
	ArtifactId string   `xml:"artifactId"`
	Versioning struct {
		Text     string `xml:",chardata"`
		Latest   string `xml:"latest"`
		Release  string `xml:"release"`
		Versions struct {
			Text    string   `xml:",chardata"`
			Version []string `xml:"version"`
		} `xml:"versions"`
		LastUpdated string `xml:"lastUpdated"`
	} `xml:"versioning"`
}

type PingCmd

type PingCmd struct {
	PostgresVersion string `arg:"positional" placeholder:"POSTGRES_VERSION" default:""`
}

type ReloadCmd

type ReloadCmd struct {
	PostgresVersion string `arg:"positional" placeholder:"POSTGRES_VERSION" default:""`
}

type RemoteFetchStrategy

type RemoteFetchStrategy func() error

RemoteFetchStrategy provides a strategy to fetch a Postgres binary so that it is available for use.

type StartCmd

type StartCmd struct {
	PostgresVersion string `arg:"positional" placeholder:"POSTGRES_VERSION" default:""`
	NoInstall       bool   `arg:"--no-install" default:"false" help:"Inverts default of installing nonexistent version"`
}

type StopCmd

type StopCmd struct {
	PostgresVersion string `arg:"positional" placeholder:"POSTGRES_VERSION" default:""`
}

type UriCmd

type UriCmd struct{}

type VersionStrategy

type VersionStrategy func() (operatingSystem string, architecture string, postgresVersion string)

VersionStrategy provides a strategy that can be used to determine which version of Postgres should be used based on the operating system, architecture and desired Postgres version.

Jump to

Keyboard shortcuts

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