apache / dubbo-admin

@@ -170,10 +170,10 @@
Loading
170 170
171 171
    private URL formUrl(String config, String group, String nameSpace, String username, String password) {
172 172
        URL url = URL.valueOf(config);
173 -
        if (StringUtils.isNotEmpty(group)) {
173 +
        if (StringUtils.isEmpty(url.getParameter(Constants.GROUP_KEY)) && StringUtils.isNotEmpty(group)) {
174 174
            url = url.addParameter(Constants.GROUP_KEY, group);
175 175
        }
176 -
        if (StringUtils.isNotEmpty(nameSpace)){
176 +
        if (StringUtils.isEmpty(url.getParameter(Constants.NAMESPACE_KEY)) && StringUtils.isNotEmpty(nameSpace)) {
177 177
            url = url.addParameter(Constants.NAMESPACE_KEY, nameSpace);
178 178
        }
179 179
        if (StringUtils.isNotEmpty(username)) {

@@ -19,29 +19,48 @@
Loading
19 19
20 20
import com.ctrip.framework.apollo.openapi.client.ApolloOpenApiClient;
21 21
import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO;
22 +
23 +
import org.apache.dubbo.admin.common.util.Constants;
22 24
import org.apache.dubbo.admin.registry.config.GovernanceConfiguration;
23 25
import org.apache.dubbo.common.URL;
24 26
import org.apache.dubbo.common.extension.SPI;
27 +
import org.apache.dubbo.common.utils.StringUtils;
25 28
import org.springframework.beans.factory.annotation.Value;
26 29
30 +
import java.util.Arrays;
31 +
import java.util.stream.Collectors;
32 +
33 +
import static org.apache.dubbo.common.constants.CommonConstants.COMMA_SPLIT_PATTERN;
34 +
27 35
@SPI("apollo")
28 36
public class ApolloConfiguration implements GovernanceConfiguration {
29 37
30 -
    @Value("${admin.apollo.token}")
31 -
    private String token;
38 +
    private static final String APOLLO_ENV_KEY = "env";
39 +
    private static final String CLUSTER_KEY = "cluster";
40 +
    private static final String TOKEN_KEY = "token";
41 +
    private static final String APOLLO_APPID_KEY = "app.id";
42 +
    private static final String APOLLO_PROTOCOL_PREFIX = "http://";
32 43
33 -
    @Value("${admin.apollo.cluster}")
34 -
    private String cluster;
44 +
    @Value("${admin.apollo.token:}")
45 +
    private String configToken;
35 46
36 -
    @Value("${admin.apollo.namespace}")
37 -
    private String namespace;
47 +
    @Value("${admin.apollo.cluster:}")
48 +
    private String configCluster;
38 49
39 -
    @Value("${admin.apollo.env}")
40 -
    private String env;
50 +
    @Value("${admin.apollo.namespace:}")
51 +
    private String configNamespace;
41 52
42 -
    @Value("${admin.apollo.appId}")
43 -
    private String appId;
53 +
    @Value("${admin.apollo.env:}")
54 +
    private String configEnv;
55 +
56 +
    @Value("${admin.apollo.appId:}")
57 +
    private String configAppId;
44 58
59 +
    private String token;
60 +
    private String cluster;
61 +
    private String namespace;
62 +
    private String env;
63 +
    private String appId;
45 64
    private URL url;
46 65
    private ApolloOpenApiClient client;
47 66
@@ -58,9 +77,28 @@
Loading
58 77
59 78
    @Override
60 79
    public void init() {
61 -
        client = ApolloOpenApiClient.newBuilder().withPortalUrl(url.getAddress()).withToken(token).build();
80 +
        token = url.getParameter(TOKEN_KEY, configToken);
81 +
        cluster = url.getParameter(CLUSTER_KEY, configCluster);
82 +
        namespace = url.getParameter(Constants.NAMESPACE_KEY, configNamespace);
83 +
        env = url.getParameter(APOLLO_ENV_KEY, configEnv);
84 +
        appId = url.getParameter(APOLLO_APPID_KEY, configAppId);
85 +
        String address = getAddressWithProtocolPrefix(url);
86 +
        client = ApolloOpenApiClient.newBuilder().withPortalUrl(address).withToken(token).build();
87 +
    }
88 +
    private String getAddressWithProtocolPrefix(URL url) {
89 +
        String address = url.getBackupAddress();
90 +
        if (StringUtils.isNotEmpty(address)) {
91 +
            address = Arrays.stream(COMMA_SPLIT_PATTERN.split(address))
92 +
                    .map(addr -> {
93 +
                        if (addr.startsWith(APOLLO_PROTOCOL_PREFIX)) {
94 +
                            return addr;
95 +
                        }
96 +
                        return APOLLO_PROTOCOL_PREFIX + addr;
97 +
                    })
98 +
                    .collect(Collectors.joining(","));
99 +
        }
100 +
        return address;
62 101
    }
63 -
64 102
    @Override
65 103
    public String setConfig(String key, String value) {
66 104
        return setConfig(null, key, value);
Files Complexity Coverage
dubbo-admin-server/src/main/java/org/apache/dubbo/admin 20.01% 21.21%
Project Totals (97 files) 20.01% 21.21%
Notifications are pending CI completion. Periodically Codecov will check the CI state, when complete notifications will be submitted. Push notifications now.

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading