diff --git a/base/src/main/java/com/thoughtworks/go/util/GoConstants.java b/base/src/main/java/com/thoughtworks/go/util/GoConstants.java index a56c6a82fd9d..a163238c5af8 100644 --- a/base/src/main/java/com/thoughtworks/go/util/GoConstants.java +++ b/base/src/main/java/com/thoughtworks/go/util/GoConstants.java @@ -54,7 +54,7 @@ public class GoConstants { public static final String PRODUCT_NAME = "go"; - public static final int CONFIG_SCHEMA_VERSION = 119; + public static final int CONFIG_SCHEMA_VERSION = 120; public static final String APPROVAL_SUCCESS = "success"; public static final String APPROVAL_MANUAL = "manual"; diff --git a/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfile.java b/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfile.java index 801186d55e75..3af026679f55 100644 --- a/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfile.java +++ b/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfile.java @@ -26,7 +26,7 @@ import static java.lang.String.format; -@ConfigTag("profile") +@ConfigTag("agentProfile") @ConfigCollection(value = ConfigurationProperty.class) public class ElasticProfile extends PluginProfile { diff --git a/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfiles.java b/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfiles.java index edfb251ca2e3..37cb87857236 100644 --- a/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfiles.java +++ b/config/config-api/src/main/java/com/thoughtworks/go/config/elastic/ElasticProfiles.java @@ -21,7 +21,7 @@ import java.util.Arrays; -@ConfigTag("profiles") +@ConfigTag("agentProfiles") @ConfigCollection(ElasticProfile.class) public class ElasticProfiles extends PluginProfiles implements Validatable { private final ConfigErrors errors = new ConfigErrors(); diff --git a/config/config-server/src/main/resources/cruise-config.xsd b/config/config-server/src/main/resources/cruise-config.xsd index 3317b6a862fc..557a1e282415 100644 --- a/config/config-server/src/main/resources/cruise-config.xsd +++ b/config/config-server/src/main/resources/cruise-config.xsd @@ -89,7 +89,7 @@ - + @@ -318,9 +318,9 @@ - + - + @@ -330,7 +330,7 @@ - + diff --git a/config/config-server/src/main/resources/schemas/119_cruise-config.xsd b/config/config-server/src/main/resources/schemas/119_cruise-config.xsd new file mode 100644 index 000000000000..3317b6a862fc --- /dev/null +++ b/config/config-server/src/main/resources/schemas/119_cruise-config.xsd @@ -0,0 +1,1127 @@ + + + + + + + Configuration schema for Go. Copyright (c) 2017 ThoughtWorks, Inc. + www.thoughtworks.com. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/config/config-server/src/main/resources/upgrades/120.xsl b/config/config-server/src/main/resources/upgrades/120.xsl new file mode 100644 index 000000000000..19a5b812c5cf --- /dev/null +++ b/config/config-server/src/main/resources/upgrades/120.xsl @@ -0,0 +1,36 @@ + + + + + + 120 + + + + + + + + + + + + + + + + diff --git a/server/config/cruise-config.xml b/server/config/cruise-config.xml index 851ca77b1ff1..9d4e1db36ecc 100755 --- a/server/config/cruise-config.xml +++ b/server/config/cruise-config.xml @@ -1,5 +1,5 @@ - + diff --git a/server/src/test-integration/java/com/thoughtworks/go/config/GoConfigMigrationIntegrationTest.java b/server/src/test-integration/java/com/thoughtworks/go/config/GoConfigMigrationIntegrationTest.java index 9cf1cb273bdd..1794f4265fb4 100644 --- a/server/src/test-integration/java/com/thoughtworks/go/config/GoConfigMigrationIntegrationTest.java +++ b/server/src/test-integration/java/com/thoughtworks/go/config/GoConfigMigrationIntegrationTest.java @@ -1266,6 +1266,77 @@ public void shouldOnlyUpdateSchemaVersionForMigration116() throws NoSuchMethodEx assertThat(migratedContent).contains(configContent); } + @Test + public void shouldRenameProfilesToAgentProfilesAsPartOfMigration120() throws Exception { + String configContent = "\n" + + " \n" + + " \n" + + " \n" + + " Image\n" + + " docker.gocd.io/gocddev/gocd-dev-build:centos-7-v2.0.67\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " Image\n" + + " docker.gocd.io/gocddev/gocd-dev-build:centos-7-v2.0.67\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " GoServerUrl\n" + + " https://build.gocd.io:8154/go\n" + + " \n" + + " \n" + + " \n" + + " "; + + String configXml = "" + + "\n" + + configContent + + ""; + + String expected = "" + + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " Image\n" + + " docker.gocd.io/gocddev/gocd-dev-build:centos-7-v2.0.67\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " Image\n" + + " docker.gocd.io/gocddev/gocd-dev-build:centos-7-v2.0.67\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " GoServerUrl\n" + + " https://build.gocd.io:8154/go\n" + + " \n" + + " \n" + + " \n" + + " " + + ""; + + String migratedContent = migrateXmlString(configXml, 119, 120); + org.xmlunit.assertj.XmlAssert.assertThat(migratedContent).isEqualTo(expected); + + CruiseConfig cruiseConfig = loader.deserializeConfig(migratedContent); + assertThat(cruiseConfig.getElasticConfig().getProfiles()).hasSize(2); + assertThat(cruiseConfig.getElasticConfig().getProfiles().find("ecs-gocd-dev-build-dind")).isNotNull(); + assertThat(cruiseConfig.getElasticConfig().getProfiles().find("ecs-gocd-dev-build-dind-docker-compose")).isNotNull(); + } + private void assertStringsIgnoringCarriageReturnAreEqual(String expected, String actual) { assertThat(actual.replaceAll("\\r", "")).isEqualTo(expected.replaceAll("\\r", "")); } @@ -1287,7 +1358,7 @@ public void shouldMigrateAnArtifactSourceWithJustWhitespaceToStar() throws Excep JobConfig plan = cruiseConfig.jobConfigByName("pipeline", "stage", "job", true); assertThat(plan.artifactConfigs().getBuiltInArtifactConfigs().get(0).getSource()).isEqualTo("*"); } - + private void assertStringContainsIgnoringCarriageReturn(String actual, String substring) { assertThat(actual.replaceAll("\\r", "")).contains(substring.replaceAll("\\r", "")); }