postgres

package
v1.2.3-fred.10 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SSLModeVerifyFull is the Postgres SSL "verify-full" mode.
	//
	// See Postgres SSL docs for more info:
	// https://www.postgresql.org/docs/current/libpq-ssl.html
	SSLModeVerifyFull = "verify-full"
	// SSLModeVerifyCA is the Postgres SSL "verify-ca" mode.
	//
	// See Postgres SSL docs for more info:
	// https://www.postgresql.org/docs/current/libpq-ssl.html
	SSLModeVerifyCA = "verify-ca"
)

Variables

This section is empty.

Functions

func GetConnString

func GetConnString(c *profile.ConnectProfile, noTLS bool, printFormat bool) string

GetConnString returns formatted Postgres connection string for the profile.

Types

type ServiceFile

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

ServiceFile represents Postgres connection service file.

https://www.postgresql.org/docs/13/libpq-pgservice.html

func Load

func Load() (*ServiceFile, error)

Load loads Postgres connection service file from the default location.

func LoadFromPath

func LoadFromPath(path string) (*ServiceFile, error)

LoadFromPath loads Posrtgres connection service file from the specified path.

func (*ServiceFile) Delete

func (s *ServiceFile) Delete(name string) error

Delete deletes the specified connection profile and saves the service file.

func (*ServiceFile) Env

func (s *ServiceFile) Env(serviceName string) (map[string]string, error)

Env returns the specified connection profile information as a set of environment variables recognized by Postgres clients.

func (*ServiceFile) Upsert

func (s *ServiceFile) Upsert(profile profile.ConnectProfile) error

Upsert adds the provided connection profile to the service file and saves it.

The profile goes into a separate section with the name equal to the name of the database that user is logged into and looks like this:

[postgres]
host=proxy.example.com
port=3080
sslmode=verify-full
sslrootcert=/home/user/.tsh/keys/proxy.example.com/certs.pem
sslcert=/home/user/.tsh/keys/proxy.example.com/alice-db/root/aurora-x509.pem
sslkey=/home/user/.tsh/keys/proxy.example.com/user

With the profile like this, a user can refer to it using "service" psql parameter:

$ psql "service=postgres <other parameters>"

Jump to

Keyboard shortcuts

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