From e05e876f8f3c1838903c768f19fc6ca060069005 Mon Sep 17 00:00:00 2001 From: Andy Chan Date: Thu, 5 Feb 2015 15:08:32 -0800 Subject: [PATCH] Optional support for multiple Git repos This implementation adds multiple git repositories support to Spring Cloud Config Server. By giving the following properties file: info: component: Config Server spring: application: name: configserver jmx: default_domain: cloud.config.server cloud: config: server: git: uri: https://github.com/spring-cloud-samples/config-repo repos: - patterns: iceycake-* uri: https://github.com/iceycake/config-repo - patterns: project1-*,*-project1 uri: https://github.com/spring-cloud-samples/config-repo-1 with uri: /{application}/{profile}/{label} where spring.cloud.config.server.git.uri is the default git repository spring.cloud.config.server.repos is a mapping between a git repository and a string pattern that matches the {application} string in the endpoint. Fixes gh-82, fixes gh-58 --- docs/src/main/asciidoc/quickstart.adoc | 23 +++ .../main/asciidoc/spring-cloud-config.adoc | 24 +++ .../server/ConfigServerConfiguration.java | 10 +- .../server/ConfigServerMvcConfiguration.java | 1 + .../config/server/EnvironmentController.java | 2 + .../server/EnvironmentRepositories.java | 26 +++ .../server/JGitEnvironmentRepository.java | 3 +- .../MultipleJGitEnvironmentRepository.java | 147 +++++++++++++++ .../src/main/resources/configserver.yml | 5 + ...EnvironmentRepositoryIntegrationTests.java | 104 +++++++++++ ...ultipleJGitEnvironmentRepositoryTests.java | 134 ++++++++++++++ .../test1-config-repo/application.yml | 3 + .../test1-config-repo/git/COMMIT_EDITMSG | 1 + .../test/resources/test1-config-repo/git/HEAD | 1 + .../resources/test1-config-repo/git/config | 4 + .../test1-config-repo/git/description | 1 + .../git/hooks/applypatch-msg.sample | 15 ++ .../git/hooks/commit-msg.sample | 24 +++ .../git/hooks/post-update.sample | 8 + .../git/hooks/pre-applypatch.sample | 14 ++ .../git/hooks/pre-commit.sample | 49 +++++ .../git/hooks/pre-push.sample | 54 ++++++ .../git/hooks/pre-rebase.sample | 169 ++++++++++++++++++ .../git/hooks/prepare-commit-msg.sample | 36 ++++ .../test1-config-repo/git/hooks/update.sample | 128 +++++++++++++ .../resources/test1-config-repo/git/index | Bin 0 -> 233 bytes .../test1-config-repo/git/info/exclude | 6 + .../resources/test1-config-repo/git/logs/HEAD | 2 + .../git/logs/refs/heads/master | 2 + .../1a/138ced808f5fb3206283b292253d8ba7a99b31 | Bin 0 -> 103 bytes .../20/d30201572381d9dcaf164e1c7670557ece7257 | Bin 0 -> 38 bytes .../4e/1f25bbdca5765e279b436b5b02d05b1654515c | Bin 0 -> 158 bytes .../53/14629d4229558db9cc91fec7631833e03434b3 | Bin 0 -> 65 bytes .../96/403e4eca8ed1dc5672d4bd1f125c490a2a48f7 | Bin 0 -> 43 bytes .../c9/60eaa883ffafea56e5940baf1fc7d1b5d35b56 | 2 + .../test1-config-repo/git/refs/heads/master | 1 + .../test1-config-repo/test1-svc.properties | 2 + 37 files changed, 995 insertions(+), 6 deletions(-) create mode 100644 spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/EnvironmentRepositories.java create mode 100644 spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepository.java create mode 100644 spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepositoryIntegrationTests.java create mode 100644 spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepositoryTests.java create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/application.yml create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/COMMIT_EDITMSG create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/HEAD create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/config create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/description create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/applypatch-msg.sample create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/commit-msg.sample create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/post-update.sample create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-applypatch.sample create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-commit.sample create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-push.sample create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-rebase.sample create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/prepare-commit-msg.sample create mode 100755 spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/update.sample create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/index create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/info/exclude create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/logs/HEAD create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/logs/refs/heads/master create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/1a/138ced808f5fb3206283b292253d8ba7a99b31 create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/20/d30201572381d9dcaf164e1c7670557ece7257 create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/4e/1f25bbdca5765e279b436b5b02d05b1654515c create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/53/14629d4229558db9cc91fec7631833e03434b3 create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/96/403e4eca8ed1dc5672d4bd1f125c490a2a48f7 create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/c9/60eaa883ffafea56e5940baf1fc7d1b5d35b56 create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/git/refs/heads/master create mode 100644 spring-cloud-config-server/src/test/resources/test1-config-repo/test1-svc.properties diff --git a/docs/src/main/asciidoc/quickstart.adoc b/docs/src/main/asciidoc/quickstart.adoc index 8d5cbec0..90cb4f5a 100644 --- a/docs/src/main/asciidoc/quickstart.adoc +++ b/docs/src/main/asciidoc/quickstart.adoc @@ -43,6 +43,29 @@ The YAML and properties forms are coalesced into a single map, even if the origin of the values (reflected in the "propertySources" of the "standard" form) has multiple sources. +Spring Cloud Config Server also supports multiple git repositories: + +---- +spring: + cloud: + config: + server: + git: + uri: https://github.com/spring-cloud-samples/config-repo + repos: + - patterns: *pattern + uri: https://github.com/pattern1/config-repo + - patterns: pattern*,*pattern1* + uri: https://github.com/pattern2/config-repo + - patterns: local* + uri: file:/home/configsvc/config-repo +---- + +In the above example, if {application} does not match to any of the patterns +under "spring.cloud.config.server.git.repos", it will use the default uri +defined under "spring.cloud.config.server.git.uri". Acceptable pattern +format is "*xxx", "xxx*", or "*xxx*". + === Client Side Usage To use these features in an application, just build it as a Spring diff --git a/docs/src/main/asciidoc/spring-cloud-config.adoc b/docs/src/main/asciidoc/spring-cloud-config.adoc index c8d9ff3b..badb822a 100644 --- a/docs/src/main/asciidoc/spring-cloud-config.adoc +++ b/docs/src/main/asciidoc/spring-cloud-config.adoc @@ -85,6 +85,30 @@ working copy as a cache. This repository implementation maps the `{label}` parameter of the HTTP resource to a git label (commit id, branch name or tag). +Spring Cloud Config Server also supports multiple git repositories: + +---- +spring: + cloud: + config: + server: + git: + uri: https://github.com/spring-cloud-samples/config-repo + repos: + - patterns: *pattern + uri: https://github.com/pattern1/config-repo + - patterns: pattern*,*pattern1* + uri: https://github.com/pattern2/config-repo + - patterns: local* + uri: file:/home/configsvc/config-repo +---- + +In the above example, if {application} does not match to any of the patterns +under "spring.cloud.config.server.git.repos", it will use the default uri +defined under "spring.cloud.config.server.git.uri". Acceptable pattern +format is "*xxx", "xxx*", or "*xxx*". + + ==== File System Backend There is also a "native" profile in the Config Server that doesn't use diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ConfigServerConfiguration.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ConfigServerConfiguration.java index 35ecaae3..6ad04134 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ConfigServerConfiguration.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ConfigServerConfiguration.java @@ -44,13 +44,13 @@ public class ConfigServerConfiguration { @Configuration @Profile("!native") protected static class GitRepositoryConfiguration { + @Autowired - private ConfigurableEnvironment environment; - + private ConfigurableEnvironment environment; + @Bean - public JGitEnvironmentRepository EnvironmentRepository() { - return new JGitEnvironmentRepository(environment); + public MultipleJGitEnvironmentRepository EnvironmentRepository() { + return new MultipleJGitEnvironmentRepository(environment); } } - } \ No newline at end of file diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ConfigServerMvcConfiguration.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ConfigServerMvcConfiguration.java index 8f5db3d5..e479aad6 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ConfigServerMvcConfiguration.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/ConfigServerMvcConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.cloud.config.server; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/EnvironmentController.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/EnvironmentController.java index 223ca391..062bb3f3 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/EnvironmentController.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/EnvironmentController.java @@ -12,6 +12,7 @@ import java.util.Properties; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.bind.PropertiesConfigurationFactory; import org.springframework.cloud.config.Environment; import org.springframework.cloud.config.PropertySource; @@ -30,6 +31,7 @@ import org.yaml.snakeyaml.Yaml; @RequestMapping("${spring.cloud.config.server.prefix:}") public class EnvironmentController { + @Qualifier("MultipleJGitEnvironmentRepository") private EnvironmentRepository repository; private EncryptionController encryption; diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/EnvironmentRepositories.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/EnvironmentRepositories.java new file mode 100644 index 00000000..b73fe4a6 --- /dev/null +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/EnvironmentRepositories.java @@ -0,0 +1,26 @@ +package org.springframework.cloud.config.server; + +import javax.annotation.PostConstruct; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * + * @author iceycake + * + */ +@ConfigurationProperties(prefix = "spring.cloud.config.server.git.repos") +public class EnvironmentRepositories { + + private String uri; + private String name; + + @PostConstruct + public void init() throws Exception { + + } + + public EnvironmentRepositories() { + super(); + } +} diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/JGitEnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/JGitEnvironmentRepository.java index cc2a8f9d..170964fd 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/JGitEnvironmentRepository.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/JGitEnvironmentRepository.java @@ -75,7 +75,7 @@ public class JGitEnvironmentRepository implements EnvironmentRepository, Initial private boolean initialized; private String[] searchPaths = new String[0]; - + @Override public void afterPropertiesSet() throws Exception { Assert.state(uri != null, "You need to configure a uri for the git repository"); @@ -103,6 +103,7 @@ public class JGitEnvironmentRepository implements EnvironmentRepository, Initial } } + public void setUri(String uri) { while (uri.endsWith("/")) { uri = uri.substring(0, uri.length() - 1); diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepository.java new file mode 100644 index 00000000..2a0bfed2 --- /dev/null +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepository.java @@ -0,0 +1,147 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * 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 org.springframework.cloud.config.server; + +import java.io.File; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.InitializingBean; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cloud.config.Environment; +import org.springframework.core.env.ConfigurableEnvironment; +import org.springframework.util.Assert; +import org.springframework.util.PatternMatchUtils; + +/** + * @author Andy Chan (iceycake) + * + */ +@ConfigurationProperties("spring.cloud.config.server.git") +public class MultipleJGitEnvironmentRepository implements EnvironmentRepository, + InitializingBean { + + private static final String REPO_PATTERNS = "patterns"; + private static final String REPO_URI = "uri"; + private static final String REPO_USERNAME = "username"; + private static final String REPO_PASSWORD = "password"; + private static final String REPO_SEARCHPATHS = "searchPaths"; + + private String uri; + private String username; + private String password; + private String[] searchPaths = new String[0]; + + private List> repos = new ArrayList>(); + private Map repoCache = new LinkedHashMap(); + private JGitEnvironmentRepository defaultRepo; + + private ConfigurableEnvironment environment; + + @Override + public void afterPropertiesSet() throws Exception { + Assert.state(uri != null, + "You need to configure a uri for the default git repository"); + } + + public MultipleJGitEnvironmentRepository(ConfigurableEnvironment environment) { + this.environment = environment; + } + + public void setSearchPaths(String... searchPaths) { + this.searchPaths = searchPaths; + } + + public void setUri(String uri) { + while (uri.endsWith("/")) { + uri = uri.substring(0, uri.length() - 1); + } + this.uri = uri; + } + + public String getUri() { + return uri; + } + + public void setRepos(List> repos) { + this.repos.addAll(repos); + } + + public List> getRepos() { + return this.repos; + } + + @Override + public Environment findOne(String application, String profile, String label) { + if (this.defaultRepo == null) { + defaultRepo = createJGitEnvironmentRepository(this.uri, this.username, + this.password, this.searchPaths); + } + + JGitEnvironmentRepository repo = this.defaultRepo; + + for (Map repoKeyValue : repos) { + String repoPatternsList = (String)repoKeyValue.get(REPO_PATTERNS); + if (repoPatternsList == null || repoPatternsList.isEmpty()) { + continue; + } + String[] repoPatterns = repoPatternsList.split(","); + String repoUri = (String)repoKeyValue.get(REPO_URI); + + Assert.state(repoUri != null, + "You need to configure a uri for the '" + repoPatternsList + "' git repository"); + + String repoUsername = (String)repoKeyValue.get(REPO_USERNAME); + String repoPassword = (String)repoKeyValue.get(REPO_PASSWORD); + String[] repoSearchPaths = new String[0]; + LinkedHashMap searchPathsList = (LinkedHashMap)repoKeyValue.get(REPO_SEARCHPATHS); + if (searchPathsList != null) { + repoSearchPaths = searchPathsList.values().toArray(new String[searchPathsList.values().size()]); + } + + if (PatternMatchUtils.simpleMatch(repoPatterns, application)) { + repo = repoCache.get(repoPatternsList); + + if (repo == null) { + repo = createJGitEnvironmentRepository(repoUri, repoUsername, + repoPassword, repoSearchPaths); + + synchronized (repoCache) { + repoCache.put(repoPatternsList, repo); + } + } + + break; + } + } + + return repo.findOne(application, profile, label); + } + + private JGitEnvironmentRepository createJGitEnvironmentRepository(String uri, + String username, String password, String[] searchPaths) { + JGitEnvironmentRepository repo = new JGitEnvironmentRepository(this.environment); + repo.setUri(uri); + repo.setUsername(username); + repo.setPassword(password); + repo.setSearchPaths(searchPaths); + + return repo; + } +} diff --git a/spring-cloud-config-server/src/main/resources/configserver.yml b/spring-cloud-config-server/src/main/resources/configserver.yml index 87fee6d7..176cc464 100644 --- a/spring-cloud-config-server/src/main/resources/configserver.yml +++ b/spring-cloud-config-server/src/main/resources/configserver.yml @@ -10,7 +10,12 @@ spring: server: git: uri: https://github.com/spring-cloud-samples/config-repo + repos: + - patterns: multi-repo-demo-* + uri: https://github.com/spring-cloud-samples/config-repo + server: port: 8888 management: context_path: /admin + \ No newline at end of file diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepositoryIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepositoryIntegrationTests.java new file mode 100644 index 00000000..474924ea --- /dev/null +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepositoryIntegrationTests.java @@ -0,0 +1,104 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * 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 org.springframework.cloud.config.server; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.jgit.util.FileUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.cloud.config.Environment; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; + +/** + * @author Andy Chan (iceycake) + * + */ +public class MultipleJGitEnvironmentRepositoryIntegrationTests { + + private ConfigurableApplicationContext context; + + private File basedir = new File("target/config"); + + @Before + public void init() throws Exception { + if (basedir.exists()) { + FileUtils.delete(basedir, FileUtils.RECURSIVE); + } + ConfigServerTestUtils.deleteLocalRepo("config-copy"); + } + + @After + public void close() { + if (context != null) { + context.close(); + } + } + + @Test + public void defaultRepo() throws IOException { + String defaultRepoUri = ConfigServerTestUtils.prepareLocalRepo("config-repo"); + context = new SpringApplicationBuilder(TestConfiguration.class).web(false) + .properties("spring.cloud.config.server.git.uri:" + defaultRepoUri).run(); + EnvironmentRepository repository = context.getBean(EnvironmentRepository.class); + repository.findOne("bar", "staging", "master"); + Environment environment = repository.findOne("bar", "staging", "master"); + assertEquals(2, environment.getPropertySources().size()); + } + + @Test + public void mappingRepo() throws IOException { + String defaultRepoUri = ConfigServerTestUtils.prepareLocalRepo("config-repo"); + String test1RepoUri = ConfigServerTestUtils.prepareLocalRepo("test1-config-repo"); + + Map repoMapping = new LinkedHashMap(); + repoMapping.put("patterns", "*test1*"); + repoMapping.put("uri", test1RepoUri); + + List> repoMappings = new ArrayList>(); + repoMappings.add(repoMapping); + + Map reposProperties = new LinkedHashMap(); + reposProperties.put("spring.cloud.config.server.git.repos", repoMappings); + + context = new SpringApplicationBuilder(TestConfiguration.class).web(false) + .properties("spring.cloud.config.server.git.uri:" + defaultRepoUri) + .properties(reposProperties).run(); + EnvironmentRepository repository = context.getBean(EnvironmentRepository.class); + repository.findOne("test1-svc", "staging", "master"); + Environment environment = repository.findOne("test1-svc", "staging", "master"); + assertEquals(2, environment.getPropertySources().size()); + } + + @Configuration + @Import({ PropertyPlaceholderAutoConfiguration.class, ConfigServerConfiguration.class }) + protected static class TestConfiguration { + } + +} diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepositoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepositoryTests.java new file mode 100644 index 00000000..9179425b --- /dev/null +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/MultipleJGitEnvironmentRepositoryTests.java @@ -0,0 +1,134 @@ +/* + * Copyright 2013-2015 the original author or authors. + * + * 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 org.springframework.cloud.config.server; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; +import org.springframework.cloud.config.Environment; +import org.springframework.core.env.StandardEnvironment; + +/** + * + * @author Andy Chan (iceycake) + * + */ +public class MultipleJGitEnvironmentRepositoryTests { + + private StandardEnvironment environment = new StandardEnvironment(); + private MultipleJGitEnvironmentRepository repository = new MultipleJGitEnvironmentRepository(environment); + + @Before + public void init() throws Exception { + String defaultUri = ConfigServerTestUtils.prepareLocalRepo("config-repo"); + + repository.setUri(defaultUri); + repository.setRepos(createRepositoryMappings()); + } + + private List> createRepositoryMappings() throws Exception { + String test1Uri = ConfigServerTestUtils.prepareLocalRepo("test1-config-repo"); + + List> mappings = new ArrayList>(); + mappings.add(createRepositoryMapping("*test1*", test1Uri)); + + return mappings; + } + + private Map createRepositoryMapping(String pattern, String uri) { + Map repoMapping = new LinkedHashMap(); + repoMapping.put("patterns", pattern); + repoMapping.put("uri", uri); + + return repoMapping; + } + + @Test + public void defaultRepo() { + Environment environment = repository.findOne("bar", "staging", "master"); + assertEquals(2, environment.getPropertySources().size()); + assertEquals(repository.getUri() + "/bar.properties", environment + .getPropertySources().get(0).getName()); + } + + @Test + public void defaultRepoNested() throws IOException { + String uri = ConfigServerTestUtils.prepareLocalRepo("another-config-repo"); + repository.setUri(uri); + repository.setSearchPaths(new String[] {"sub"}); + repository.findOne("bar", "staging", "master"); + Environment environment = repository.findOne("bar", "staging", "master"); + assertEquals(2, environment.getPropertySources().size()); + assertEquals(repository.getUri() + "/sub/application.yml", environment + .getPropertySources().get(0).getName()); + } + + @Test + public void defaultRepoBranch() { + Environment environment = repository.findOne("bar", "staging", "raw"); + assertEquals(2, environment.getPropertySources().size()); + assertEquals(repository.getUri() + "/bar.properties", environment + .getPropertySources().get(0).getName()); + } + + @Test + public void defaultRepoTag() { + Environment environment = repository.findOne("bar", "staging", "foo"); + assertEquals(2, environment.getPropertySources().size()); + assertEquals(repository.getUri() + "/bar.properties", environment + .getPropertySources().get(0).getName()); + } + + @Test + public void defaultRepoBasedir() { + repository.findOne("bar", "staging", "master"); + Environment environment = repository.findOne("bar", "staging", "master"); + assertEquals(2, environment.getPropertySources().size()); + assertEquals(repository.getUri() + "/bar.properties", environment + .getPropertySources().get(0).getName()); + } + + @Test + public void mappingRepo() { + Environment environment = repository.findOne("test1-svc", "staging", "master"); + assertEquals(2, environment.getPropertySources().size()); + assertEquals(getUri("*test1*") + "test1-svc.properties", environment + .getPropertySources().get(0).getName()); + } + + private String getUri(String pattern) { + String uri = null; + + List> repoMappings = repository.getRepos(); + + for (Map mapping : repoMappings) { + String mappingPattern = (String)mapping.get("patterns"); + if (mappingPattern != null) { + uri = (String)mapping.get("uri"); + break; + } + } + + return uri; + } +} diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/application.yml b/spring-cloud-config-server/src/test/resources/test1-config-repo/application.yml new file mode 100644 index 00000000..20d30201 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/application.yml @@ -0,0 +1,3 @@ +my: + app: + name: appname diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/COMMIT_EDITMSG b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/COMMIT_EDITMSG new file mode 100644 index 00000000..1b5f2002 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/COMMIT_EDITMSG @@ -0,0 +1 @@ +test case diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/HEAD b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/HEAD new file mode 100644 index 00000000..cb089cd8 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/HEAD @@ -0,0 +1 @@ +ref: refs/heads/master diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/config b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/config new file mode 100644 index 00000000..2de79931 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/config @@ -0,0 +1,4 @@ +[core] + repositoryformatversion = 0 + filemode = true + logallrefupdates = true diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/description b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/description new file mode 100644 index 00000000..498b267a --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/description @@ -0,0 +1 @@ +Unnamed repository; edit this file 'description' to name the repository. diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/applypatch-msg.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/applypatch-msg.sample new file mode 100755 index 00000000..8b2a2fe8 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/applypatch-msg.sample @@ -0,0 +1,15 @@ +#!/bin/sh +# +# An example hook script to check the commit log message taken by +# applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. The hook is +# allowed to edit the commit message file. +# +# To enable this hook, rename this file to "applypatch-msg". + +. git-sh-setup +test -x "$GIT_DIR/hooks/commit-msg" && + exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"} +: diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/commit-msg.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/commit-msg.sample new file mode 100755 index 00000000..b58d1184 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/commit-msg.sample @@ -0,0 +1,24 @@ +#!/bin/sh +# +# An example hook script to check the commit log message. +# Called by "git commit" with one argument, the name of the file +# that has the commit message. The hook should exit with non-zero +# status after issuing an appropriate message if it wants to stop the +# commit. The hook is allowed to edit the commit message file. +# +# To enable this hook, rename this file to "commit-msg". + +# Uncomment the below to add a Signed-off-by line to the message. +# Doing this in a hook is a bad idea in general, but the prepare-commit-msg +# hook is more suited to it. +# +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" + +# This example catches duplicate Signed-off-by lines. + +test "" = "$(grep '^Signed-off-by: ' "$1" | + sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || { + echo >&2 Duplicate Signed-off-by lines. + exit 1 +} diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/post-update.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/post-update.sample new file mode 100755 index 00000000..ec17ec19 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/post-update.sample @@ -0,0 +1,8 @@ +#!/bin/sh +# +# An example hook script to prepare a packed repository for use over +# dumb transports. +# +# To enable this hook, rename this file to "post-update". + +exec git update-server-info diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-applypatch.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-applypatch.sample new file mode 100755 index 00000000..b1f187c2 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-applypatch.sample @@ -0,0 +1,14 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed +# by applypatch from an e-mail message. +# +# The hook should exit with non-zero status after issuing an +# appropriate message if it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-applypatch". + +. git-sh-setup +test -x "$GIT_DIR/hooks/pre-commit" && + exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"} +: diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-commit.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-commit.sample new file mode 100755 index 00000000..68d62d54 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-commit.sample @@ -0,0 +1,49 @@ +#!/bin/sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# If you want to allow non-ASCII filenames set this variable to true. +allownonascii=$(git config --bool hooks.allownonascii) + +# Redirect output to stderr. +exec 1>&2 + +# Cross platform projects tend to avoid non-ASCII filenames; prevent +# them from being added to the repository. We exploit the fact that the +# printable range starts at the space character and ends with tilde. +if [ "$allownonascii" != "true" ] && + # Note that the use of brackets around a tr range is ok here, (it's + # even required, for portability to Solaris 10's /usr/bin/tr), since + # the square bracket bytes happen to fall in the designated range. + test $(git diff --cached --name-only --diff-filter=A -z $against | + LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 +then + cat <<\EOF +Error: Attempt to add a non-ASCII file name. + +This can cause problems if you want to work with people on other platforms. + +To be portable it is advisable to rename the file. + +If you know what you are doing you can disable this check using: + + git config hooks.allownonascii true +EOF + exit 1 +fi + +# If there are whitespace errors, print the offending file names and fail. +exec git diff-index --check --cached $against -- diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-push.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-push.sample new file mode 100755 index 00000000..1f3bcebf --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-push.sample @@ -0,0 +1,54 @@ +#!/bin/sh + +# An example hook script to verify what is about to be pushed. Called by "git +# push" after it has checked the remote status, but before anything has been +# pushed. If this script exits with a non-zero status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# +# +# This sample shows how to prevent push of commits where the log message starts +# with "WIP" (work in progress). + +remote="$1" +url="$2" + +z40=0000000000000000000000000000000000000000 + +IFS=' ' +while read local_ref local_sha remote_ref remote_sha +do + if [ "$local_sha" = $z40 ] + then + # Handle delete + : + else + if [ "$remote_sha" = $z40 ] + then + # New branch, examine all commits + range="$local_sha" + else + # Update to existing branch, examine new commits + range="$remote_sha..$local_sha" + fi + + # Check for WIP commit + commit=`git rev-list -n 1 --grep '^WIP' "$range"` + if [ -n "$commit" ] + then + echo "Found WIP commit in $local_ref, not pushing" + exit 1 + fi + fi +done + +exit 0 diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-rebase.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-rebase.sample new file mode 100755 index 00000000..9773ed4c --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/pre-rebase.sample @@ -0,0 +1,169 @@ +#!/bin/sh +# +# Copyright (c) 2006, 2008 Junio C Hamano +# +# The "pre-rebase" hook is run just before "git rebase" starts doing +# its job, and can prevent the command from running by exiting with +# non-zero status. +# +# The hook is called with the following parameters: +# +# $1 -- the upstream the series was forked from. +# $2 -- the branch being rebased (or empty when rebasing the current branch). +# +# This sample shows how to prevent topic branches that are already +# merged to 'next' branch from getting rebased, because allowing it +# would result in rebasing already published history. + +publish=next +basebranch="$1" +if test "$#" = 2 +then + topic="refs/heads/$2" +else + topic=`git symbolic-ref HEAD` || + exit 0 ;# we do not interrupt rebasing detached HEAD +fi + +case "$topic" in +refs/heads/??/*) + ;; +*) + exit 0 ;# we do not interrupt others. + ;; +esac + +# Now we are dealing with a topic branch being rebased +# on top of master. Is it OK to rebase it? + +# Does the topic really exist? +git show-ref -q "$topic" || { + echo >&2 "No such branch $topic" + exit 1 +} + +# Is topic fully merged to master? +not_in_master=`git rev-list --pretty=oneline ^master "$topic"` +if test -z "$not_in_master" +then + echo >&2 "$topic is fully merged to master; better remove it." + exit 1 ;# we could allow it, but there is no point. +fi + +# Is topic ever merged to next? If so you should not be rebasing it. +only_next_1=`git rev-list ^master "^$topic" ${publish} | sort` +only_next_2=`git rev-list ^master ${publish} | sort` +if test "$only_next_1" = "$only_next_2" +then + not_in_topic=`git rev-list "^$topic" master` + if test -z "$not_in_topic" + then + echo >&2 "$topic is already up-to-date with master" + exit 1 ;# we could allow it, but there is no point. + else + exit 0 + fi +else + not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"` + /usr/bin/perl -e ' + my $topic = $ARGV[0]; + my $msg = "* $topic has commits already merged to public branch:\n"; + my (%not_in_next) = map { + /^([0-9a-f]+) /; + ($1 => 1); + } split(/\n/, $ARGV[1]); + for my $elem (map { + /^([0-9a-f]+) (.*)$/; + [$1 => $2]; + } split(/\n/, $ARGV[2])) { + if (!exists $not_in_next{$elem->[0]}) { + if ($msg) { + print STDERR $msg; + undef $msg; + } + print STDERR " $elem->[1]\n"; + } + } + ' "$topic" "$not_in_next" "$not_in_master" + exit 1 +fi + +exit 0 + +################################################################ + +This sample hook safeguards topic branches that have been +published from being rewound. + +The workflow assumed here is: + + * Once a topic branch forks from "master", "master" is never + merged into it again (either directly or indirectly). + + * Once a topic branch is fully cooked and merged into "master", + it is deleted. If you need to build on top of it to correct + earlier mistakes, a new topic branch is created by forking at + the tip of the "master". This is not strictly necessary, but + it makes it easier to keep your history simple. + + * Whenever you need to test or publish your changes to topic + branches, merge them into "next" branch. + +The script, being an example, hardcodes the publish branch name +to be "next", but it is trivial to make it configurable via +$GIT_DIR/config mechanism. + +With this workflow, you would want to know: + +(1) ... if a topic branch has ever been merged to "next". Young + topic branches can have stupid mistakes you would rather + clean up before publishing, and things that have not been + merged into other branches can be easily rebased without + affecting other people. But once it is published, you would + not want to rewind it. + +(2) ... if a topic branch has been fully merged to "master". + Then you can delete it. More importantly, you should not + build on top of it -- other people may already want to + change things related to the topic as patches against your + "master", so if you need further changes, it is better to + fork the topic (perhaps with the same name) afresh from the + tip of "master". + +Let's look at this example: + + o---o---o---o---o---o---o---o---o---o "next" + / / / / + / a---a---b A / / + / / / / + / / c---c---c---c B / + / / / \ / + / / / b---b C \ / + / / / / \ / + ---o---o---o---o---o---o---o---o---o---o---o "master" + + +A, B and C are topic branches. + + * A has one fix since it was merged up to "next". + + * B has finished. It has been fully merged up to "master" and "next", + and is ready to be deleted. + + * C has not merged to "next" at all. + +We would want to allow C to be rebased, refuse A, and encourage +B to be deleted. + +To compute (1): + + git rev-list ^master ^topic next + git rev-list ^master next + + if these match, topic has not merged in next at all. + +To compute (2): + + git rev-list master..topic + + if this is empty, it is fully merged to "master". diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/prepare-commit-msg.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/prepare-commit-msg.sample new file mode 100755 index 00000000..f093a02e --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/prepare-commit-msg.sample @@ -0,0 +1,36 @@ +#!/bin/sh +# +# An example hook script to prepare the commit log message. +# Called by "git commit" with the name of the file that has the +# commit message, followed by the description of the commit +# message's source. The hook's purpose is to edit the commit +# message file. If the hook fails with a non-zero status, +# the commit is aborted. +# +# To enable this hook, rename this file to "prepare-commit-msg". + +# This hook includes three examples. The first comments out the +# "Conflicts:" part of a merge commit. +# +# The second includes the output of "git diff --name-status -r" +# into the message, just before the "git status" output. It is +# commented because it doesn't cope with --amend or with squashed +# commits. +# +# The third example adds a Signed-off-by line to the message, that can +# still be edited. This is rarely a good idea. + +case "$2,$3" in + merge,) + /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; + +# ,|template,) +# /usr/bin/perl -i.bak -pe ' +# print "\n" . `git diff --cached --name-status -r` +# if /^#/ && $first++ == 0' "$1" ;; + + *) ;; +esac + +# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') +# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/update.sample b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/update.sample new file mode 100755 index 00000000..d8475837 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/hooks/update.sample @@ -0,0 +1,128 @@ +#!/bin/sh +# +# An example hook script to blocks unannotated tags from entering. +# Called by "git receive-pack" with arguments: refname sha1-old sha1-new +# +# To enable this hook, rename this file to "update". +# +# Config +# ------ +# hooks.allowunannotated +# This boolean sets whether unannotated tags will be allowed into the +# repository. By default they won't be. +# hooks.allowdeletetag +# This boolean sets whether deleting tags will be allowed in the +# repository. By default they won't be. +# hooks.allowmodifytag +# This boolean sets whether a tag may be modified after creation. By default +# it won't be. +# hooks.allowdeletebranch +# This boolean sets whether deleting branches will be allowed in the +# repository. By default they won't be. +# hooks.denycreatebranch +# This boolean sets whether remotely creating branches will be denied +# in the repository. By default this is allowed. +# + +# --- Command line +refname="$1" +oldrev="$2" +newrev="$3" + +# --- Safety check +if [ -z "$GIT_DIR" ]; then + echo "Don't run this script from the command line." >&2 + echo " (if you want, you could supply GIT_DIR then run" >&2 + echo " $0 )" >&2 + exit 1 +fi + +if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then + echo "usage: $0 " >&2 + exit 1 +fi + +# --- Config +allowunannotated=$(git config --bool hooks.allowunannotated) +allowdeletebranch=$(git config --bool hooks.allowdeletebranch) +denycreatebranch=$(git config --bool hooks.denycreatebranch) +allowdeletetag=$(git config --bool hooks.allowdeletetag) +allowmodifytag=$(git config --bool hooks.allowmodifytag) + +# check for no description +projectdesc=$(sed -e '1q' "$GIT_DIR/description") +case "$projectdesc" in +"Unnamed repository"* | "") + echo "*** Project description file hasn't been set" >&2 + exit 1 + ;; +esac + +# --- Check types +# if $newrev is 0000...0000, it's a commit to delete a ref. +zero="0000000000000000000000000000000000000000" +if [ "$newrev" = "$zero" ]; then + newrev_type=delete +else + newrev_type=$(git cat-file -t $newrev) +fi + +case "$refname","$newrev_type" in + refs/tags/*,commit) + # un-annotated tag + short_refname=${refname##refs/tags/} + if [ "$allowunannotated" != "true" ]; then + echo "*** The un-annotated tag, $short_refname, is not allowed in this repository" >&2 + echo "*** Use 'git tag [ -a | -s ]' for tags you want to propagate." >&2 + exit 1 + fi + ;; + refs/tags/*,delete) + # delete tag + if [ "$allowdeletetag" != "true" ]; then + echo "*** Deleting a tag is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/tags/*,tag) + # annotated tag + if [ "$allowmodifytag" != "true" ] && git rev-parse $refname > /dev/null 2>&1 + then + echo "*** Tag '$refname' already exists." >&2 + echo "*** Modifying a tag is not allowed in this repository." >&2 + exit 1 + fi + ;; + refs/heads/*,commit) + # branch + if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then + echo "*** Creating a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/heads/*,delete) + # delete branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + refs/remotes/*,commit) + # tracking branch + ;; + refs/remotes/*,delete) + # delete tracking branch + if [ "$allowdeletebranch" != "true" ]; then + echo "*** Deleting a tracking branch is not allowed in this repository" >&2 + exit 1 + fi + ;; + *) + # Anything else (is there anything else?) + echo "*** Update hook: unknown type of update to ref $refname of type $newrev_type" >&2 + exit 1 + ;; +esac + +# --- Finished +exit 0 diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/index b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/index new file mode 100644 index 0000000000000000000000000000000000000000..728ccc4dbd1cbdfa48e623778e4b5f10b6c42326 GIT binary patch literal 233 zcmZ?q402{*U|<5_kSj-l6axc{W(0{({CS^&p>au-k=kRhBm;x2!eu7LaOK9Ech-yf z$&?j@)}1Q~XW&mPD9Fi7PAtjH&(o{S%>kQpWG=)!2n{uF2AX+F(;V#lPW4^96IOI( zue?x1!1hNSq`Ei=KId>zI)U$a}f^!q3B0; literal 0 HcmV?d00001 diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/info/exclude b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/info/exclude new file mode 100644 index 00000000..a5196d1b --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/info/exclude @@ -0,0 +1,6 @@ +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/logs/HEAD b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/logs/HEAD new file mode 100644 index 00000000..ca8453d4 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/logs/HEAD @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 c960eaa883ffafea56e5940baf1fc7d1b5d35b56 Andy Chan 1423230131 -0800 commit (initial): test case +c960eaa883ffafea56e5940baf1fc7d1b5d35b56 4e1f25bbdca5765e279b436b5b02d05b1654515c Andy Chan 1423230216 -0800 commit: test case diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/logs/refs/heads/master b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/logs/refs/heads/master new file mode 100644 index 00000000..ca8453d4 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/logs/refs/heads/master @@ -0,0 +1,2 @@ +0000000000000000000000000000000000000000 c960eaa883ffafea56e5940baf1fc7d1b5d35b56 Andy Chan 1423230131 -0800 commit (initial): test case +c960eaa883ffafea56e5940baf1fc7d1b5d35b56 4e1f25bbdca5765e279b436b5b02d05b1654515c Andy Chan 1423230216 -0800 commit: test case diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/1a/138ced808f5fb3206283b292253d8ba7a99b31 b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/1a/138ced808f5fb3206283b292253d8ba7a99b31 new file mode 100644 index 0000000000000000000000000000000000000000..910eec7620ad28a4ab45fab37c20032efb8a4cbb GIT binary patch literal 103 zcmV-t0GR)H0V^p=O;xZoWH2-^Ff%bxNGvGG$xKcx$;{8wtIW+|P`J#*7_QuS^UiuP zKbf+E(7JO);ZUU|sl_FRy2WM5dId%K1*t_PnW@DL(;V#lPW4^96IOI(ue?x=x8tma&c95?pztBpx1GbmEoWQS0ey4$_}pp literal 0 HcmV?d00001 diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/4e/1f25bbdca5765e279b436b5b02d05b1654515c b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/4e/1f25bbdca5765e279b436b5b02d05b1654515c new file mode 100644 index 0000000000000000000000000000000000000000..32102c39d91adef6f7d7f13a25a1f0c49e4e393e GIT binary patch literal 158 zcmV;P0Ac@l0iBLf3IZVzK>PL-UZBvK)kcUYI?1RbyU=RvTF~wD4E;SGJb0(Vs< z9r`AsEnB1{nG6+IB7*Ti7$E>S%oO>|Aw;z5#hcWwQ}9NZiLewd!p@5elZjkxN#|^% z%jlx>ir;;1o4(il)sLC0zVN^_==NMbQn@d!o>E({+D?Fg2CUadL&m6K$7Gj3bJb-Z Mr@V{$0qHYH#0TI}3jhEB literal 0 HcmV?d00001 diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/53/14629d4229558db9cc91fec7631833e03434b3 b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/53/14629d4229558db9cc91fec7631833e03434b3 new file mode 100644 index 0000000000000000000000000000000000000000..9bcca6d40fc16880b0dfb92fa4d186e809d8e080 GIT binary patch literal 65 zcmV-H0KWft0V^p=O;s?lU@$Z=Ff%bxC`m0YG1M(COV%qW$}dPQD#=VOW|-z+=Xa{_ X;+?RfD|_XIVm!IDJiY?}4rdg4;)59# literal 0 HcmV?d00001 diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/96/403e4eca8ed1dc5672d4bd1f125c490a2a48f7 b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/96/403e4eca8ed1dc5672d4bd1f125c490a2a48f7 new file mode 100644 index 0000000000000000000000000000000000000000..01d6c9ffc100c500b9b69dc82bca13b43fcf27c9 GIT binary patch literal 43 zcmbtr<&-;7nJks*e(bGGx@3pbja0i1^4}S>&bTkmN literal 0 HcmV?d00001 diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/c9/60eaa883ffafea56e5940baf1fc7d1b5d35b56 b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/c9/60eaa883ffafea56e5940baf1fc7d1b5d35b56 new file mode 100644 index 00000000..ef928461 --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/objects/c9/60eaa883ffafea56e5940baf1fc7d1b5d35b56 @@ -0,0 +1,2 @@ +xQ +!@sqtS(:;N*NA3xx׵*`D ɥK!2'ODĒ'?o]VXrKȃnv^#G hf1U37*]}9 \ No newline at end of file diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/git/refs/heads/master b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/refs/heads/master new file mode 100644 index 00000000..c010c13b --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/git/refs/heads/master @@ -0,0 +1 @@ +4e1f25bbdca5765e279b436b5b02d05b1654515c diff --git a/spring-cloud-config-server/src/test/resources/test1-config-repo/test1-svc.properties b/spring-cloud-config-server/src/test/resources/test1-config-repo/test1-svc.properties new file mode 100644 index 00000000..96403e4e --- /dev/null +++ b/spring-cloud-config-server/src/test/resources/test1-config-repo/test1-svc.properties @@ -0,0 +1,2 @@ +username=foobar +password=password