Skip to content

Commit 24d817e

Browse files
committed
minors
1 parent cd438df commit 24d817e

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

jmf-rules.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ za.co.absa.atum.server.Main*#*
164164
za.co.absa.atum.server.Constants*#*
165165
za.co.absa.atum.server.api.database.DoobieImplicits*#*
166166
za.co.absa.atum.server.api.database.TransactorProvider*#*
167+
za.co.absa.atum.server.api.database.PostgresDataSourceWithPasswordFromSecretsManager*#*
168+
za.co.absa.atum.server.api.database.AWSSDKs*#*
167169
za.co.absa.atum.server.api.common.http.Routes*#*
168170
za.co.absa.atum.server.api.v2.repository.PartitioningRepository#*
169171
za.co.absa.atum.server.api.v2.repository.PartitioningRepository$#*

server/src/main/scala/za/co/absa/atum/server/api/database/PostgresDataSourceWithPasswordFromSecretsManager.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ import org.slf4j.LoggerFactory
2121
*/
2222
class PostgresDataSourceWithPasswordFromSecretsManager extends PGSimpleDataSource {
2323

24-
protected val logger: Logger = LoggerFactory.getLogger(this.getClass())
24+
protected val logger: Logger = LoggerFactory.getLogger(this.getClass)
2525

2626
private var password: String = _
2727
private var passwordSecretId: String = _
2828

29-
override def getConnection(): Connection = {
29+
override def getConnection: Connection = {
3030
if (Option(password).isEmpty) {
31-
val pw = getPasswordFromSecretsManagerOrConfig()
31+
val pw = getPasswordFromSecretsManagerOrConfig
3232
setInternalPassword(pw)
3333
}
3434

3535
val connectionTry = Try(baseGetConnection(user, password)).recoverWith { case _: SQLException =>
3636
logger.info("Failed to create Postgres connection, attempting to refresh the password and try again...")
3737
for {
38-
passwordFromSecretsManager <- getPasswordFromSecretsManager()
38+
passwordFromSecretsManager <- getPasswordFromSecretsManager
3939
connection <- Try(baseGetConnection(user, passwordFromSecretsManager)).recoverWith { case e =>
4040
logger.error("Failed to create Postgres connection even after password refresh")
4141
Failure(e)
@@ -50,7 +50,7 @@ class PostgresDataSourceWithPasswordFromSecretsManager extends PGSimpleDataSourc
5050
}
5151

5252
// getter and setter for passwordSecretId are needed as this class is usually constructed by reflection
53-
def getPasswordSecretId(): String = passwordSecretId
53+
def getPasswordSecretId: String = passwordSecretId
5454

5555
def setPasswordSecretId(passwordSecretId: String): Unit = {
5656
this.passwordSecretId = passwordSecretId
@@ -72,8 +72,8 @@ class PostgresDataSourceWithPasswordFromSecretsManager extends PGSimpleDataSourc
7272
this.password = password
7373
}
7474

75-
private def getPasswordFromSecretsManager(): Try[String] = {
76-
val secretID = getPasswordSecretId()
75+
private def getPasswordFromSecretsManager: Try[String] = {
76+
val secretID = getPasswordSecretId
7777

7878
val secretValueTry = Try {
7979
logger.info(s"Fetching password for Postgres from Secrets Manager (secret id: $secretID)")
@@ -92,10 +92,10 @@ class PostgresDataSourceWithPasswordFromSecretsManager extends PGSimpleDataSourc
9292
}
9393
}
9494

95-
private def getPasswordFromSecretsManagerOrConfig(): String = {
96-
getPasswordFromSecretsManager().getOrElse {
95+
private def getPasswordFromSecretsManagerOrConfig: String = {
96+
getPasswordFromSecretsManager.getOrElse {
9797
logger.error(
98-
s"Failed to fetch password from Secrets Manager (secret id: ${getPasswordSecretId()}). " +
98+
s"Failed to fetch password from Secrets Manager (secret id: ${getPasswordSecretId}). " +
9999
s"Falling back to config value."
100100
)
101101
val configPassword = ConfigFactory.load().getConfig("postgres").getString("password")

0 commit comments

Comments
 (0)