本文整理了Java中io.fabric8.kubernetes.client.utils.Utils.isNullOrEmpty()
方法的一些代码示例,展示了Utils.isNullOrEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.isNullOrEmpty()
方法的具体详情如下:
包路径:io.fabric8.kubernetes.client.utils.Utils
类名称:Utils
方法名:isNullOrEmpty
暂无
代码示例来源:origin: spring-cloud/spring-cloud-kubernetes
if (Utils.isNullOrEmpty(portName)
|| portName.endsWith(port.getName())) {
for (EndpointAddress address : subset.getAddresses()) {
代码示例来源:origin: fabric8io/kubernetes-client
public static boolean isNotNullOrEmpty(String str) {
return !isNullOrEmpty(str);
}
代码示例来源:origin: fabric8io/kubernetes-client
private static char[] getTrustStorePassphrase(String trustStorePassphrase) {
if (Utils.isNullOrEmpty(trustStorePassphrase)) {
return System.getProperty(TRUST_STORE_PASSWORD_SYSTEM_PROPERTY, "changeit").toCharArray();
}
return trustStorePassphrase.toCharArray();
}
代码示例来源:origin: fabric8io/kubernetes-client
private static char[] getKeyStorePassphrase(String keyStorePassphrase) {
if (Utils.isNullOrEmpty(keyStorePassphrase)) {
return System.getProperty(KEY_STORE_PASSWORD_SYSTEM_PROPERTY, "changeit").toCharArray();
}
return keyStorePassphrase.toCharArray();
}
代码示例来源:origin: fabric8io/kubernetes-client
public static String getProperty(Map<String, Object> properties, String propertyName, String defaultValue) {
String answer = (String) properties.get(propertyName);
if (!isNullOrEmpty(answer)) {
return answer;
}
return getSystemPropertyOrEnvVar(propertyName, defaultValue);
}
代码示例来源:origin: fabric8io/kubernetes-client
protected <T> String checkName(T item) {
String operationName = getName();
String itemName = item instanceof HasMetadata ? ((HasMetadata) item).getMetadata().getName() : null;
if (Utils.isNullOrEmpty(operationName) && Utils.isNullOrEmpty(itemName)) {
return null;
} else if (Utils.isNullOrEmpty(itemName)) {
return operationName;
} else if (Utils.isNullOrEmpty(operationName)) {
return itemName;
} else if (itemName.equals(operationName)) {
return itemName;
}
throw new KubernetesClientException("Name mismatch. Item name:" + itemName + ". Operation name:" + operationName + ".");
}
代码示例来源:origin: fabric8io/kubernetes-client
@Override
protected <T> String checkNamespace(T item) {
String operationNs = getNamespace();
String itemNs = (item instanceof HasMetadata && ((HasMetadata)item).getMetadata() != null) ? ((HasMetadata) item).getMetadata().getNamespace() : null;
if (Utils.isNullOrEmpty(operationNs) && Utils.isNullOrEmpty(itemNs)) {
return null;
} else if (Utils.isNullOrEmpty(itemNs)) {
return operationNs;
} else if (Utils.isNullOrEmpty(operationNs)) {
return itemNs;
} else if (itemNs.equals(operationNs)) {
return itemNs;
}
throw new KubernetesClientException("Namespace mismatch. Item namespace:" + itemNs + ". Operation namespace:" + operationNs + ".");
}
代码示例来源:origin: fabric8io/kubernetes-client
private String getQueryParameters() throws MalformedURLException {
StringBuilder sb = new StringBuilder();
sb.append(URLUtils.join(getResourceUrl().toString(), "instantiatebinary"));
if (Utils.isNullOrEmpty(message)) {
sb.append("?commit=");
} else {
sb.append("?commit=").append(message);
}
if (!Utils.isNullOrEmpty(authorName)) {
sb.append("&revision.authorName=").append(authorName);
}
if (!Utils.isNullOrEmpty(authorEmail)) {
sb.append("&revision.authorEmail=").append(authorEmail);
}
if (!Utils.isNullOrEmpty(committerName)) {
sb.append("&revision.committerName=").append(committerName);
}
if (!Utils.isNullOrEmpty(committerEmail)) {
sb.append("&revision.committerEmail=").append(committerEmail);
}
if (!Utils.isNullOrEmpty(commit)) {
sb.append("&revision.commit=").append(commit);
}
if (!Utils.isNullOrEmpty(asFile)) {
sb.append("&asFile=").append(asFile);
}
return sb.toString();
}
代码示例来源:origin: fabric8io/kubernetes-client
protected <T> String checkNamespace(T item) {
String operationNs = getNamespace();
String itemNs = (item instanceof HasMetadata && ((HasMetadata)item).getMetadata() != null) ? ((HasMetadata) item).getMetadata().getNamespace() : null;
if (Utils.isNullOrEmpty(operationNs) && Utils.isNullOrEmpty(itemNs)) {
if (!isResourceNamespaced()) {
return null;
} else {
throw new KubernetesClientException("Namespace not specified. But operation requires namespace.");
}
} else if (Utils.isNullOrEmpty(itemNs)) {
return operationNs;
} else if (Utils.isNullOrEmpty(operationNs)) {
return itemNs;
} else if (itemNs.equals(operationNs)) {
return itemNs;
}
throw new KubernetesClientException("Namespace mismatch. Item namespace:" + itemNs + ". Operation namespace:" + operationNs + ".");
}
代码示例来源:origin: fabric8io/kubernetes-client
/**
* Returns the resource version for the entity or null if it does not have one
*/
public static String getResourceVersion(HasMetadata entity) {
if (entity != null) {
ObjectMeta metadata = entity.getMetadata();
if (metadata != null) {
String resourceVersion = metadata.getResourceVersion();
if (!Utils.isNullOrEmpty(resourceVersion)) {
return resourceVersion;
}
}
}
return null;
}
代码示例来源:origin: fabric8io/kubernetes-client
public URL getRootUrl() {
try {
if (!Utils.isNullOrEmpty(apiGroupName)) {
return new URL(URLUtils.join(config.getMasterUrl().toString(), "apis", apiGroupName, apiGroupVersion));
}
return new URL(URLUtils.join(config.getMasterUrl().toString(), "api", apiGroupVersion));
} catch (MalformedURLException e) {
throw KubernetesClientException.launderThrowable(e);
}
}
代码示例来源:origin: fabric8io/kubernetes-client
if (m.matches()) {
String kind = m.group(KIND);
if (!Utils.isNullOrEmpty(kind)) {
if (!Utils.isNullOrEmpty(namespace)) {
attributes = attributes.add(new Attribute(NAMESPACE, namespace));
if (!Utils.isNullOrEmpty(name)) {
attributes = attributes.add(new Attribute(NAME, name));
代码示例来源:origin: fabric8io/spring-cloud-kubernetes
@Override
public ServiceInstance getLocalServiceInstance() {
String serviceName = properties.getServiceName();
String podName = System.getenv(HOSTNAME);
ServiceInstance defaultInstance = new DefaultServiceInstance(serviceName, "localhost", 8080, false);
Endpoints endpoints = client.endpoints().withName(serviceName).get();
if (Utils.isNullOrEmpty(podName) || endpoints == null) {
return defaultInstance;
}
try {
return endpoints.getSubsets()
.stream()
.filter(s -> s.getAddresses().get(0).getTargetRef().getName().equals(podName))
.map(s -> (ServiceInstance) new KubernetesServiceInstance(serviceName,
s.getAddresses().stream().findFirst().orElseThrow(IllegalStateException::new),
s.getPorts().stream().findFirst().orElseThrow(IllegalStateException::new),
false))
.findFirst().orElse(defaultInstance);
} catch (Throwable t) {
return defaultInstance;
}
}
代码示例来源:origin: fabric8io/kubernetes-client
@Override
public void visit(ObjectMetaBuilder builder) {
if (Utils.isNotNullOrEmpty(explicitNamespace)) {
builder.withNamespace(explicitNamespace);
} else if (Utils.isNullOrEmpty(builder.getNamespace())) {
builder.withNamespace(fallbackNamespace);
}
}
}
代码示例来源:origin: fabric8io/kubernetes-client
@Override
public void visit(ObjectMetaBuilder builder) {
if (Utils.isNotNullOrEmpty(explicitNamespace)) {
builder.withNamespace(explicitNamespace);
} else if (Utils.isNullOrEmpty(builder.getNamespace())) {
builder.withNamespace(fallbackNamespace);
}
}
}
代码示例来源:origin: fabric8io/kubernetes-client
String token = null;
if (Utils.isNotNullOrEmpty(oauthToken.get()) && Utils.isNullOrEmpty(request.header(AUTHORIZATION))) {
token = oauthToken.get();
} else if (Utils.isNotNullOrEmpty(config.getUsername()) && Utils.isNotNullOrEmpty(config.getPassword())) {
if (Utils.isNotNullOrEmpty(token) && Utils.isNullOrEmpty(request.header(AUTHORIZATION))) {
setAuthHeader(builder, token);
代码示例来源:origin: fabric8io/kubernetes-client
@Override
public AttributeSet extract(HasMetadata o) {
AttributeSet attributes = new AttributeSet();
if (!Utils.isNullOrEmpty(o.getKind())) {
attributes = attributes.add(new Attribute(KIND, o.getKind().toLowerCase()));
}
if (!Utils.isNullOrEmpty(o.getMetadata().getName())) {
attributes = attributes.add(new Attribute(NAME, o.getMetadata().getName()));
}
if (!Utils.isNullOrEmpty(o.getMetadata().getNamespace())) {
attributes = attributes.add(new Attribute(NAMESPACE, o.getMetadata().getNamespace()));
}
if (o.getMetadata().getLabels() != null) {
for (Map.Entry<String, String> label : o.getMetadata().getLabels().entrySet()) {
attributes = attributes.add(new Attribute(LABEL_KEY_PREFIX + label.getKey(), label.getValue()));
}
}
return attributes;
}
代码示例来源:origin: fabric8io/kubernetes-client
@Override
public T createOrReplace(T... items) {
T item = getItem();
if (items.length > 1) {
throw new IllegalArgumentException("Too many items to create.");
} else if (items.length == 1) {
item = items[0];
}
if (item == null) {
throw new IllegalArgumentException("Nothing to create.");
}
if (Utils.isNullOrEmpty(name) && item instanceof HasMetadata) {
return withName(((HasMetadata)item).getMetadata().getName()).createOrReplace(item);
}
if (fromServer().get() == null) {
return create(item);
} else {
return replace(item);
}
}
代码示例来源:origin: fabric8io/spring-cloud-kubernetes
if (Utils.isNullOrEmpty(portName) || portName.endsWith(port.getName())) {
for (EndpointAddress address : subset.getAddresses()) {
result.add(new Server(address.getIp(), port.getPort()));
代码示例来源:origin: fabric8io/kubernetes-client
config.setPassword(currentAuthInfo.getPassword());
if (Utils.isNullOrEmpty(config.getOauthToken()) && currentAuthInfo.getAuthProvider() != null && !Utils.isNullOrEmpty(currentAuthInfo.getAuthProvider().getConfig().get(ACCESS_TOKEN))) {
config.setOauthToken(currentAuthInfo.getAuthProvider().getConfig().get(ACCESS_TOKEN));
} else { // https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins
内容来源于网络,如有侵权,请联系作者删除!