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/"; 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 @Provides
@Config("zoneFilesBucket") @Config("zoneFilesBucket")
public static String provideZoneFilesBucket(RegistryConfig config) { public static String provideZoneFilesBucket(@Config("projectId") String projectId) {
return config.getZoneFilesBucket(); return projectId + "-zonefiles";
} }
/** @see RegistryConfig#getCommitsBucket() */ /**
* Returns the Google Cloud Storage bucket for storing commit logs.
*
* @see google.registry.backup.ExportCommitLogDiffAction
*/
@Provides @Provides
@Config("commitLogGcsBucket") @Config("commitLogGcsBucket")
public static String provideCommitLogGcsBucket(RegistryConfig config) { public static String provideCommitLogGcsBucket(@Config("projectId") String projectId) {
return config.getCommitsBucket(); return projectId + "-commits";
} }
/** @see RegistryConfig#getCommitLogDatastoreRetention() */ /** @see RegistryConfig#getCommitLogDatastoreRetention() */
@ -203,8 +211,8 @@ public final class ConfigModule {
*/ */
@Provides @Provides
@Config("domainListsGcsBucket") @Config("domainListsGcsBucket")
public static String provideDomainListsGcsBucket(RegistryConfig config) { public static String provideDomainListsGcsBucket(@Config("projectId") String projectId) {
return config.getDomainListsBucket(); return projectId + "-domain-lists";
} }
/** /**
@ -360,12 +368,25 @@ public final class ConfigModule {
return "admin@example.com"; 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 @Provides
@Config("registrarChangesNotificationEmailAddresses") @Config("registrarChangesNotificationEmailAddresses")
public static ImmutableList<String> provideRegistrarChangesNotificationEmailAddresses( public static ImmutableList<String> provideRegistrarChangesNotificationEmailAddresses(
RegistryConfig config) { RegistryEnvironment environment) {
return config.getRegistrarChangesNotificationEmailAddresses(); 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"; return "registry.example.com";
} }
/** @see RegistryConfig#getTmchCaTestingMode() */ /**
* Returns {@code true} if TMCH certificate authority should be in testing mode.
*
* @see RegistryConfig#getTmchCaTestingMode()
*/
@Provides @Provides
@Config("tmchCaTestingMode") @Config("tmchCaTestingMode")
public static boolean provideTmchCaTestingMode(RegistryConfig config) { 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 @Provides
@Config("tmchMarksdbUrl") @Config("tmchMarksdbUrl")
public static String provideTmchMarksdbUrl(RegistryConfig config) { public static String provideTmchMarksdbUrl(RegistryEnvironment environment) {
return config.getTmchMarksdbUrl(); 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(); 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 @Provides
@Config("maxChecks") @Config("maxChecks")
public static int provideMaxChecks(RegistryConfig config) { public static int provideMaxChecks() {
return config.getMaxChecks(); 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.appengine.api.utils.SystemProperty;
import com.google.common.base.Ascii; import com.google.common.base.Ascii;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HostAndPort; import com.google.common.net.HostAndPort;
import java.net.URL; import java.net.URL;
import javax.annotation.concurrent.Immutable; import javax.annotation.concurrent.Immutable;
@ -83,21 +82,6 @@ public final class ProductionRegistryConfigExample implements RegistryConfig {
return getProjectId() + "-snapshots"; 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 @Override
public boolean getTmchCaTestingMode() { public boolean getTmchCaTestingMode() {
switch (environment) { 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 @Override
public Optional<String> getECatcherAddress() { public Optional<String> getECatcherAddress() {
throw new UnsupportedOperationException(); // n/a 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()); 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 @Override
public String getRegistrarDefaultWhoisServer() { public String getRegistrarDefaultWhoisServer() {
return "whois.nic.registry.example"; return "whois.nic.registry.example";
@ -189,11 +153,6 @@ public final class ProductionRegistryConfigExample implements RegistryConfig {
return "Nomulus"; return "Nomulus";
} }
@Override
public int getMaxChecks() {
return 50;
}
@Override @Override
public int getEppResourceIndexBucketCount() { public int getEppResourceIndexBucketCount() {
return 997; return 997;

View file

@ -15,7 +15,6 @@
package google.registry.config; package google.registry.config;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HostAndPort; import com.google.common.net.HostAndPort;
import java.net.URL; import java.net.URL;
import org.joda.time.Duration; import org.joda.time.Duration;
@ -42,13 +41,6 @@ public interface RegistryConfig {
*/ */
public String getSnapshotsBucket(); 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. * Number of sharded commit log buckets.
* *
@ -75,20 +67,6 @@ public interface RegistryConfig {
*/ */
public Duration getCommitLogDatastoreRetention(); 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. * Returns {@code true} if TMCH certificate authority should be in testing mode.
* *
@ -96,16 +74,6 @@ public interface RegistryConfig {
*/ */
public boolean getTmchCaTestingMode(); 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(); public Optional<String> getECatcherAddress();
/** /**
@ -159,14 +127,6 @@ public interface RegistryConfig {
*/ */
public String getContactAndHostRepositoryIdentifier(); 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}. * Returns default WHOIS server to use when {@code Registrar#getWhoisServer()} is {@code null}.
* *
@ -185,11 +145,6 @@ public interface RegistryConfig {
*/ */
public String getDocumentationProjectTitle(); 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. * 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 static org.joda.time.Duration.standardDays;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HostAndPort; import com.google.common.net.HostAndPort;
import java.net.URL; import java.net.URL;
import org.joda.time.Duration; import org.joda.time.Duration;
@ -50,31 +49,11 @@ public class TestRegistryConfig implements RegistryConfig {
return getProjectId() + "-snapshots"; 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 @Override
public boolean getTmchCaTestingMode() { public boolean getTmchCaTestingMode() {
return true; return true;
} }
@Override
public String getTmchMarksdbUrl() {
return "https://ry.marksdb.org";
}
@Override @Override
public Optional<String> getECatcherAddress() { public Optional<String> getECatcherAddress() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
@ -117,11 +96,6 @@ public class TestRegistryConfig implements RegistryConfig {
return "noreply@testing.example"; return "noreply@testing.example";
} }
@Override
public ImmutableList<String> getRegistrarChangesNotificationEmailAddresses() {
return ImmutableList.of("notification@test.example", "notification2@test.example");
}
@Override @Override
public String getRegistrarDefaultWhoisServer() { public String getRegistrarDefaultWhoisServer() {
return "whois.nic.fakewhois.example"; return "whois.nic.fakewhois.example";
@ -137,11 +111,6 @@ public class TestRegistryConfig implements RegistryConfig {
return "Nomulus"; return "Nomulus";
} }
@Override
public int getMaxChecks() {
return 50;
}
@Override @Override
public int getEppResourceIndexBucketCount() { public int getEppResourceIndexBucketCount() {
return 2; return 2;