Add config parameters to point at us to use cloud-dns staging

Add cloudDns.{rootUrl, servicePath} to allow us to point an environment at the
Cloud DNS staging API for testing.  Make sandbox and alpha point to staging.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170340859
This commit is contained in:
mmuller 2017-09-28 07:26:55 -07:00 committed by Ben McIlwain
parent d4ab6fe90b
commit d09bd89629
4 changed files with 43 additions and 4 deletions

View file

@ -331,6 +331,18 @@ public final class RegistryConfig {
return config.datastore.eppResourceIndexBucketsNum; return config.datastore.eppResourceIndexBucketsNum;
} }
@Provides
@Config("cloudDnsRootUrl")
public static Optional<String> getCloudDnsRootUrl(RegistryConfigSettings config) {
return Optional.fromNullable(config.cloudDns.rootUrl);
}
@Provides
@Config("cloudDnsServicePath")
public static Optional<String> getCloudDnsServicePath(RegistryConfigSettings config) {
return Optional.fromNullable(config.cloudDns.servicePath);
}
/** /**
* Returns size of Google Cloud Storage client connection buffer in bytes. * Returns size of Google Cloud Storage client connection buffer in bytes.
* *

View file

@ -25,6 +25,7 @@ public class RegistryConfigSettings {
public OAuth oAuth; public OAuth oAuth;
public RegistryPolicy registryPolicy; public RegistryPolicy registryPolicy;
public Datastore datastore; public Datastore datastore;
public CloudDns cloudDns;
public Caching caching; public Caching caching;
public IcannReporting icannReporting; public IcannReporting icannReporting;
public Rde rde; public Rde rde;
@ -96,6 +97,12 @@ public class RegistryConfigSettings {
public String projectId; public String projectId;
} }
/** Configuration for Cloud DNS. */
public static class CloudDns {
public String rootUrl;
public String servicePath;
}
/** Configuration for caching. */ /** Configuration for caching. */
public static class Caching { public static class Caching {
public int singletonCacheRefreshSeconds; public int singletonCacheRefreshSeconds;

View file

@ -110,6 +110,15 @@ datastore:
# doubles after each failure). # doubles after each failure).
baseOfyRetryMillis: 100 baseOfyRetryMillis: 100
cloudDns:
# The root url for the Cloud DNS API. Set this to a non-null value to
# override the default API server used by the googleapis library.
rootUrl: null
# The service endpoint path for the Cloud DNS API. Set this to a non-null
# value to override the default API path used by the googleapis library.
servicePath: null
caching: caching:
# Length of time that a singleton should be cached before expiring. # Length of time that a singleton should be cached before expiring.
singletonCacheRefreshSeconds: 600 singletonCacheRefreshSeconds: 600

View file

@ -20,6 +20,7 @@ import com.google.api.client.json.JsonFactory;
import com.google.api.services.dns.Dns; import com.google.api.services.dns.Dns;
import com.google.api.services.dns.DnsScopes; import com.google.api.services.dns.DnsScopes;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.RateLimiter; import com.google.common.util.concurrent.RateLimiter;
import dagger.Module; import dagger.Module;
import dagger.Provides; import dagger.Provides;
@ -40,10 +41,20 @@ public final class CloudDnsWriterModule {
HttpTransport transport, HttpTransport transport,
JsonFactory jsonFactory, JsonFactory jsonFactory,
Function<Set<String>, ? extends HttpRequestInitializer> credential, Function<Set<String>, ? extends HttpRequestInitializer> credential,
@Config("projectId") String projectId) { @Config("projectId") String projectId,
return new Dns.Builder(transport, jsonFactory, credential.apply(DnsScopes.all())) @Config("cloudDnsRootUrl") Optional<String> rootUrl,
.setApplicationName(projectId) @Config("cloudDnsServicePath") Optional<String> servicePath) {
.build(); Dns.Builder builder = new Dns.Builder(transport, jsonFactory, credential.apply(DnsScopes.all()))
.setApplicationName(projectId);
if (rootUrl.isPresent()) {
builder.setRootUrl(rootUrl.get());
}
if (servicePath.isPresent()) {
builder.setServicePath(servicePath.get());
}
return builder.build();
} }
@Provides @Provides