From 40319884092b6d07f0d023ef97f0354b81b00368 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Fri, 3 Feb 2017 09:21:38 -0800 Subject: [PATCH] Fix connection error in nomulus tool caused by YAML configs This is a temporary work-around that fixes the tool for all of our environments. Next up I'm working on a generalizable way to get this working by adding some kind of configuration between environment name and App Engine project ID. The current configuration system doesn't quite work for that because it's all based on a separate config per environment, whereas the tool needs to be able to access all environments. Either we bundle all configs that currently go into WEB-INF/ with nomulus and have it select based on the -e flag, or we make it a separate configuration. TESTED=I built and ran locally and was able to successfully run commands against alpha, production, and sandbox. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146481850 --- .../registry/config/RegistryConfig.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/java/google/registry/config/RegistryConfig.java b/java/google/registry/config/RegistryConfig.java index 35ee2898a..6977ece86 100644 --- a/java/google/registry/config/RegistryConfig.java +++ b/java/google/registry/config/RegistryConfig.java @@ -19,6 +19,7 @@ import static google.registry.config.ConfigUtils.makeUrl; import static google.registry.config.YamlUtils.getConfigSettings; import static java.lang.annotation.RetentionPolicy.RUNTIME; +import com.google.common.base.Ascii; import com.google.common.base.Optional; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; @@ -26,7 +27,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.net.HostAndPort; import dagger.Module; import dagger.Provides; -import google.registry.config.RegistryConfigSettings.AppEngine.ToolsServiceUrl; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.net.URI; @@ -1076,8 +1076,22 @@ public final class RegistryConfig { *

This is used by the {@code nomulus} tool to connect to the App Engine remote API. */ public static HostAndPort getServer() { - ToolsServiceUrl url = CONFIG_SETTINGS.get().appEngine.toolsServiceUrl; - return HostAndPort.fromParts(url.hostName, url.port); + // TODO(b/33386530): Make this configurable in a way that is accessible from the nomulus + // command-line tool. + switch (RegistryEnvironment.get()) { + case PRODUCTION: + return HostAndPort.fromParts("tools-dot-domain-registry.appspot.com", 443); + case LOCAL: + return HostAndPort.fromParts("localhost", 8080); + case UNITTEST: + throw new UnsupportedOperationException("Unit tests can't spin up a full server"); + default: + return HostAndPort.fromParts( + String.format( + "tools-dot-domain-registry-%s.appspot.com", + Ascii.toLowerCase(RegistryEnvironment.get().name())), + 443); + } } /** Returns the amount of time a singleton should be cached, before expiring. */