use of io.fabric8.openshift.api.model.ProjectRequestBuilder in project fabric8-maven-plugin by fabric8io.
the class ImportMojo method ensureNamespaceExists.
private void ensureNamespaceExists(KubernetesClient kubernetes, String name) {
name = convertToValidDnsLabel(name);
// lets check namespace exists
Namespace namespace = kubernetes.namespaces().withName(name).get();
if (namespace == null) {
Map<String, String> labels = new HashMap<>();
labels.put("provider", "fabric8");
labels.put("kind", "secrets");
namespace = new NamespaceBuilder().withNewMetadata().withName(name).withLabels(labels).endMetadata().build();
if (KubernetesHelper.isOpenShift(kubernetes)) {
ProjectRequest projectRequest = new ProjectRequestBuilder().withMetadata(namespace.getMetadata()).build();
OpenShiftClient openShiftClient = asOpenShiftClient(kubernetes);
log.info("Creating ProjectRequest " + name + " with labels: " + labels);
openShiftClient.projectrequests().create(projectRequest);
} else {
log.info("Creating Namespace " + name + " with labels: " + labels);
kubernetes.namespaces().withName(name).create(namespace);
}
}
}
Aggregations