Search in sources :

Example 1 with CustomResourceDefinitionContext

use of io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext in project syndesis-qe by syndesisio.

the class Syndesis method makeSyndesisContext.

private CustomResourceDefinitionContext makeSyndesisContext(String version) {
    CustomResourceDefinition syndesisCrd = getCrd();
    CustomResourceDefinitionContext.Builder builder = new CustomResourceDefinitionContext.Builder().withGroup(syndesisCrd.getSpec().getGroup()).withPlural(syndesisCrd.getSpec().getNames().getPlural()).withScope(syndesisCrd.getSpec().getScope()).withVersion(version);
    return builder.build();
}
Also used : CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition)

Example 2 with CustomResourceDefinitionContext

use of io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext in project jbosstools-openshift by jbosstools.

the class OdoCli method createService.

@Override
public void createService(String project, String application, ServiceTemplate serviceTemplate, OperatorCRD serviceCRD, String service, ObjectNode spec, boolean wait) throws IOException {
    try {
        CustomResourceDefinitionContext context = toCustomResourceDefinitionContext(serviceCRD);
        ObjectNode payload = serviceCRD.getSample().deepCopy();
        updatePayload(payload, spec, project, service);
        client.customResource(context).create(project, JSON_MAPPER.writeValueAsString(payload));
        UsageStats.getInstance().odoCommand("service create", true);
        UsageStats.getInstance().createService(serviceTemplate.getName(), true);
    } catch (KubernetesClientException e) {
        UsageStats.getInstance().odoCommand("service create", false);
        UsageStats.getInstance().createService(serviceTemplate.getName(), false);
        throw new IOException(e.getLocalizedMessage(), e);
    } catch (IOException e) {
        UsageStats.getInstance().odoCommand("service create", false);
        UsageStats.getInstance().createService(serviceTemplate.getName(), false);
        throw e;
    }
}
Also used : CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) IOException(java.io.IOException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Example 3 with CustomResourceDefinitionContext

use of io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext in project syndesis-qe by syndesisio.

the class Syndesis method getSubscription.

private static JSONObject getSubscription() {
    CustomResourceDefinitionContext context = getSubscriptionCRDContext();
    JSONObject subs = new JSONObject(OpenShiftUtils.getInstance().customResource(context).list(TestConfiguration.openShiftNamespace()));
    JSONArray items = subs.getJSONArray("items");
    for (int i = 0; i < items.length(); i++) {
        if (items.getJSONObject(i).getJSONObject("spec").getString("name").equals("fuse-online")) {
            return items.getJSONObject(i);
        }
    }
    return null;
}
Also used : CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray)

Example 4 with CustomResourceDefinitionContext

use of io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext in project syndesis-qe by syndesisio.

the class CamelK method getCamelKCRD.

private CustomResourceDefinitionContext getCamelKCRD() {
    CustomResourceDefinition crd = OpenShiftUtils.getInstance().customResourceDefinitions().withName("integrations.camel.apache.org").get();
    CustomResourceDefinitionContext.Builder builder = new CustomResourceDefinitionContext.Builder().withGroup(crd.getSpec().getGroup()).withPlural(crd.getSpec().getNames().getPlural()).withScope(crd.getSpec().getScope()).withVersion(crd.getSpec().getVersion());
    return builder.build();
}
Also used : CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition)

Example 5 with CustomResourceDefinitionContext

use of io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext in project jbosstools-openshift by jbosstools.

the class OdoCli method deleteService.

@Override
public void deleteService(String project, String application, org.jboss.tools.openshift.core.odo.Service service) throws IOException {
    try {
        CustomResourceDefinitionContext context = toCustomResourceDefinitionContext(service);
        client.customResource(context).delete(project, service.getName());
        UsageStats.getInstance().odoCommand("service delete", true);
    } catch (KubernetesClientException e) {
        UsageStats.getInstance().odoCommand("service delete", false);
        throw e;
    }
}
Also used : CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException)

Aggregations

CustomResourceDefinitionContext (io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext)5 CustomResourceDefinition (io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition)2 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 IOException (java.io.IOException)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1