Add initial implementation of YAML config file

This implements the basic framework that allows global YAML
configuration, per-environment custom configuration, and unit-
test-specific configuration.

TESTED=I deployed to alpha, ran some EPP commands through the
nomulus tool, and verified no errors.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145422680
This commit is contained in:
mcilwain 2017-01-24 08:40:41 -08:00 committed by Ben McIlwain
parent 15ba52988b
commit b5cf58bf2c
29 changed files with 480 additions and 55 deletions

View file

@ -53,6 +53,7 @@ zip_file(
"env/common/default/WEB-INF/logging.properties",
"env/common/default/WEB-INF/queue.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/cron.xml",
"//java/google/registry/module/frontend:frontend_jar_deploy.jar",
@ -60,6 +61,7 @@ zip_file(
out = "registry_default.war",
mappings = {
"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/module/frontend": "WEB-INF/lib",
},
@ -75,12 +77,14 @@ zip_file(
"env/common/backend/WEB-INF/logging.properties",
"env/common/backend/WEB-INF/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",
],
out = "registry_backend.war",
mappings = {
"domain_registry/java/google/registry/env/common/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",
},
deps = [
@ -94,12 +98,14 @@ zip_file(
srcs = [
"env/common/tools/WEB-INF/logging.properties",
"env/common/tools/WEB-INF/web.xml",
"env/production/common/WEB-INF/nomulus-config.yaml",
"env/production/tools/WEB-INF/appengine-web.xml",
"//java/google/registry/module/tools:tools_jar_deploy.jar",
],
out = "registry_tools.war",
mappings = {
"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/module/tools": "WEB-INF/lib",
},
@ -132,27 +138,43 @@ registry_ear_file(
zip_file(
name = "registry_default_sandbox_war",
srcs = [
"env/sandbox/common/WEB-INF/nomulus-config.yaml",
"env/sandbox/default/WEB-INF/appengine-web.xml",
"env/sandbox/default/WEB-INF/cron.xml",
],
out = "registry_default_sandbox.war",
mappings = {"domain_registry/java/google/registry/env/sandbox/default": ""},
mappings = {
"domain_registry/java/google/registry/env/sandbox/common": "",
"domain_registry/java/google/registry/env/sandbox/default": "",
},
deps = [":registry_default_war"],
)
zip_file(
name = "registry_backend_sandbox_war",
srcs = ["env/sandbox/backend/WEB-INF/appengine-web.xml"],
srcs = [
"env/sandbox/backend/WEB-INF/appengine-web.xml",
"env/sandbox/common/WEB-INF/nomulus-config.yaml",
],
out = "registry_backend_sandbox.war",
mappings = {"domain_registry/java/google/registry/env/sandbox/backend": ""},
mappings = {
"domain_registry/java/google/registry/env/sandbox/backend": "",
"domain_registry/java/google/registry/env/sandbox/common": "",
},
deps = [":registry_backend_war"],
)
zip_file(
name = "registry_tools_sandbox_war",
srcs = ["env/sandbox/tools/WEB-INF/appengine-web.xml"],
srcs = [
"env/sandbox/common/WEB-INF/nomulus-config.yaml",
"env/sandbox/tools/WEB-INF/appengine-web.xml",
],
out = "registry_tools_sandbox.war",
mappings = {"domain_registry/java/google/registry/env/sandbox/tools": ""},
mappings = {
"domain_registry/java/google/registry/env/sandbox/common": "",
"domain_registry/java/google/registry/env/sandbox/tools": "",
},
deps = [":registry_tools_war"],
)
@ -178,27 +200,43 @@ registry_ear_file(
zip_file(
name = "registry_default_alpha_war",
srcs = [
"env/alpha/common/WEB-INF/nomulus-config.yaml",
"env/alpha/default/WEB-INF/appengine-web.xml",
"env/alpha/default/WEB-INF/cron.xml",
],
out = "registry_default_alpha.war",
mappings = {"domain_registry/java/google/registry/env/alpha/default": ""},
mappings = {
"domain_registry/java/google/registry/env/alpha/common": "",
"domain_registry/java/google/registry/env/alpha/default": "",
},
deps = [":registry_default_war"],
)
zip_file(
name = "registry_backend_alpha_war",
srcs = ["env/alpha/backend/WEB-INF/appengine-web.xml"],
srcs = [
"env/alpha/backend/WEB-INF/appengine-web.xml",
"env/alpha/common/WEB-INF/nomulus-config.yaml",
],
out = "registry_backend_alpha.war",
mappings = {"domain_registry/java/google/registry/env/alpha/backend": ""},
mappings = {
"domain_registry/java/google/registry/env/alpha/backend": "",
"domain_registry/java/google/registry/env/alpha/common": "",
},
deps = [":registry_backend_war"],
)
zip_file(
name = "registry_tools_alpha_war",
srcs = ["env/alpha/tools/WEB-INF/appengine-web.xml"],
srcs = [
"env/alpha/common/WEB-INF/nomulus-config.yaml",
"env/alpha/tools/WEB-INF/appengine-web.xml",
],
out = "registry_tools_alpha.war",
mappings = {"domain_registry/java/google/registry/env/alpha/tools": ""},
mappings = {
"domain_registry/java/google/registry/env/alpha/common": "",
"domain_registry/java/google/registry/env/alpha/tools": "",
},
deps = [":registry_tools_war"],
)
@ -224,27 +262,43 @@ registry_ear_file(
zip_file(
name = "registry_default_crash_war",
srcs = [
"env/crash/common/WEB-INF/nomulus-config.yaml",
"env/crash/default/WEB-INF/appengine-web.xml",
"env/crash/default/WEB-INF/cron.xml",
],
out = "registry_default_crash.war",
mappings = {"domain_registry/java/google/registry/env/crash/default": ""},
mappings = {
"domain_registry/java/google/registry/env/crash/common": "",
"domain_registry/java/google/registry/env/crash/default": "",
},
deps = [":registry_default_war"],
)
zip_file(
name = "registry_backend_crash_war",
srcs = ["env/crash/backend/WEB-INF/appengine-web.xml"],
srcs = [
"env/crash/backend/WEB-INF/appengine-web.xml",
"env/crash/common/WEB-INF/nomulus-config.yaml",
],
out = "registry_backend_crash.war",
mappings = {"domain_registry/java/google/registry/env/crash/backend": ""},
mappings = {
"domain_registry/java/google/registry/env/crash/backend": "",
"domain_registry/java/google/registry/env/crash/common": "",
},
deps = [":registry_backend_war"],
)
zip_file(
name = "registry_tools_crash_war",
srcs = ["env/crash/tools/WEB-INF/appengine-web.xml"],
srcs = [
"env/crash/common/WEB-INF/nomulus-config.yaml",
"env/crash/tools/WEB-INF/appengine-web.xml",
],
out = "registry_tools_crash.war",
mappings = {"domain_registry/java/google/registry/env/crash/tools": ""},
mappings = {
"domain_registry/java/google/registry/env/crash/common": "",
"domain_registry/java/google/registry/env/crash/tools": "",
},
deps = [":registry_tools_war"],
)
@ -269,24 +323,42 @@ registry_ear_file(
zip_file(
name = "registry_default_local_war",
srcs = ["env/local/default/WEB-INF/appengine-web.xml"],
srcs = [
"env/local/common/WEB-INF/nomulus-config.yaml",
"env/local/default/WEB-INF/appengine-web.xml",
],
out = "registry_default_local.war",
mappings = {"domain_registry/java/google/registry/env/local/default": ""},
mappings = {
"domain_registry/java/google/registry/env/local/common": "",
"domain_registry/java/google/registry/env/local/default": "",
},
deps = [":registry_default_war"],
)
zip_file(
name = "registry_backend_local_war",
srcs = ["env/local/backend/WEB-INF/appengine-web.xml"],
srcs = [
"env/local/backend/WEB-INF/appengine-web.xml",
"env/local/common/WEB-INF/nomulus-config.yaml",
],
out = "registry_backend_local.war",
mappings = {"domain_registry/java/google/registry/env/local/backend": ""},
mappings = {
"domain_registry/java/google/registry/env/local/backend": "",
"domain_registry/java/google/registry/env/local/common": "",
},
deps = [":registry_backend_war"],
)
zip_file(
name = "registry_tools_local_war",
srcs = ["env/local/tools/WEB-INF/appengine-web.xml"],
srcs = [
"env/local/common/WEB-INF/nomulus-config.yaml",
"env/local/tools/WEB-INF/appengine-web.xml",
],
out = "registry_tools_local.war",
mappings = {"domain_registry/java/google/registry/env/local/tools": ""},
mappings = {
"domain_registry/java/google/registry/env/local/common": "",
"domain_registry/java/google/registry/env/local/tools": "",
},
deps = [":registry_tools_war"],
)

View file

@ -7,7 +7,9 @@ licenses(["notice"]) # Apache 2.0
java_library(
name = "config",
srcs = glob(["*.java"]),
resources = glob(["*.yaml"]),
deps = [
"//java/google/registry/util",
"@com_google_appengine_api_1_0_sdk",
"@com_google_auto_value",
"@com_google_code_findbugs_jsr305",
@ -15,5 +17,6 @@ java_library(
"@com_google_guava",
"@joda_time",
"@org_joda_money",
"@org_yaml_snakeyaml",
],
)

View file

@ -14,13 +14,15 @@
package google.registry.config;
import static com.google.common.base.Suppliers.memoize;
import static google.registry.config.ConfigUtils.makeUrl;
import static google.registry.config.YamlUtils.getConfigSettings;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
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.base.Supplier;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.net.HostAndPort;
@ -83,8 +85,8 @@ public final class RegistryConfig {
@Provides
@Config("projectId")
public static String provideProjectId() {
return RegistryConfig.getProjectId();
public static String provideProjectId(RegistryConfigSettings config) {
return config.general.appEngineProjectId;
}
/**
@ -362,8 +364,8 @@ public final class RegistryConfig {
*/
@Provides
@Config("eppResourceIndexBucketCount")
public static int provideEppResourceIndexBucketCount() {
return RegistryConfig.getEppResourceIndexBucketCount();
public static int provideEppResourceIndexBucketCount(RegistryConfigSettings config) {
return config.datastore.eppResourceIndexBucketsNum;
}
/**
@ -893,8 +895,8 @@ public final class RegistryConfig {
*/
@Provides
@Config("stackdriverMaxQps")
public static int provideStackdriverMaxQps() {
return 30;
public static int provideStackdriverMaxQps(RegistryConfigSettings config) {
return config.monitoring.stackdriverMaxQps;
}
/**
@ -905,8 +907,8 @@ public final class RegistryConfig {
*/
@Provides
@Config("stackdriverMaxPointsPerRequest")
public static int provideStackdriverMaxPointsPerRequest() {
return 200;
public static int provideStackdriverMaxPointsPerRequest(RegistryConfigSettings config) {
return config.monitoring.stackdriverMaxPointsPerRequest;
}
/**
@ -917,8 +919,8 @@ public final class RegistryConfig {
*/
@Provides
@Config("metricsWriteInterval")
public static Duration provideMetricsWriteInterval() {
return Duration.standardSeconds(60);
public static Duration provideMetricsWriteInterval(RegistryConfigSettings config) {
return Duration.standardSeconds(config.monitoring.writeIntervalSeconds);
}
/**
@ -1015,6 +1017,12 @@ public final class RegistryConfig {
return "TheRegistrar";
}
@Singleton
@Provides
static RegistryConfigSettings provideRegistryConfigSettings() {
return CONFIG_SETTINGS.get();
}
/**
* Returns the help path for the RDAP terms of service.
*
@ -1105,16 +1113,7 @@ public final class RegistryConfig {
* Returns the App Engine project ID, which is based off the environment name.
*/
public static String getProjectId() {
String prodProjectId = "domain-registry";
RegistryEnvironment environment = RegistryEnvironment.get();
switch (environment) {
case PRODUCTION:
case UNITTEST:
case LOCAL:
return prodProjectId;
default:
return prodProjectId + "-" + Ascii.toLowerCase(environment.name());
}
return CONFIG_SETTINGS.get().general.appEngineProjectId;
}
/**
@ -1140,12 +1139,7 @@ public final class RegistryConfig {
* @see google.registry.model.ofy.CommitLogBucket
*/
public static int getCommitLogBucketCount() {
switch (RegistryEnvironment.get()) {
case UNITTEST:
return 3;
default:
return 100;
}
return CONFIG_SETTINGS.get().datastore.commitLogBucketsNum;
}
/**
@ -1246,12 +1240,7 @@ public final class RegistryConfig {
* Returns the number of {@code EppResourceIndex} buckets to be used.
*/
public static int getEppResourceIndexBucketCount() {
switch (RegistryEnvironment.get()) {
case UNITTEST:
return 3;
default:
return 997;
}
return CONFIG_SETTINGS.get().datastore.eppResourceIndexBucketsNum;
}
/**
@ -1266,6 +1255,19 @@ public final class RegistryConfig {
}
}
/**
* Memoizes loading of the {@link RegistryConfigSettings} POJO.
*
* <p>Memoizing without cache expiration is used because the app must be re-deployed in order to
* change the contents of the YAML config files.
*/
private static final Supplier<RegistryConfigSettings> CONFIG_SETTINGS =
memoize(new Supplier<RegistryConfigSettings>() {
@Override
public RegistryConfigSettings get() {
return getConfigSettings();
}});
/** Config values used for local and unit test environments. */
public static class LocalTestConfig {

View file

@ -0,0 +1,49 @@
// Copyright 2016 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.config;
/** The POJO that YAML config files are deserialized into. */
public class RegistryConfigSettings {
public General general;
public Datastore datastore;
public Monitoring monitoring;
/** General configuration options that apply to the entire App Engine project. */
public static class General {
public String appEngineProjectId;
}
/** Configuration for Cloud Datastore. */
public static class Datastore {
public int commitLogBucketsNum;
public int eppResourceIndexBucketsNum;
}
/** Configuration for monitoring. */
public static class Monitoring {
public int stackdriverMaxQps;
public int stackdriverMaxPointsPerRequest;
public int writeIntervalSeconds;
}
}

View file

@ -0,0 +1,122 @@
// Copyright 2016 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.config;
import static google.registry.config.RegistryEnvironment.UNITTEST;
import static google.registry.util.FormattingLogger.getLoggerForCallerClass;
import static google.registry.util.ResourceUtils.readResourceUtf8;
import com.google.common.io.CharStreams;
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 org.yaml.snakeyaml.Yaml;
/** Utility methods for dealing with YAML. */
public final class YamlUtils {
private static final FormattingLogger logger = getLoggerForCallerClass();
private static final String CUSTOM_CONFIG_PATH = "WEB-INF/nomulus-config.yaml";
private static final String YAML_CONFIG_PROD =
readResourceUtf8(RegistryConfig.class, "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).
*
* <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
* file located in {@code WEB-INF/nomulus-config.yaml} is also loaded and those values merged into
* the POJO. If the custom config file does not exist then an info notice is logged, but if it
* does exist and is invalid then a fatal error is thrown.
*
* <p>Unit tests load the {@code unittest-config.yaml} file for custom config.
*/
static RegistryConfigSettings getConfigSettings() {
String yaml = YAML_CONFIG_PROD;
if (RegistryEnvironment.get() == UNITTEST) {
yaml = mergeYaml(yaml, YAML_CONFIG_UNITTEST);
} else {
try {
// We have to load the file this way because App Engine does not allow loading files in the
// WEB-INF directory using a class loader.
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) {
throw new IllegalStateException("Fatal error: Custom YAML configuration file is invalid", e);
}
}
/**
* Recursively merges two YAML documents together.
*
* <p>Any fields that are specified in customYaml will override fields of the same path in
* defaultYaml. Additional fields in customYaml that aren't specified in defaultYaml will be
* ignored. The schemas of all fields that are present must be identical, e.g. it is an error to
* override a field that has a Map value in the default YAML with a field of any other type in the
* custom YAML.
*
* <p>Only maps are handled recursively; lists are simply overridden in place as-is.
*/
static String mergeYaml(String defaultYaml, String customYaml) {
try {
Yaml yaml = new Yaml();
Map<String, Object> defaultObj = loadAsMap(yaml, defaultYaml);
Map<String, Object> customObj = loadAsMap(yaml, customYaml);
Object mergedObj = mergeMaps(defaultObj, customObj);
logger.infofmt("Successfully loaded custom YAML configuration file.");
return yaml.dump(mergedObj);
} catch (Exception e) {
throw new IllegalStateException("Fatal error: Custom YAML configuration file is invalid", e);
}
}
private static Object mergeMaps(Map<String, Object> defaultMap, Map<String, Object> customMap) {
for (String key : defaultMap.keySet()) {
if (!customMap.containsKey(key)) {
continue;
}
Object defaultValue = defaultMap.get(key);
@SuppressWarnings("unchecked")
Object newValue =
(defaultValue instanceof Map)
? mergeMaps(
(Map<String, Object>) defaultValue, (Map<String, Object>) customMap.get(key))
: customMap.get(key);
defaultMap.put(key, newValue);
}
return defaultMap;
}
@SuppressWarnings("unchecked")
private static Map<String, Object> loadAsMap(Yaml yaml, String yamlString) {
return (Map<String, Object>) yaml.load(yamlString);
}
private YamlUtils() {}
}

View file

@ -0,0 +1,29 @@
# This is the default configuration file for Nomulus. Do not make changes to it
# unless you are writing new features that requires you to. To customize an
# individual deployment or environment, create a nomulus-config.yaml file in the
# WEB-INF/ directory overriding only the values you wish to change.
general:
# Globally unique App Engine project ID
appEngineProjectId: domain-registry
datastore:
# The 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
# initial install.
eppResourceIndexBucketsNum: 997
monitoring:
# Max queries per second for the Google Cloud Monitoring V3 (aka Stackdriver)
# API. The limit can be adjusted by contacting Cloud Support.
stackdriverMaxQps: 30
# Max number of points that can be sent to Stackdriver in a single
# TimeSeries.Create API call.
stackdriverMaxPointsPerRequest: 200
# How often metrics are exported to BigQuery.
writeIntervalSeconds: 60

View file

@ -0,0 +1,6 @@
# This is the configuration file used by unit tests. These values ARE NOT
# SUITABLE for use in a real deployed environment.
datastore:
commitLogBucketsNum: 3
eppResourceIndexBucketsNum: 3

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -0,0 +1,3 @@
general:
appEngineProjectId: domain-registry-alpha

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -12,6 +12,10 @@
<idle-timeout>5m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -0,0 +1,3 @@
general:
appEngineProjectId: domain-registry-crash

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -0,0 +1,3 @@
general:
appEngineProjectId: domain-registry

View file

@ -12,6 +12,9 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -0,0 +1,3 @@
general:
appEngineProjectId: domain-registry

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -0,0 +1,3 @@
general:
appEngineProjectId: domain-registry-sandbox

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -12,6 +12,10 @@
<idle-timeout>10m</idle-timeout>
</basic-scaling>
<resource-files>
<include path="/WEB-INF/*.yaml"/>
</resource-files>
<system-properties>
<property name="java.util.logging.config.file"
value="WEB-INF/logging.properties"/>

View file

@ -105,7 +105,8 @@ def domain_registry_repositories(
omit_org_mortbay_jetty=False,
omit_org_mortbay_jetty_servlet_api=False,
omit_org_mortbay_jetty_util=False,
omit_org_slf4j_api=False):
omit_org_slf4j_api=False,
omit_org_yaml_snakeyaml=False):
"""Imports dependencies for Nomulus."""
domain_registry_bazel_check()
if not omit_com_beust_jcommander:
@ -276,6 +277,8 @@ def domain_registry_repositories(
org_mortbay_jetty_util()
if not omit_org_slf4j_api:
org_slf4j_api()
if not omit_org_yaml_snakeyaml:
org_yaml_snakeyaml()
def com_beust_jcommander():
java_import_external(
@ -1620,6 +1623,17 @@ def org_slf4j_api():
licenses = ["notice"], # MIT License
)
def org_yaml_snakeyaml():
java_import_external(
name = "org_yaml_snakeyaml",
licenses = ["notice"], # Apache License, Version 2.0
jar_sha256 = "5666b36f9db46f06dd5a19d73bbff3b588d5969c0f4b8848fde0f5ec849430a5",
jar_urls = [
"http://maven.ibiblio.org/maven2/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar",
"http://repo1.maven.org/maven2/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar",
],
)
def _check_bazel_version(project, bazel_version):
if "bazel_version" not in dir(native):
fail("%s requires Bazel >=%s but was <0.2.1" % (project, bazel_version))

View file

@ -0,0 +1,54 @@
// Copyright 2016 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.config;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.config.YamlUtils.mergeYaml;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link YamlUtils}. */
@RunWith(JUnit4.class)
public class YamlUtilsTest {
@Test
public void testSuccess_mergeSimpleMaps() {
String defaultYaml = join("one: ay", "two: bee", "three: sea");
String customYaml = join("two: dee", "four: ignored");
assertThat(mergeYaml(defaultYaml, customYaml)).isEqualTo("{one: ay, two: dee, three: sea}\n");
}
@Test
public void testSuccess_mergeNestedMaps() {
String defaultYaml = join("non: ay", "nested:", " blah: tim", " neat: 12");
String customYaml = join("nested:", " blah: max", " extra: none");
assertThat(mergeYaml(defaultYaml, customYaml))
.isEqualTo(join("non: ay", "nested: {blah: max, neat: 12}"));
}
@Test
public void testSuccess_listsAreOverridden() {
String defaultYaml = join("non: ay", "list:", " - foo", " - bar", " - baz");
String customYaml = join("list:", " - crackle", " - pop var");
assertThat(mergeYaml(defaultYaml, customYaml))
.isEqualTo(join("non: ay", "list: [crackle, pop var]"));
}
private static String join(CharSequence... strings) {
return String.join("\n", strings) + "\n";
}
}