use of io.kubernetes.client.util.generic.options.CreateOptions in project java by kubernetes-client.
the class KubectlCreate method execute.
@Override
public ApiType execute() throws KubectlException {
refreshDiscovery();
GenericKubernetesApi<ApiType, KubernetesListObject> api = getGenericApi();
if (ModelMapper.isNamespaced(this.targetObj.getClass())) {
String targetNamespace = namespace != null ? namespace : Strings.isNullOrEmpty(targetObj.getMetadata().getNamespace()) ? Namespaces.NAMESPACE_DEFAULT : targetObj.getMetadata().getNamespace();
try {
return api.create(targetNamespace, targetObj, new CreateOptions()).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
} else {
try {
return api.create(targetObj, new CreateOptions()).throwsApiException().getObject();
} catch (ApiException e) {
throw new KubectlException(e);
}
}
}
Aggregations