-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow leaving accessKey and secretKey undefined for DEFAULT auth mode. (
#64)
- Loading branch information
1 parent
eac6be7
commit 247261c
Showing
5 changed files
with
67 additions
and
26 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
secret-provider/src/main/scala/io/lenses/connect/secrets/config/AWSCredentials.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.lenses.connect.secrets.config | ||
|
||
import org.apache.kafka.common.config.types.Password | ||
import org.apache.kafka.connect.errors.ConnectException | ||
|
||
import scala.util.Try | ||
|
||
case class AWSCredentials(accessKey: String, secretKey: Password) | ||
|
||
object AWSCredentials { | ||
def apply(configs: AWSProviderConfig): Either[Throwable, AWSCredentials] = | ||
for { | ||
accessKey <- Try(configs.getString(AWSProviderConfig.AWS_ACCESS_KEY)).toEither | ||
secretKey <- Try(configs.getPassword(AWSProviderConfig.AWS_SECRET_KEY)).toEither | ||
|
||
accessKeyValidated <- Either.cond(accessKey.nonEmpty, | ||
accessKey, | ||
new ConnectException( | ||
s"${AWSProviderConfig.AWS_ACCESS_KEY} not set", | ||
), | ||
) | ||
secretKeyValidated <- Either.cond(secretKey.value().nonEmpty, | ||
secretKey, | ||
new ConnectException( | ||
s"${AWSProviderConfig.AWS_SECRET_KEY} not set", | ||
), | ||
) | ||
} yield { | ||
AWSCredentials(accessKeyValidated, secretKeyValidated) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters