Search in sources :

Example 1 with CreateOptions

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);
        }
    }
}
Also used : KubernetesListObject(io.kubernetes.client.common.KubernetesListObject) KubectlException(io.kubernetes.client.extended.kubectl.exception.KubectlException) CreateOptions(io.kubernetes.client.util.generic.options.CreateOptions) ApiException(io.kubernetes.client.openapi.ApiException)

Aggregations

KubernetesListObject (io.kubernetes.client.common.KubernetesListObject)1 KubectlException (io.kubernetes.client.extended.kubectl.exception.KubectlException)1 ApiException (io.kubernetes.client.openapi.ApiException)1 CreateOptions (io.kubernetes.client.util.generic.options.CreateOptions)1