-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supply jdbc string through an env variable #7660
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @mziolekda!
...te/kvutils/app/src/test/scala/com/daml/ledger/participant/state/kvutils/app/ConfigSpec.scala
Outdated
Show resolved
Hide resolved
...te/kvutils/app/src/test/scala/com/daml/ledger/participant/state/kvutils/app/ConfigSpec.scala
Outdated
Show resolved
Hide resolved
...te/kvutils/app/src/test/scala/com/daml/ledger/participant/state/kvutils/app/ConfigSpec.scala
Outdated
Show resolved
Hide resolved
private val participantOption = "--participant" | ||
private val participantId: ParticipantId = ParticipantId.assertFromString("dummy-participant") | ||
private val fixedParticipantSubOptions = s"participant-id=$participantId,port=123" | ||
private val jdbcUrlSubOption = "server-jdbc-url" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These magic strings must be referenced from Config
.
private val dumpIndexMetadataCommand = "dump-index-metadata" | ||
private val participantOption = "--participant" | ||
private val participantId: ParticipantId = ParticipantId.assertFromString("dummy-participant") | ||
private val fixedParticipantSubOptions = s"participant-id=$participantId,port=123" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest naming this as mandatoryParticipantOptions
or mandatoryParticipantConfig
or similar to hint that these must be provided.
private val DumpIndexMetadataCommand = "dump-index-metadata" | ||
private val ConfigParser: Seq[String] => Option[Config[Unit]] = | ||
Config.parse("Test", (_: OptionParser[Config[Unit]]) => (), (), _) | ||
private val dumpIndexMetadataCommand = "dump-index-metadata" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constants should be UpperCamelCased
-- please don't change this.
@@ -75,8 +75,9 @@ object Config { | |||
extraOptions: OptionParser[Config[Extra]] => Unit, | |||
defaultExtra: Extra, | |||
args: Seq[String], | |||
getEnvVar: String => Option[String] = sys.env.get(_), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getEnvironmentVariable
it should "get the jdbc string from the command line argument when provided" in { | ||
val jdbcFromCli = "command-line-jdbc" | ||
val config = configParser( | ||
Seq(participantOption, s"$fixedParticipantSubOptions,$jdbcUrlSubOption=$jdbcFromCli")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve test readability, I'd suggest putting the relevant config key first (i.e., from this test case's perspective).
This PR shuffles things around a bit to make it easier to test and adds `--query-store-jdbc-config-env` which specifies the name of an environment variable containing the jdbc URL. The UX for this is modeled after #7660. Added a test for the different formats. fixes #7667 changelog_begin - [JSON API] The JDBC url can now also be specified via `--query-store-jdbc-config-env` which reads it from the given environment variable. changelog_end
This PR shuffles things around a bit to make it easier to test and adds `--query-store-jdbc-config-env` which specifies the name of an environment variable containing the jdbc URL. The UX for this is modeled after #7660. Added a test for the different formats. fixes #7667 changelog_begin - [JSON API] The JDBC url can now also be specified via `--query-store-jdbc-config-env` which reads it from the given environment variable. changelog_end
This PR shuffles things around a bit to make it easier to test and adds `--query-store-jdbc-config-env` which specifies the name of an environment variable containing the jdbc URL. The UX for this is modeled after #7660. Added a test for the different formats. fixes #7667 changelog_begin - [JSON API] The JDBC url can now also be specified via `--query-store-jdbc-config-env` which reads it from the given environment variable. changelog_end
CHANGELOG_BEGIN
The
--participant
command-line configuration syntax has been extended. It is now possible to use aserver-jdbc-url-env
sub-option to specify the name of an environment variable that holds the JDBC string that should be used for connecting to the index database. This approach allows avoiding passing sensitive information in the command line launching the participant process.CHANGELOG_END