MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / createPgPassFile

Function createPgPassFile

pkg/management/external/utils.go:169–182  ·  view source on GitHub ↗

createPgPassFile creates a pgpass file inside the user home directory

(
	serverName string,
	connectionParameters map[string]string,
	password string,
)

Source from the content-addressed store, hash-verified

167
168// createPgPassFile creates a pgpass file inside the user home directory
169func createPgPassFile(
170 serverName string,
171 connectionParameters map[string]string,
172 password string,
173) (string, error) {
174 pgpassLine := pgpass.NewConnectionInfo(connectionParameters, password)
175
176 filePath := getPgPassFilePath(serverName)
177 if err := os.MkdirAll(filepath.Dir(filePath), 0o700); err != nil {
178 return "", err
179 }
180
181 return filePath, pgpass.From(pgpassLine).Write(filePath)
182}

Callers 1

Calls 4

NewConnectionInfoFunction · 0.92
FromFunction · 0.92
getPgPassFilePathFunction · 0.85
WriteMethod · 0.65

Tested by

no test coverage detected