Move more configuration options into YAML config files

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145452311
This commit is contained in:
mcilwain 2017-01-24 12:27:36 -08:00 committed by Ben McIlwain
parent 124011a8ce
commit 6c11ac5392
9 changed files with 91 additions and 38 deletions

View file

@ -86,7 +86,7 @@ public final class RegistryConfig {
@Provides
@Config("projectId")
public static String provideProjectId(RegistryConfigSettings config) {
return config.general.appEngineProjectId;
return config.appEngine.projectId;
}
/**
@ -96,15 +96,8 @@ public final class RegistryConfig {
*/
@Provides
@Config("logoFilename")
public static String provideLogoFilename(RegistryEnvironment environment) {
switch (environment) {
case UNITTEST:
case LOCAL:
return "logo.png";
default:
// Change this to the filename of your logo.
return "google_registry.png";
}
public static String provideLogoFilename(RegistryConfigSettings config) {
return config.registrarConsole.logoFilename;
}
/**
@ -114,9 +107,8 @@ public final class RegistryConfig {
*/
@Provides
@Config("productName")
public static String provideProductName(RegistryEnvironment environment) {
// Change this to the name of your product.
return "Nomulus";
public static String provideProductName(RegistryConfigSettings config) {
return config.registryPolicy.productName;
}
/**
@ -128,8 +120,8 @@ public final class RegistryConfig {
*/
@Provides
@Config("contactAndHostRoidSuffix")
public static String provideContactAndHostRoidSuffix(RegistryEnvironment environment) {
return LocalTestConfig.CONTACT_AND_HOST_ROID_SUFFIX;
public static String provideContactAndHostRoidSuffix(RegistryConfigSettings config) {
return config.registryPolicy.contactAndHostRoidSuffix;
}
/**
@ -1120,7 +1112,7 @@ public final class RegistryConfig {
* Returns the App Engine project ID, which is based off the environment name.
*/
public static String getProjectId() {
return CONFIG_SETTINGS.get().general.appEngineProjectId;
return CONFIG_SETTINGS.get().appEngine.projectId;
}
/**
@ -1262,6 +1254,11 @@ public final class RegistryConfig {
}
}
/** Returns the roid suffix to be used for the roids of all contacts and hosts. */
public static String getContactAndHostRoidSuffix() {
return CONFIG_SETTINGS.get().registryPolicy.contactAndHostRoidSuffix;
}
/**
* Memoizes loading of the {@link RegistryConfigSettings} POJO.
*
@ -1278,8 +1275,6 @@ public final class RegistryConfig {
/** Config values used for local and unit test environments. */
public static class LocalTestConfig {
public static final String CONTACT_AND_HOST_ROID_SUFFIX = "ROID";
public static final String RESERVED_TERMS_TEST_EXPORT_DISCLAIMER = "This is a disclaimer.\n";
public static final String GOOGLE_APPS_SEND_FROM_EMAIL_ADDRESS = "noreply@testing.example";

View file

@ -17,16 +17,28 @@ package google.registry.config;
/** The POJO that YAML config files are deserialized into. */
public class RegistryConfigSettings {
public General general;
public AppEngine appEngine;
public RegistryPolicy registryPolicy;
public Datastore datastore;
public RegistrarConsole registrarConsole;
public Monitoring monitoring;
/** General configuration options that apply to the entire App Engine project. */
public static class General {
/** Configuration options that apply to the entire App Engine project. */
public static class AppEngine {
public String appEngineProjectId;
public String projectId;
}
/** Configuration options for registry policy. */
public static class RegistryPolicy {
public String contactAndHostRoidSuffix;
public String productName;
}
/** Configuration for Cloud Datastore. */
@ -37,6 +49,12 @@ public class RegistryConfigSettings {
public int eppResourceIndexBucketsNum;
}
/** Configuration for the web-based registrar console. */
public static class RegistrarConsole {
public String logoFilename;
}
/** Configuration for monitoring. */
public static class Monitoring {

View file

@ -3,19 +3,31 @@
# individual deployment or environment, create a nomulus-config.yaml file in the
# WEB-INF/ directory overriding only the values you wish to change.
general:
appEngine:
# Globally unique App Engine project ID
appEngineProjectId: domain-registry
projectId: domain-registry
registryPolicy:
# Repository identifier (ROID) suffix for contacts and hosts.
contactAndHostRoidSuffix: ROID
# Product name of the registry. Used throughout the registrar console.
productName: Nomulus
datastore:
# The number of commit log buckets in Datastore. Don't change after initial
# Number of commit log buckets in Datastore. Don't change after initial
# install.
commitLogBucketsNum: 100
# The number of EPP resource index buckets in Datastore. Dont change after
# Number of EPP resource index buckets in Datastore. Dont change after
# initial install.
eppResourceIndexBucketsNum: 997
registrarConsole:
# Filename of the logo to use in the header of the console. This filename is
# relative to ui/assets/images/
logoFilename: logo.png
monitoring:
# Max queries per second for the Google Cloud Monitoring V3 (aka Stackdriver)
# API. The limit can be adjusted by contacting Cloud Support.

View file

@ -1,3 +1,10 @@
general:
appEngineProjectId: domain-registry-alpha
appEngine:
projectId: domain-registry-alpha
registryPolicy:
contactAndHostRoidSuffix: GOOGLE
productName: Google Registry Alpha
registrarConsole:
logoFilename: google_registry.png

View file

@ -1,3 +1,10 @@
general:
appEngineProjectId: domain-registry-crash
appEngine:
projectId: domain-registry-crash
registryPolicy:
contactAndHostRoidSuffix: GOOGLE
productName: Google Registry Crash
registrarConsole:
logoFilename: google_registry.png

View file

@ -1,3 +1,3 @@
general:
appEngineProjectId: domain-registry
appEngine:
projectId: domain-registry

View file

@ -1,3 +1,10 @@
general:
appEngineProjectId: domain-registry
appEngine:
projectId: domain-registry
registryPolicy:
contactAndHostRoidSuffix: GOOGLE
productName: Google Registry
registrarConsole:
logoFilename: google_registry.png

View file

@ -1,3 +1,10 @@
general:
appEngineProjectId: domain-registry-sandbox
appEngine:
projectId: domain-registry-sandbox
registryPolicy:
contactAndHostRoidSuffix: GOOGLE
productName: Google Registry Sandbox
registrarConsole:
logoFilename: google_registry.png

View file

@ -20,8 +20,8 @@ import static com.google.common.base.Suppliers.memoize;
import static com.google.common.collect.Iterables.toArray;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static google.registry.config.RegistryConfig.LocalTestConfig.CONTACT_AND_HOST_ROID_SUFFIX;
import static google.registry.config.RegistryConfig.LocalTestConfig.CONTACT_AUTOMATIC_TRANSFER_LENGTH;
import static google.registry.config.RegistryConfig.getContactAndHostRoidSuffix;
import static google.registry.flows.ResourceFlowUtils.createTransferResponse;
import static google.registry.model.EppResourceUtils.createDomainRepoId;
import static google.registry.model.EppResourceUtils.createRepoId;
@ -747,7 +747,7 @@ public class DatastoreHelper {
* HEX_TLD-ROID.
*/
public static String generateNewContactHostRoid() {
return createRepoId(ObjectifyService.allocateId(), CONTACT_AND_HOST_ROID_SUFFIX);
return createRepoId(ObjectifyService.allocateId(), getContactAndHostRoidSuffix());
}
/**