Skip to content
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

Merged
merged 2 commits into from
Oct 13, 2020

Conversation

mziolekda
Copy link
Contributor

@mziolekda mziolekda commented Oct 12, 2020

CHANGELOG_BEGIN
The --participant command-line configuration syntax has been extended. It is now possible to use a server-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

Copy link
Contributor

@gerolf-da gerolf-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @mziolekda!

@mziolekda mziolekda merged commit 22fb8d4 into master Oct 13, 2020
@mziolekda mziolekda deleted the mziolek/jdbc-string-in-env-var branch October 13, 2020 08:02
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"
Copy link
Contributor

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"
Copy link
Contributor

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"
Copy link
Contributor

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(_),
Copy link
Contributor

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"))
Copy link
Contributor

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).

cocreature added a commit that referenced this pull request Oct 14, 2020
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
cocreature added a commit that referenced this pull request Oct 14, 2020
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
cocreature added a commit that referenced this pull request Oct 14, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants