style: pg cleaning up for things (#3627)

Signed-off-by: Samantha Coyle <sam@diagrid.io>
This commit is contained in:
Sam 2024-12-06 16:56:29 -06:00 committed by GitHub
parent 1e295a7056
commit dcaa80eef8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 16 deletions

View File

@ -262,21 +262,8 @@ func (a *StaticAuth) getDatabaseToken(ctx context.Context, poolConfig *pgxpool.C
dbEndpoint := poolConfig.ConnConfig.Host + ":" + strconv.Itoa(int(poolConfig.ConnConfig.Port))
// First, check if there are credentials set explicitly with accesskey and secretkey
var creds credentials.Value
if a.session != nil {
var err error
creds, err = a.session.Config.Credentials.Get()
if err != nil {
a.logger.Infof("failed to get access key and secret key, will fallback to reading the default AWS credentials file: %w", err)
}
}
if creds.AccessKeyID != "" && creds.SecretAccessKey != "" {
creds, err := a.session.Config.Credentials.Get()
if err != nil {
return "", fmt.Errorf("failed to retrieve session credentials: %w", err)
}
awsCfg := v2creds.NewStaticCredentialsProvider(creds.AccessKeyID, creds.SecretAccessKey, creds.SessionToken)
if a.accessKey != nil && a.secretKey != nil {
awsCfg := v2creds.NewStaticCredentialsProvider(*a.accessKey, *a.secretKey, a.sessionToken)
authenticationToken, err := auth.BuildAuthToken(
ctx, dbEndpoint, *a.region, poolConfig.ConnConfig.User, awsCfg)
if err != nil {

View File

@ -312,7 +312,9 @@ func (a *x509) Ses() *SesClients {
func (a *x509) getDatabaseToken(ctx context.Context, poolConfig *pgxpool.Config) (string, error) {
dbEndpoint := poolConfig.ConnConfig.Host + ":" + strconv.Itoa(int(poolConfig.ConnConfig.Port))
// First, check if there are credentials set explicitly with accesskey and secretkey
// First, check session credentials.
// This should always be what we use to generate the x509 auth credentials for postgres.
// However, we can leave the Second and Lastly checks as backup for now.
var creds credentials.Value
if a.session != nil {
var err error