mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Move the environment configuration YAML files into the main JAR
This allows configuration to work properly from the nomulus tool. TESTED=I built and ran it against several environments, and all worked properly. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146697124
This commit is contained in:
parent
a904f2c6ee
commit
bf068e61d9
14 changed files with 51 additions and 128 deletions
|
@ -58,21 +58,16 @@ queues, and thus edit those associated XML files.
|
||||||
|
|
||||||
Global configuration is managed through YAML files that are built with and
|
Global configuration is managed through YAML files that are built with and
|
||||||
deployed in the app. The full list of config options and their default values
|
deployed in the app. The full list of config options and their default values
|
||||||
can be found in the `[default-config.yaml][default-config]` file. If you wish to
|
can be found in the [`default-config.yaml`][default-config] file. If you wish to
|
||||||
change any of these values, do not change make changes to this file. Instead,
|
change any of these values, do not edit this file. Instead, edit the environment
|
||||||
write a custom configuration file named `nomulus-config.yaml` that overrides
|
configuration file named
|
||||||
only the options you wish to change, and include it in the `WEB-INF` directory
|
`google/registry/config/files/nomulus-config-ENVIRONMENT.yaml`, overriding only
|
||||||
in each service.
|
the options you wish to change. Nomulus ships with blank placeholders for all
|
||||||
|
standard environments.
|
||||||
The existing environments that Nomulus ships with (alpha, sandbox, etc.) come
|
|
||||||
with placeholder configuration files that are included in the default deployment
|
|
||||||
build, so if you are using one of these environments, simply make your changes
|
|
||||||
to that file. For example, to configure the alpha environment, edit
|
|
||||||
`[env/alpha/common/WEB-INF/nomulus-config.yaml][nomulus-config-alpha]`.
|
|
||||||
|
|
||||||
You will not need to change most of the default settings. Here is the subset of
|
You will not need to change most of the default settings. Here is the subset of
|
||||||
settings that you will need to change for all deployed environments, including
|
settings that you will need to change for all deployed environments, including
|
||||||
development environments. See `[default-config.yaml][default-config]` for a full
|
development environments. See [`default-config.yaml`][default-config] for a full
|
||||||
description of each option:
|
description of each option:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
@ -93,7 +88,7 @@ need to specify more settings. The `nomulus-config-production-sample.yaml` file
|
||||||
contains an exhaustive list of all settings to override.
|
contains an exhaustive list of all settings to override.
|
||||||
|
|
||||||
From a code perspective, all configuration settings ultimately come through the
|
From a code perspective, all configuration settings ultimately come through the
|
||||||
`[RegistryConfig][registry-config]` class. This includes a Dagger module called
|
[`RegistryConfig`][registry-config] class. This includes a Dagger module called
|
||||||
`ConfigModule` that provides injectable configuration options. Some legacy
|
`ConfigModule` that provides injectable configuration options. Some legacy
|
||||||
configuration options that can be changed in this class include timeout lengths
|
configuration options that can be changed in this class include timeout lengths
|
||||||
and buffer sizes for various tasks, email addresses and URLs to use for various
|
and buffer sizes for various tasks, email addresses and URLs to use for various
|
||||||
|
@ -145,6 +140,5 @@ above, per-TLD configuration options are stored as data in the running system,
|
||||||
and thus do not require code pushes to update.
|
and thus do not require code pushes to update.
|
||||||
|
|
||||||
[app-engine-config]: https://cloud.google.com/appengine/docs/java/configuration-files
|
[app-engine-config]: https://cloud.google.com/appengine/docs/java/configuration-files
|
||||||
[default-config]: https://github.com/google/nomulus/blob/master/java/google/registry/config/default-config.yaml
|
[default-config]: https://github.com/google/nomulus/blob/master/java/google/registry/config/files/default-config.yaml
|
||||||
[nomulus-config-alpha]: https://github.com/google/nomulus/blob/master/java/google/registry/env/alpha/common/WEB-INF/nomulus-config.yaml
|
|
||||||
[registry-config]: https://github.com/google/nomulus/blob/master/java/google/registry/config/RegistryConfig.java
|
[registry-config]: https://github.com/google/nomulus/blob/master/java/google/registry/config/RegistryConfig.java
|
||||||
|
|
|
@ -53,7 +53,6 @@ zip_file(
|
||||||
"env/common/default/WEB-INF/logging.properties",
|
"env/common/default/WEB-INF/logging.properties",
|
||||||
"env/common/default/WEB-INF/queue.xml",
|
"env/common/default/WEB-INF/queue.xml",
|
||||||
"env/common/default/WEB-INF/web.xml",
|
"env/common/default/WEB-INF/web.xml",
|
||||||
"env/production/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/production/default/WEB-INF/appengine-web.xml",
|
"env/production/default/WEB-INF/appengine-web.xml",
|
||||||
"env/production/default/WEB-INF/cron.xml",
|
"env/production/default/WEB-INF/cron.xml",
|
||||||
"//java/google/registry/module/frontend:frontend_jar_deploy.jar",
|
"//java/google/registry/module/frontend:frontend_jar_deploy.jar",
|
||||||
|
@ -61,7 +60,6 @@ zip_file(
|
||||||
out = "registry_default.war",
|
out = "registry_default.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/common/default": "",
|
"domain_registry/java/google/registry/env/common/default": "",
|
||||||
"domain_registry/java/google/registry/env/production/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/production/default": "",
|
"domain_registry/java/google/registry/env/production/default": "",
|
||||||
"domain_registry/java/google/registry/module/frontend": "WEB-INF/lib",
|
"domain_registry/java/google/registry/module/frontend": "WEB-INF/lib",
|
||||||
},
|
},
|
||||||
|
@ -77,14 +75,12 @@ zip_file(
|
||||||
"env/common/backend/WEB-INF/logging.properties",
|
"env/common/backend/WEB-INF/logging.properties",
|
||||||
"env/common/backend/WEB-INF/web.xml",
|
"env/common/backend/WEB-INF/web.xml",
|
||||||
"env/production/backend/WEB-INF/appengine-web.xml",
|
"env/production/backend/WEB-INF/appengine-web.xml",
|
||||||
"env/production/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"//java/google/registry/module/backend:backend_jar_deploy.jar",
|
"//java/google/registry/module/backend:backend_jar_deploy.jar",
|
||||||
],
|
],
|
||||||
out = "registry_backend.war",
|
out = "registry_backend.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/common/backend": "",
|
"domain_registry/java/google/registry/env/common/backend": "",
|
||||||
"domain_registry/java/google/registry/env/production/backend": "",
|
"domain_registry/java/google/registry/env/production/backend": "",
|
||||||
"domain_registry/java/google/registry/env/production/common": "",
|
|
||||||
"domain_registry/java/google/registry/module/backend": "WEB-INF/lib",
|
"domain_registry/java/google/registry/module/backend": "WEB-INF/lib",
|
||||||
},
|
},
|
||||||
deps = [
|
deps = [
|
||||||
|
@ -98,14 +94,12 @@ zip_file(
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/common/tools/WEB-INF/logging.properties",
|
"env/common/tools/WEB-INF/logging.properties",
|
||||||
"env/common/tools/WEB-INF/web.xml",
|
"env/common/tools/WEB-INF/web.xml",
|
||||||
"env/production/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/production/tools/WEB-INF/appengine-web.xml",
|
"env/production/tools/WEB-INF/appengine-web.xml",
|
||||||
"//java/google/registry/module/tools:tools_jar_deploy.jar",
|
"//java/google/registry/module/tools:tools_jar_deploy.jar",
|
||||||
],
|
],
|
||||||
out = "registry_tools.war",
|
out = "registry_tools.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/common/tools": "",
|
"domain_registry/java/google/registry/env/common/tools": "",
|
||||||
"domain_registry/java/google/registry/env/production/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/production/tools": "",
|
"domain_registry/java/google/registry/env/production/tools": "",
|
||||||
"domain_registry/java/google/registry/module/tools": "WEB-INF/lib",
|
"domain_registry/java/google/registry/module/tools": "WEB-INF/lib",
|
||||||
},
|
},
|
||||||
|
@ -138,13 +132,11 @@ registry_ear_file(
|
||||||
zip_file(
|
zip_file(
|
||||||
name = "registry_default_sandbox_war",
|
name = "registry_default_sandbox_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/sandbox/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/sandbox/default/WEB-INF/appengine-web.xml",
|
"env/sandbox/default/WEB-INF/appengine-web.xml",
|
||||||
"env/sandbox/default/WEB-INF/cron.xml",
|
"env/sandbox/default/WEB-INF/cron.xml",
|
||||||
],
|
],
|
||||||
out = "registry_default_sandbox.war",
|
out = "registry_default_sandbox.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/sandbox/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/sandbox/default": "",
|
"domain_registry/java/google/registry/env/sandbox/default": "",
|
||||||
},
|
},
|
||||||
deps = [":registry_default_war"],
|
deps = [":registry_default_war"],
|
||||||
|
@ -154,12 +146,10 @@ zip_file(
|
||||||
name = "registry_backend_sandbox_war",
|
name = "registry_backend_sandbox_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/sandbox/backend/WEB-INF/appengine-web.xml",
|
"env/sandbox/backend/WEB-INF/appengine-web.xml",
|
||||||
"env/sandbox/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
],
|
],
|
||||||
out = "registry_backend_sandbox.war",
|
out = "registry_backend_sandbox.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/sandbox/backend": "",
|
"domain_registry/java/google/registry/env/sandbox/backend": "",
|
||||||
"domain_registry/java/google/registry/env/sandbox/common": "",
|
|
||||||
},
|
},
|
||||||
deps = [":registry_backend_war"],
|
deps = [":registry_backend_war"],
|
||||||
)
|
)
|
||||||
|
@ -167,12 +157,10 @@ zip_file(
|
||||||
zip_file(
|
zip_file(
|
||||||
name = "registry_tools_sandbox_war",
|
name = "registry_tools_sandbox_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/sandbox/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/sandbox/tools/WEB-INF/appengine-web.xml",
|
"env/sandbox/tools/WEB-INF/appengine-web.xml",
|
||||||
],
|
],
|
||||||
out = "registry_tools_sandbox.war",
|
out = "registry_tools_sandbox.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/sandbox/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/sandbox/tools": "",
|
"domain_registry/java/google/registry/env/sandbox/tools": "",
|
||||||
},
|
},
|
||||||
deps = [":registry_tools_war"],
|
deps = [":registry_tools_war"],
|
||||||
|
@ -200,13 +188,11 @@ registry_ear_file(
|
||||||
zip_file(
|
zip_file(
|
||||||
name = "registry_default_alpha_war",
|
name = "registry_default_alpha_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/alpha/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/alpha/default/WEB-INF/appengine-web.xml",
|
"env/alpha/default/WEB-INF/appengine-web.xml",
|
||||||
"env/alpha/default/WEB-INF/cron.xml",
|
"env/alpha/default/WEB-INF/cron.xml",
|
||||||
],
|
],
|
||||||
out = "registry_default_alpha.war",
|
out = "registry_default_alpha.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/alpha/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/alpha/default": "",
|
"domain_registry/java/google/registry/env/alpha/default": "",
|
||||||
},
|
},
|
||||||
deps = [":registry_default_war"],
|
deps = [":registry_default_war"],
|
||||||
|
@ -216,12 +202,10 @@ zip_file(
|
||||||
name = "registry_backend_alpha_war",
|
name = "registry_backend_alpha_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/alpha/backend/WEB-INF/appengine-web.xml",
|
"env/alpha/backend/WEB-INF/appengine-web.xml",
|
||||||
"env/alpha/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
],
|
],
|
||||||
out = "registry_backend_alpha.war",
|
out = "registry_backend_alpha.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/alpha/backend": "",
|
"domain_registry/java/google/registry/env/alpha/backend": "",
|
||||||
"domain_registry/java/google/registry/env/alpha/common": "",
|
|
||||||
},
|
},
|
||||||
deps = [":registry_backend_war"],
|
deps = [":registry_backend_war"],
|
||||||
)
|
)
|
||||||
|
@ -229,12 +213,10 @@ zip_file(
|
||||||
zip_file(
|
zip_file(
|
||||||
name = "registry_tools_alpha_war",
|
name = "registry_tools_alpha_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/alpha/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/alpha/tools/WEB-INF/appengine-web.xml",
|
"env/alpha/tools/WEB-INF/appengine-web.xml",
|
||||||
],
|
],
|
||||||
out = "registry_tools_alpha.war",
|
out = "registry_tools_alpha.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/alpha/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/alpha/tools": "",
|
"domain_registry/java/google/registry/env/alpha/tools": "",
|
||||||
},
|
},
|
||||||
deps = [":registry_tools_war"],
|
deps = [":registry_tools_war"],
|
||||||
|
@ -262,13 +244,11 @@ registry_ear_file(
|
||||||
zip_file(
|
zip_file(
|
||||||
name = "registry_default_crash_war",
|
name = "registry_default_crash_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/crash/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/crash/default/WEB-INF/appengine-web.xml",
|
"env/crash/default/WEB-INF/appengine-web.xml",
|
||||||
"env/crash/default/WEB-INF/cron.xml",
|
"env/crash/default/WEB-INF/cron.xml",
|
||||||
],
|
],
|
||||||
out = "registry_default_crash.war",
|
out = "registry_default_crash.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/crash/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/crash/default": "",
|
"domain_registry/java/google/registry/env/crash/default": "",
|
||||||
},
|
},
|
||||||
deps = [":registry_default_war"],
|
deps = [":registry_default_war"],
|
||||||
|
@ -278,12 +258,10 @@ zip_file(
|
||||||
name = "registry_backend_crash_war",
|
name = "registry_backend_crash_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/crash/backend/WEB-INF/appengine-web.xml",
|
"env/crash/backend/WEB-INF/appengine-web.xml",
|
||||||
"env/crash/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
],
|
],
|
||||||
out = "registry_backend_crash.war",
|
out = "registry_backend_crash.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/crash/backend": "",
|
"domain_registry/java/google/registry/env/crash/backend": "",
|
||||||
"domain_registry/java/google/registry/env/crash/common": "",
|
|
||||||
},
|
},
|
||||||
deps = [":registry_backend_war"],
|
deps = [":registry_backend_war"],
|
||||||
)
|
)
|
||||||
|
@ -291,12 +269,10 @@ zip_file(
|
||||||
zip_file(
|
zip_file(
|
||||||
name = "registry_tools_crash_war",
|
name = "registry_tools_crash_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/crash/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/crash/tools/WEB-INF/appengine-web.xml",
|
"env/crash/tools/WEB-INF/appengine-web.xml",
|
||||||
],
|
],
|
||||||
out = "registry_tools_crash.war",
|
out = "registry_tools_crash.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/crash/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/crash/tools": "",
|
"domain_registry/java/google/registry/env/crash/tools": "",
|
||||||
},
|
},
|
||||||
deps = [":registry_tools_war"],
|
deps = [":registry_tools_war"],
|
||||||
|
@ -324,12 +300,10 @@ registry_ear_file(
|
||||||
zip_file(
|
zip_file(
|
||||||
name = "registry_default_local_war",
|
name = "registry_default_local_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/local/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/local/default/WEB-INF/appengine-web.xml",
|
"env/local/default/WEB-INF/appengine-web.xml",
|
||||||
],
|
],
|
||||||
out = "registry_default_local.war",
|
out = "registry_default_local.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/local/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/local/default": "",
|
"domain_registry/java/google/registry/env/local/default": "",
|
||||||
},
|
},
|
||||||
deps = [":registry_default_war"],
|
deps = [":registry_default_war"],
|
||||||
|
@ -339,12 +313,10 @@ zip_file(
|
||||||
name = "registry_backend_local_war",
|
name = "registry_backend_local_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/local/backend/WEB-INF/appengine-web.xml",
|
"env/local/backend/WEB-INF/appengine-web.xml",
|
||||||
"env/local/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
],
|
],
|
||||||
out = "registry_backend_local.war",
|
out = "registry_backend_local.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/local/backend": "",
|
"domain_registry/java/google/registry/env/local/backend": "",
|
||||||
"domain_registry/java/google/registry/env/local/common": "",
|
|
||||||
},
|
},
|
||||||
deps = [":registry_backend_war"],
|
deps = [":registry_backend_war"],
|
||||||
)
|
)
|
||||||
|
@ -352,12 +324,10 @@ zip_file(
|
||||||
zip_file(
|
zip_file(
|
||||||
name = "registry_tools_local_war",
|
name = "registry_tools_local_war",
|
||||||
srcs = [
|
srcs = [
|
||||||
"env/local/common/WEB-INF/nomulus-config.yaml",
|
|
||||||
"env/local/tools/WEB-INF/appengine-web.xml",
|
"env/local/tools/WEB-INF/appengine-web.xml",
|
||||||
],
|
],
|
||||||
out = "registry_tools_local.war",
|
out = "registry_tools_local.war",
|
||||||
mappings = {
|
mappings = {
|
||||||
"domain_registry/java/google/registry/env/local/common": "",
|
|
||||||
"domain_registry/java/google/registry/env/local/tools": "",
|
"domain_registry/java/google/registry/env/local/tools": "",
|
||||||
},
|
},
|
||||||
deps = [":registry_tools_war"],
|
deps = [":registry_tools_war"],
|
||||||
|
|
|
@ -7,7 +7,7 @@ licenses(["notice"]) # Apache 2.0
|
||||||
java_library(
|
java_library(
|
||||||
name = "config",
|
name = "config",
|
||||||
srcs = glob(["*.java"]),
|
srcs = glob(["*.java"]),
|
||||||
resources = glob(["*.yaml"]),
|
resources = glob(["files/*.yaml"]),
|
||||||
deps = [
|
deps = [
|
||||||
"//java/google/registry/util",
|
"//java/google/registry/util",
|
||||||
"@com_google_appengine_api_1_0_sdk",
|
"@com_google_appengine_api_1_0_sdk",
|
||||||
|
|
|
@ -19,7 +19,6 @@ import static google.registry.config.ConfigUtils.makeUrl;
|
||||||
import static google.registry.config.YamlUtils.getConfigSettings;
|
import static google.registry.config.YamlUtils.getConfigSettings;
|
||||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||||
|
|
||||||
import com.google.common.base.Ascii;
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
@ -27,6 +26,7 @@ import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.net.HostAndPort;
|
import com.google.common.net.HostAndPort;
|
||||||
import dagger.Module;
|
import dagger.Module;
|
||||||
import dagger.Provides;
|
import dagger.Provides;
|
||||||
|
import google.registry.config.RegistryConfigSettings.AppEngine.ToolsServiceUrl;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -43,6 +43,11 @@ import org.joda.time.Duration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Central clearing-house for all configuration.
|
* Central clearing-house for all configuration.
|
||||||
|
*
|
||||||
|
* <p>This class does not represent the total configuration of the Nomulus service. It's <b>only
|
||||||
|
* meant for settings that need to be configured <i>once</i></b>. Settings which may be subject to
|
||||||
|
* change in the future, should instead be retrieved from Datastore. The {@link
|
||||||
|
* google.registry.model.registry.Registry Registry} class is one such example of this.
|
||||||
*/
|
*/
|
||||||
public final class RegistryConfig {
|
public final class RegistryConfig {
|
||||||
|
|
||||||
|
@ -54,26 +59,7 @@ public final class RegistryConfig {
|
||||||
String value() default "";
|
String value() default "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Dagger module for providing configuration settings. */
|
||||||
* Configuration example for the Nomulus codebase.
|
|
||||||
*
|
|
||||||
* <p>The Nomulus codebase contains many classes that inject configurable settings. This is
|
|
||||||
* the centralized class that is used by default to configure them all, in hard-coded type-safe
|
|
||||||
* Java code.
|
|
||||||
*
|
|
||||||
* <p>This class does not represent the total configuration of the Nomulus service. It's
|
|
||||||
* <b>only meant for settings that need to be configured <i>once</i></b>. Settings which may
|
|
||||||
* be subject to change in the future, should instead be retrieved from Datastore. The
|
|
||||||
* {@link google.registry.model.registry.Registry Registry} class is one such example of this.
|
|
||||||
*
|
|
||||||
* <h3>Customization</h3>
|
|
||||||
*
|
|
||||||
* <p>It is recommended that users do not modify this file within a forked repository. It is
|
|
||||||
* preferable to modify these settings by swapping out this module with a separate copied version
|
|
||||||
* in the user's repository. For this to work, other files need to be copied too, such as the
|
|
||||||
* {@code @Component} instances under {@code google.registry.module}. This allows modules to be
|
|
||||||
* substituted at the {@code @Component} level.
|
|
||||||
*/
|
|
||||||
@Module
|
@Module
|
||||||
public static final class ConfigModule {
|
public static final class ConfigModule {
|
||||||
|
|
||||||
|
@ -1056,22 +1042,8 @@ public final class RegistryConfig {
|
||||||
* <p>This is used by the {@code nomulus} tool to connect to the App Engine remote API.
|
* <p>This is used by the {@code nomulus} tool to connect to the App Engine remote API.
|
||||||
*/
|
*/
|
||||||
public static HostAndPort getServer() {
|
public static HostAndPort getServer() {
|
||||||
// TODO(b/33386530): Make this configurable in a way that is accessible from the nomulus
|
ToolsServiceUrl url = CONFIG_SETTINGS.get().appEngine.toolsServiceUrl;
|
||||||
// command-line tool.
|
return HostAndPort.fromParts(url.hostName, url.port);
|
||||||
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. */
|
/** Returns the amount of time a singleton should be cached, before expiring. */
|
||||||
|
|
|
@ -14,62 +14,52 @@
|
||||||
|
|
||||||
package google.registry.config;
|
package google.registry.config;
|
||||||
|
|
||||||
import static google.registry.config.RegistryEnvironment.UNITTEST;
|
import static com.google.common.base.Ascii.toLowerCase;
|
||||||
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
|
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
|
||||||
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
import static google.registry.util.ResourceUtils.readResourceUtf8;
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.io.CharStreams;
|
|
||||||
import google.registry.util.FormattingLogger;
|
import google.registry.util.FormattingLogger;
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
/** Utility methods for dealing with YAML. */
|
/**
|
||||||
|
* Utility methods for dealing with YAML.
|
||||||
|
*
|
||||||
|
* <p>There are always two YAML configuration files that are used: the {@code default-config.yaml}
|
||||||
|
* file, which contains default configuration for all environments, and the environment-specific
|
||||||
|
* {@code nomulus-config-ENVIRONMENT.yaml} file, which contains overrides for the default values for
|
||||||
|
* environment-specific settings such as the App Engine project ID. The environment-specific
|
||||||
|
* configuration can be blank, but it must exist.
|
||||||
|
*/
|
||||||
public final class YamlUtils {
|
public final class YamlUtils {
|
||||||
|
|
||||||
private static final FormattingLogger logger = getLoggerForCallerClass();
|
private static final FormattingLogger logger = getLoggerForCallerClass();
|
||||||
|
|
||||||
private static final String CUSTOM_CONFIG_PATH = "WEB-INF/nomulus-config.yaml";
|
private static final String ENVIRONMENT_CONFIG_FORMAT = "files/nomulus-config-%s.yaml";
|
||||||
private static final String YAML_CONFIG_PROD =
|
private static final String YAML_CONFIG_PROD =
|
||||||
readResourceUtf8(RegistryConfig.class, "default-config.yaml");
|
readResourceUtf8(RegistryConfig.class, "files/default-config.yaml");
|
||||||
private static final String YAML_CONFIG_UNITTEST =
|
|
||||||
readResourceUtf8(RegistryConfig.class, "unittest-config.yaml");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the {@link RegistryConfigSettings} POJO from the YAML configuration file(s).
|
* Loads the {@link RegistryConfigSettings} POJO from the YAML configuration files.
|
||||||
*
|
*
|
||||||
* <p>The {@code default-config.yaml} file in this directory is loaded first, and a fatal error is
|
* <p>The {@code default-config.yaml} file in this directory is loaded first, and a fatal error is
|
||||||
* thrown if it cannot be found or if there is an error parsing it. Separately, the custom config
|
* thrown if it cannot be found or if there is an error parsing it. Separately, the
|
||||||
* file located in {@code WEB-INF/nomulus-config.yaml} is also loaded and those values merged into
|
* environment-specific config file named {@code nomulus-config-ENVIRONMENT.yaml} is also loaded
|
||||||
* the POJO. If the custom config file does not exist then an info notice is logged, but if it
|
* and those values merged into the POJO.
|
||||||
* does exist and is invalid then a fatal error is thrown.
|
|
||||||
*
|
*
|
||||||
* <p>Unit tests load the {@code unittest-config.yaml} file for custom config.
|
* @throws IllegalStateException if the configuration files don't exist or are invalid
|
||||||
*/
|
*/
|
||||||
static RegistryConfigSettings getConfigSettings() {
|
static RegistryConfigSettings getConfigSettings() {
|
||||||
String yaml = YAML_CONFIG_PROD;
|
String configFilePath =
|
||||||
if (RegistryEnvironment.get() == UNITTEST) {
|
String.format(ENVIRONMENT_CONFIG_FORMAT, toLowerCase(RegistryEnvironment.get().name()));
|
||||||
yaml = mergeYaml(yaml, YAML_CONFIG_UNITTEST);
|
String customYaml = readResourceUtf8(RegistryConfig.class, configFilePath);
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
// We have to load the file this way because App Engine does not allow loading files in the
|
String mergedYaml = mergeYaml(YAML_CONFIG_PROD, customYaml);
|
||||||
// WEB-INF directory using a class loader.
|
return new Yaml().loadAs(mergedYaml, RegistryConfigSettings.class);
|
||||||
FileInputStream fin = new FileInputStream(new File(CUSTOM_CONFIG_PATH));
|
|
||||||
String customYaml = CharStreams.toString(new InputStreamReader(fin, "UTF-8"));
|
|
||||||
yaml = mergeYaml(yaml, customYaml);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.warningfmt(
|
|
||||||
"There was no custom configuration file to load at %s", CUSTOM_CONFIG_PATH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return new Yaml().loadAs(yaml, RegistryConfigSettings.class);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalStateException("Fatal error: Custom YAML configuration file is invalid", e);
|
throw new IllegalStateException(
|
||||||
|
"Fatal error: Environment configuration YAML file is invalid", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,18 +79,14 @@ public final class YamlUtils {
|
||||||
static String mergeYaml(String defaultYaml, String customYaml) {
|
static String mergeYaml(String defaultYaml, String customYaml) {
|
||||||
Yaml yaml = new Yaml();
|
Yaml yaml = new Yaml();
|
||||||
Map<String, Object> yamlMap = loadAsMap(yaml, defaultYaml).get();
|
Map<String, Object> yamlMap = loadAsMap(yaml, defaultYaml).get();
|
||||||
try {
|
|
||||||
Optional<Map<String, Object>> customMap = loadAsMap(yaml, customYaml);
|
Optional<Map<String, Object>> customMap = loadAsMap(yaml, customYaml);
|
||||||
if (customMap.isPresent()) {
|
if (customMap.isPresent()) {
|
||||||
yamlMap = mergeMaps(yamlMap, customMap.get());
|
yamlMap = mergeMaps(yamlMap, customMap.get());
|
||||||
logger.infofmt("Successfully loaded custom YAML configuration file.");
|
logger.infofmt("Successfully loaded environment configuration YAML file.");
|
||||||
} else {
|
} else {
|
||||||
logger.infofmt("Ignoring empty custom YAML configuration file.");
|
logger.infofmt("Ignoring empty environment configuration YAML file.");
|
||||||
}
|
}
|
||||||
return yaml.dump(yamlMap);
|
return yaml.dump(yamlMap);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new IllegalStateException("Fatal error: Custom YAML configuration file is invalid", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
# Add environment-specific configuration here.
|
Loading…
Add table
Reference in a new issue