From 86d4fb6d998613950e764cbf6e6a6ee618f3f3b9 Mon Sep 17 00:00:00 2001 From: gbrodman Date: Wed, 22 Jul 2020 16:52:31 -0400 Subject: [PATCH] Fix some SQL credential issues identified when deploying Beam pipelines (#706) * Fix some SQL credential issues identified when deploying Beam pipelines There are two issues fixed here. 1. Without calling `FileSystems.setDefaultPipelineOptions(PipelineOptionsFactory.create()), the Nomulus tool doesn't know how to handle gs:// scheme files. Thus, if you try to deploy (for instance) the Spec11 pipeline using a GCS credential file, it fails. 2. There was a misunderstanding before about what the credential file actually refers to -- there is a credential file in JSON format that is used for gcloud authorization, and there is a space-delimited SQL access info file that has the instance name, username, and password. These are separate options and should have separate command-line params. * Actually we don't need this for remote deployment --- core/src/main/java/google/registry/tools/RegistryCli.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/google/registry/tools/RegistryCli.java b/core/src/main/java/google/registry/tools/RegistryCli.java index 9463b1daa..b268bcaf2 100644 --- a/core/src/main/java/google/registry/tools/RegistryCli.java +++ b/core/src/main/java/google/registry/tools/RegistryCli.java @@ -66,6 +66,12 @@ final class RegistryCli implements AutoCloseable, CommandRunner { + "If not set, credentials saved by running `nomulus login' will be used.") private String credentialJson = null; + @Parameter( + names = {"--sql_access_info"}, + description = "Name of a file containing space-separated SQL access info used when deploying " + + "Beam pipelines") + private String sqlAccessInfoFile = null; + // Do not make this final - compile-time constant inlining may interfere with JCommander. @ParametersDelegate private LoggingParameters loggingParams = new LoggingParameters(); @@ -161,7 +167,7 @@ final class RegistryCli implements AutoCloseable, CommandRunner { component = DaggerRegistryToolComponent.builder() .credentialFilePath(credentialJson) - .beamJpaModule(new BeamJpaModule(credentialJson)) + .beamJpaModule(new BeamJpaModule(sqlAccessInfoFile)) .build(); // JCommander stores sub-commands as nested JCommander objects containing a list of user objects