Commit a0e6a98a authored by Jason Song's avatar Jason Song Committed by GitHub

Merge branch 'master' into ldap_support_ad

parents 043ed967 f73ded8c
...@@ -22,4 +22,16 @@ We provide template files [intellij-java-google-style.xml](https://github.com/ct ...@@ -22,4 +22,16 @@ We provide template files [intellij-java-google-style.xml](https://github.com/ct
* If no-one else is using your branch, please rebase it against the current master (or other target branch in the main project). * If no-one else is using your branch, please rebase it against the current master (or other target branch in the main project).
* Normally, we would squash commits for one feature into one commit. There are 2 ways to do this:
1. To rebase and squash based on the remote branch
* `git rebase -i <remote>/master`
* merge commits via `fixup`, etc
2. Create a new branch and merge these commits into one
* `git checkout -b <some-branch-name> <remote>/master`
* `git merge --squash <current-feature-branch>`
* When writing a commit message please follow these conventions: if you are fixing an existing issue, please add Fixes #XXX at the end of the commit message (where XXX is the issue number). * When writing a commit message please follow these conventions: if you are fixing an existing issue, please add Fixes #XXX at the end of the commit message (where XXX is the issue number).
...@@ -24,10 +24,6 @@ Java客户端不依赖任何框架,能够运行于所有Java运行时环境, ...@@ -24,10 +24,6 @@ Java客户端不依赖任何框架,能够运行于所有Java运行时环境,
本地快速部署请参见[Quick Start](https://github.com/ctripcorp/apollo/wiki/Quick-Start) 本地快速部署请参见[Quick Start](https://github.com/ctripcorp/apollo/wiki/Quick-Start)
公益演示环境(Demo):
- [140.143.100.23:8070](http://140.143.100.23:8070/)
- 账号/密码:apollo/admin
# Screenshots # Screenshots
![配置界面](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-home-screenshot.png) ![配置界面](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/apollo-home-screenshot.png)
...@@ -230,3 +226,6 @@ The project is licensed under the [Apache 2 license](https://github.com/ctripcor ...@@ -230,3 +226,6 @@ The project is licensed under the [Apache 2 license](https://github.com/ctripcor
![中移物联网](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/zyiot.jpg) ![中移物联网](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/zyiot.jpg)
![易车网](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/biauto.png) ![易车网](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/biauto.png)
![一药网](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/maiyaole.png) ![一药网](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/maiyaole.png)
![小影](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/xiaoying.png)
![彩贝壳](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/caibeike.png)
![YEELIGHT](https://raw.githubusercontent.com/ctripcorp/apollo/master/doc/images/known-users/yeelight.png)
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
FROM openjdk:8-jre-alpine FROM openjdk:8-jre-alpine
MAINTAINER ameizi <sxyx2008@163.com> MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.1.0-SNAPSHOT ENV VERSION 1.2.0-SNAPSHOT
RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \
......
...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.common.exception.NotFoundException; ...@@ -8,6 +8,7 @@ import com.ctrip.framework.apollo.common.exception.NotFoundException;
import com.ctrip.framework.apollo.common.utils.BeanUtils; import com.ctrip.framework.apollo.common.utils.BeanUtils;
import com.ctrip.framework.apollo.common.utils.InputValidator; import com.ctrip.framework.apollo.common.utils.InputValidator;
import com.ctrip.framework.apollo.core.ConfigConsts;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -51,10 +52,17 @@ public class ClusterController { ...@@ -51,10 +52,17 @@ public class ClusterController {
@RequestMapping(path = "/apps/{appId}/clusters/{clusterName:.+}", method = RequestMethod.DELETE) @RequestMapping(path = "/apps/{appId}/clusters/{clusterName:.+}", method = RequestMethod.DELETE)
public void delete(@PathVariable("appId") String appId, public void delete(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName, @RequestParam String operator) { @PathVariable("clusterName") String clusterName, @RequestParam String operator) {
Cluster entity = clusterService.findOne(appId, clusterName); Cluster entity = clusterService.findOne(appId, clusterName);
if (entity == null) { if (entity == null) {
throw new NotFoundException("cluster not found for clusterName " + clusterName); throw new NotFoundException("cluster not found for clusterName " + clusterName);
} }
if(ConfigConsts.CLUSTER_NAME_DEFAULT.equals(entity.getName())){
throw new BadRequestException("can not delete default cluster!");
}
clusterService.delete(entity.getId(), operator); clusterService.delete(entity.getId(), operator);
} }
......
package com.ctrip.framework.apollo.adminservice.controller;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.ctrip.framework.apollo.biz.entity.Cluster;
import com.ctrip.framework.apollo.biz.service.ClusterService;
import com.ctrip.framework.apollo.common.exception.BadRequestException;
import com.ctrip.framework.apollo.core.ConfigConsts;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.test.util.ReflectionTestUtils;
public class ClusterControllerTest {
private ClusterController clusterController;
@Mock
private ClusterService clusterService;
@Before
public void setUp() {
clusterController = new ClusterController();
MockitoAnnotations.initMocks(this);
ReflectionTestUtils.setField(clusterController, "clusterService", clusterService);
}
@Test(expected = BadRequestException.class)
public void testDeleteDefaultFail() {
Cluster cluster = new Cluster();
cluster.setName(ConfigConsts.CLUSTER_NAME_DEFAULT);
when(clusterService.findOne(any(String.class), any(String.class))).thenReturn(cluster);
clusterController.delete("1", "2", "d");
}
@Test
public void testDeleteSuccess() {
Cluster cluster = new Cluster();
when(clusterService.findOne(any(String.class), any(String.class))).thenReturn(cluster);
clusterController.delete("1", "2", "d");
verify(clusterService, times(1)).findOne("1", "2");
}
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apollo-biz</artifactId> <artifactId>apollo-biz</artifactId>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -88,7 +88,7 @@ If you need this functionality, you could specify the cluster as follows: ...@@ -88,7 +88,7 @@ If you need this functionality, you could specify the cluster as follows:
<dependency> <dependency>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId> <artifactId>apollo-client</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
</dependency> </dependency>
## III. Client Usage ## III. Client Usage
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
FROM openjdk:8-jre-alpine FROM openjdk:8-jre-alpine
MAINTAINER ameizi <sxyx2008@163.com> MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.1.1-SNAPSHOT ENV VERSION 1.2.0-SNAPSHOT
RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
package com.ctrip.framework.apollo.core.internals; package com.ctrip.framework.apollo.core.internals;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import com.ctrip.framework.apollo.core.enums.Env; import com.ctrip.framework.apollo.core.enums.Env;
import com.ctrip.framework.apollo.core.spi.MetaServerProvider; import com.ctrip.framework.apollo.core.spi.MetaServerProvider;
import com.ctrip.framework.apollo.core.utils.ResourceUtils; import com.ctrip.framework.apollo.core.utils.ResourceUtils;
import com.google.common.base.Strings;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/** /**
* For legacy meta server configuration use, i.e. apollo-env.properties * For legacy meta server configuration use, i.e. apollo-env.properties
*/ */
public class LegacyMetaServerProvider implements MetaServerProvider { public class LegacyMetaServerProvider implements MetaServerProvider {
// make it as lowest as possible, yet not the lowest // make it as lowest as possible, yet not the lowest
public static final int ORDER = MetaServerProvider.LOWEST_PRECEDENCE - 1; public static final int ORDER = MetaServerProvider.LOWEST_PRECEDENCE - 1;
private static final Map<Env, String> domains = new HashMap<>(); private static final Map<Env, String> domains = new HashMap<>();
...@@ -23,19 +24,27 @@ public class LegacyMetaServerProvider implements MetaServerProvider { ...@@ -23,19 +24,27 @@ public class LegacyMetaServerProvider implements MetaServerProvider {
private void initialize() { private void initialize() {
Properties prop = new Properties(); Properties prop = new Properties();
prop = ResourceUtils.readConfigFile("apollo-env.properties", prop); prop = ResourceUtils.readConfigFile("apollo-env.properties", prop);
Properties env = System.getProperties();
domains.put(Env.LOCAL, domains.put(Env.LOCAL, getMetaServerAddress(prop, "local_meta", "local.meta"));
env.getProperty("local_meta", prop.getProperty("local.meta"))); domains.put(Env.DEV, getMetaServerAddress(prop, "dev_meta", "dev.meta"));
domains.put(Env.DEV, domains.put(Env.FAT, getMetaServerAddress(prop, "fat_meta", "fat.meta"));
env.getProperty("dev_meta", prop.getProperty("dev.meta"))); domains.put(Env.UAT, getMetaServerAddress(prop, "uat_meta", "uat.meta"));
domains.put(Env.FAT, domains.put(Env.LPT, getMetaServerAddress(prop, "lpt_meta", "lpt.meta"));
env.getProperty("fat_meta", prop.getProperty("fat.meta"))); domains.put(Env.PRO, getMetaServerAddress(prop, "pro_meta", "pro.meta"));
domains.put(Env.UAT, }
env.getProperty("uat_meta", prop.getProperty("uat.meta")));
domains.put(Env.LPT, private String getMetaServerAddress(Properties prop, String sourceName, String propName) {
env.getProperty("lpt_meta", prop.getProperty("lpt.meta"))); // 1. Get from System Property.
domains.put(Env.PRO, String metaAddress = System.getProperty(sourceName);
env.getProperty("pro_meta", prop.getProperty("pro.meta"))); if (Strings.isNullOrEmpty(metaAddress)) {
// 2. Get from OS environment variable, which could not contain dot and is normally in UPPER case,like DEV_META.
metaAddress = System.getenv(sourceName.toUpperCase());
}
if (Strings.isNullOrEmpty(metaAddress)) {
// 3. Get from properties file.
metaAddress = prop.getProperty(propName);
}
return metaAddress;
} }
@Override @Override
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>apollo-demo</artifactId> <artifactId>apollo-demo</artifactId>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<parent> <parent>
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
FROM openjdk:8-jre-alpine FROM openjdk:8-jre-alpine
MAINTAINER ameizi <sxyx2008@163.com> MAINTAINER ameizi <sxyx2008@163.com>
ENV VERSION 1.1.1-SNAPSHOT0 ENV VERSION 1.2.0-SNAPSHOT
RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \
&& echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<groupId>com.ctrip.framework.apollo</groupId> <groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo</artifactId> <artifactId>apollo</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.2.0-SNAPSHOT</version>
<name>Apollo</name> <name>Apollo</name>
<packaging>pom</packaging> <packaging>pom</packaging>
<description>Ctrip Configuration Center</description> <description>Ctrip Configuration Center</description>
...@@ -434,7 +434,7 @@ ...@@ -434,7 +434,7 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>1.3.8.RELEASE</version> <version>1.3.5.RELEASE</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment