createPgPassFile creates a pgpass file inside the user home directory
( serverName string, connectionParameters map[string]string, password string, )
| 167 | |
| 168 | // createPgPassFile creates a pgpass file inside the user home directory |
| 169 | func 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 | } |
no test coverage detected