Skip to content

Commit

Permalink
support sofa registry kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
呈铭 committed Feb 6, 2024
1 parent f6a8609 commit 7392e22
Show file tree
Hide file tree
Showing 8 changed files with 394 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ public String getParameter(String key) {
* @return the value
*/
public String getParameter(String key, String defaultValue) {
return parameters == null ? defaultValue : parameters.get(key);
return (parameters == null || parameters.get(key) == null) ? defaultValue : parameters.get(key);
}

/**
Expand All @@ -415,7 +415,8 @@ public String getParameter(String key, String defaultValue) {
* @return the value
*/
public int getParameter(String key, int defaultValue) {
return parameters == null ? defaultValue : Integer.parseInt(parameters.get(key));
return (parameters == null || parameters.get(key) == null) ? defaultValue : Integer.parseInt(parameters
.get(key));
}

/**
Expand All @@ -425,7 +426,8 @@ public int getParameter(String key, int defaultValue) {
* @return the value
*/
public boolean getParameter(String key, boolean defaultValue) {
return parameters == null ? defaultValue : Boolean.parseBoolean(parameters.get(key));
return (parameters == null || parameters.get(key) == null) ? defaultValue : Boolean.parseBoolean(parameters
.get(key));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,20 @@ private List<Pod> getPods() {
.getItems();
}

/**
* UT used only
*/
@Deprecated
public void setCurrentHostname(String currentHostname) {
this.currentHostname = currentHostname;
}

/**
* UT used only
*/
@Deprecated
public ConcurrentMap<ConsumerConfig, SharedIndexInformer<Pod>> getConsumerListeners() {
return consumerListeners;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public class KubernetesClientConstants {

public static final String DEFAULT_MASTER_URL = "https://kubernetes.default.svc";

public static final String LABEL_KEY = "io.sofa.rpc/label";
public static final String LABEL_KEY = "com.sofa.rpc/label";

public static final String ANNOTATION_KEY = "io.sofa.rpc/annotation";
public static final String ANNOTATION_KEY = "com.sofa.rpc/annotation";

public static final String TRUST_CERTS = "trustCerts";

Expand Down Expand Up @@ -64,8 +64,6 @@ public class KubernetesClientConstants {

public static final String REQUEST_TIMEOUT = "requestTimeout";

public static final String ROLLING_TIMEOUT = "rollingTimeout";

public static final String LOGGING_INTERVAL = "loggingInterval";

public static final String HTTP_PROXY = "httpProxy";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ public static Config buildKubernetesConfig(RegistryConfig registryConfig) {

private static String buildMasterUrl(RegistryConfig registryConfig) {
String address = registryConfig.getAddress();
if (StringUtils.isNotBlank(address)) {
return (Boolean.parseBoolean(registryConfig.getParameter(USE_HTTPS, "false")) ? "https://" : "http://") +
if (StringUtils.isNotBlank(address) && address.startsWith("http")) {
return address;
} else if (StringUtils.isNotBlank(address) && !address.startsWith("http")) {
return (Boolean.parseBoolean(registryConfig.getParameter(USE_HTTPS, "true")) ? "https://" : "http://") +
address;
}
return DEFAULT_MASTER_URL;
Expand Down
Loading

0 comments on commit 7392e22

Please sign in to comment.