Move injectable config values into ConfigModule

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=138903917
This commit is contained in:
ctingue 2016-11-11 12:08:19 -08:00 committed by Ben McIlwain
parent 1b6f2f82cd
commit fab8ca8414
4 changed files with 58 additions and 135 deletions

View file

@ -175,18 +175,26 @@ public final class ConfigModule {
return "http://example.com/your_support_docs/";
}
/** @see RegistryConfig#getZoneFilesBucket() */
/**
* Returns the Google Cloud Storage bucket for storing zone files.
*
* @see google.registry.backup.ExportCommitLogDiffAction
*/
@Provides
@Config("zoneFilesBucket")
public static String provideZoneFilesBucket(RegistryConfig config) {
return config.getZoneFilesBucket();
public static String provideZoneFilesBucket(@Config("projectId") String projectId) {
return projectId + "-zonefiles";
}
/** @see RegistryConfig#getCommitsBucket() */
/**
* Returns the Google Cloud Storage bucket for storing commit logs.
*
* @see google.registry.backup.ExportCommitLogDiffAction
*/
@Provides
@Config("commitLogGcsBucket")
public static String provideCommitLogGcsBucket(RegistryConfig config) {
return config.getCommitsBucket();
public static String provideCommitLogGcsBucket(@Config("projectId") String projectId) {
return projectId + "-commits";
}
/** @see RegistryConfig#getCommitLogDatastoreRetention() */
@ -203,8 +211,8 @@ public final class ConfigModule {
*/
@Provides
@Config("domainListsGcsBucket")
public static String provideDomainListsGcsBucket(RegistryConfig config) {
return config.getDomainListsBucket();
public static String provideDomainListsGcsBucket(@Config("projectId") String projectId) {
return projectId + "-domain-lists";
}
/**
@ -360,12 +368,25 @@ public final class ConfigModule {
return "admin@example.com";
}
/** @see RegistryConfig#getRegistrarChangesNotificationEmailAddresses() */
/**
* Returns the email address(es) that notifications of registrar and/or registrar contact updates
* should be sent to, or the empty list if updates should not be sent.
*
* @see google.registry.ui.server.registrar.RegistrarSettingsAction
*/
@Provides
@Config("registrarChangesNotificationEmailAddresses")
public static ImmutableList<String> provideRegistrarChangesNotificationEmailAddresses(
RegistryConfig config) {
return config.getRegistrarChangesNotificationEmailAddresses();
RegistryEnvironment environment) {
switch (environment) {
case PRODUCTION:
// Change this to an appropriate notification e-mail address.
return ImmutableList.of("notification@registry.example");
case UNITTEST:
return ImmutableList.of("notification@test.example", "notification2@test.example");
default:
return ImmutableList.<String>of();
}
}
/**
@ -381,7 +402,11 @@ public final class ConfigModule {
return "registry.example.com";
}
/** @see RegistryConfig#getTmchCaTestingMode() */
/**
* Returns {@code true} if TMCH certificate authority should be in testing mode.
*
* @see RegistryConfig#getTmchCaTestingMode()
*/
@Provides
@Config("tmchCaTestingMode")
public static boolean provideTmchCaTestingMode(RegistryConfig config) {
@ -408,11 +433,24 @@ public final class ConfigModule {
}
}
/** @see RegistryConfig#getTmchMarksdbUrl() */
/**
* URL prefix for communicating with MarksDB ry interface.
*
* <p>This URL is used for DNL, SMDRL, and LORDN.
*
* @see google.registry.tmch.Marksdb
* @see google.registry.tmch.NordnUploadAction
*/
@Provides
@Config("tmchMarksdbUrl")
public static String provideTmchMarksdbUrl(RegistryConfig config) {
return config.getTmchMarksdbUrl();
public static String provideTmchMarksdbUrl(RegistryEnvironment environment) {
switch (environment) {
case PRODUCTION:
case UNITTEST:
return "https://ry.marksdb.org";
default:
return "https://test.ry.marksdb.org";
}
}
/**
@ -831,11 +869,13 @@ public final class ConfigModule {
return config.getContactAutomaticTransferLength();
}
/** @see RegistryConfig#getMaxChecks() */
/**
* Returns the maximum number of entities that can be checked at one time in an EPP check flow.
*/
@Provides
@Config("maxChecks")
public static int provideMaxChecks(RegistryConfig config) {
return config.getMaxChecks();
public static int provideMaxChecks() {
return 50;
}
/**

View file

@ -21,7 +21,6 @@ import static org.joda.time.Duration.standardDays;
import com.google.appengine.api.utils.SystemProperty;
import com.google.common.base.Ascii;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HostAndPort;
import java.net.URL;
import javax.annotation.concurrent.Immutable;
@ -83,21 +82,6 @@ public final class ProductionRegistryConfigExample implements RegistryConfig {
return getProjectId() + "-snapshots";
}
@Override
public String getDomainListsBucket() {
return getProjectId() + "-domain-lists";
}
@Override
public String getCommitsBucket() {
return getProjectId() + "-commits";
}
@Override
public String getZoneFilesBucket() {
return getProjectId() + "-zonefiles";
}
@Override
public boolean getTmchCaTestingMode() {
switch (environment) {
@ -108,16 +92,6 @@ public final class ProductionRegistryConfigExample implements RegistryConfig {
}
}
@Override
public String getTmchMarksdbUrl() {
switch (environment) {
case PRODUCTION:
return "https://ry.marksdb.org";
default:
return "https://test.ry.marksdb.org";
}
}
@Override
public Optional<String> getECatcherAddress() {
throw new UnsupportedOperationException(); // n/a
@ -164,16 +138,6 @@ public final class ProductionRegistryConfigExample implements RegistryConfig {
return String.format("noreply@%s.appspotmail.com", SystemProperty.applicationId.get());
}
@Override
public ImmutableList<String> getRegistrarChangesNotificationEmailAddresses() {
switch (environment) {
case PRODUCTION:
return ImmutableList.of("notification@registry.example");
default:
return ImmutableList.<String>of();
}
}
@Override
public String getRegistrarDefaultWhoisServer() {
return "whois.nic.registry.example";
@ -189,11 +153,6 @@ public final class ProductionRegistryConfigExample implements RegistryConfig {
return "Nomulus";
}
@Override
public int getMaxChecks() {
return 50;
}
@Override
public int getEppResourceIndexBucketCount() {
return 997;

View file

@ -15,7 +15,6 @@
package google.registry.config;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HostAndPort;
import java.net.URL;
import org.joda.time.Duration;
@ -42,13 +41,6 @@ public interface RegistryConfig {
*/
public String getSnapshotsBucket();
/**
* Returns the Google Cloud Storage bucket for storing exported domain lists.
*
* @see google.registry.export.ExportDomainListsAction
*/
public String getDomainListsBucket();
/**
* Number of sharded commit log buckets.
*
@ -75,20 +67,6 @@ public interface RegistryConfig {
*/
public Duration getCommitLogDatastoreRetention();
/**
* Returns the Google Cloud Storage bucket for storing commit logs.
*
* @see google.registry.backup.ExportCommitLogDiffAction
*/
public String getCommitsBucket();
/**
* Returns the Google Cloud Storage bucket for storing zone files.
*
* @see google.registry.backup.ExportCommitLogDiffAction
*/
public String getZoneFilesBucket();
/**
* Returns {@code true} if TMCH certificate authority should be in testing mode.
*
@ -96,16 +74,6 @@ public interface RegistryConfig {
*/
public boolean getTmchCaTestingMode();
/**
* URL prefix for communicating with MarksDB ry interface.
*
* <p>This URL is used for DNL, SMDRL, and LORDN.
*
* @see google.registry.tmch.Marksdb
* @see google.registry.tmch.NordnUploadAction
*/
public String getTmchMarksdbUrl();
public Optional<String> getECatcherAddress();
/**
@ -159,14 +127,6 @@ public interface RegistryConfig {
*/
public String getContactAndHostRepositoryIdentifier();
/**
* Returns the email address(es) that notifications of registrar and/or registrar contact updates
* should be sent to, or the empty list if updates should not be sent.
*
* @see google.registry.ui.server.registrar.RegistrarSettingsAction
*/
public ImmutableList<String> getRegistrarChangesNotificationEmailAddresses();
/**
* Returns default WHOIS server to use when {@code Registrar#getWhoisServer()} is {@code null}.
*
@ -185,11 +145,6 @@ public interface RegistryConfig {
*/
public String getDocumentationProjectTitle();
/**
* Returns the maximum number of entities that can be checked at one time in an EPP check flow.
*/
public int getMaxChecks();
/**
* Returns the number of EppResourceIndex buckets to be used.
*/

View file

@ -18,7 +18,6 @@ import static google.registry.config.ConfigUtils.makeUrl;
import static org.joda.time.Duration.standardDays;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HostAndPort;
import java.net.URL;
import org.joda.time.Duration;
@ -50,31 +49,11 @@ public class TestRegistryConfig implements RegistryConfig {
return getProjectId() + "-snapshots";
}
@Override
public String getDomainListsBucket() {
return getProjectId() + "-domain-lists";
}
@Override
public String getCommitsBucket() {
return getProjectId() + "-commits";
}
@Override
public String getZoneFilesBucket() {
return getProjectId() + "-zonefiles";
}
@Override
public boolean getTmchCaTestingMode() {
return true;
}
@Override
public String getTmchMarksdbUrl() {
return "https://ry.marksdb.org";
}
@Override
public Optional<String> getECatcherAddress() {
throw new UnsupportedOperationException();
@ -117,11 +96,6 @@ public class TestRegistryConfig implements RegistryConfig {
return "noreply@testing.example";
}
@Override
public ImmutableList<String> getRegistrarChangesNotificationEmailAddresses() {
return ImmutableList.of("notification@test.example", "notification2@test.example");
}
@Override
public String getRegistrarDefaultWhoisServer() {
return "whois.nic.fakewhois.example";
@ -137,11 +111,6 @@ public class TestRegistryConfig implements RegistryConfig {
return "Nomulus";
}
@Override
public int getMaxChecks() {
return 50;
}
@Override
public int getEppResourceIndexBucketCount() {
return 2;