use of io.fabric8.kubernetes.api.model.OwnerReferenceBuilder in project flink by apache.
the class Fabric8FlinkKubeClient method setOwnerReference.
private void setOwnerReference(Deployment deployment, List<HasMetadata> resources) {
final OwnerReference deploymentOwnerReference = new OwnerReferenceBuilder().withName(deployment.getMetadata().getName()).withApiVersion(deployment.getApiVersion()).withUid(deployment.getMetadata().getUid()).withKind(deployment.getKind()).withController(true).withBlockOwnerDeletion(true).build();
resources.forEach(resource -> resource.getMetadata().setOwnerReferences(Collections.singletonList(deploymentOwnerReference)));
}
use of io.fabric8.kubernetes.api.model.OwnerReferenceBuilder in project flink by apache.
the class KubernetesOwnerReference method fromMap.
public static KubernetesOwnerReference fromMap(Map<String, String> stringMap) {
final OwnerReferenceBuilder ownerReferenceBuilder = new OwnerReferenceBuilder();
stringMap.forEach((k, v) -> {
switch(k.toLowerCase()) {
case API_VERSION:
ownerReferenceBuilder.withApiVersion(v);
break;
case DELETION:
ownerReferenceBuilder.withBlockOwnerDeletion(Boolean.valueOf(v));
break;
case CONTROLLER:
ownerReferenceBuilder.withController(Boolean.valueOf(v));
break;
case KIND:
ownerReferenceBuilder.withKind(v);
break;
case NAME:
ownerReferenceBuilder.withName(v);
break;
case UUID:
ownerReferenceBuilder.withUid(v);
break;
default:
LOG.warn("Unrecognized key({}) of toleration, will ignore.", k);
break;
}
});
return new KubernetesOwnerReference(ownerReferenceBuilder.build());
}
use of io.fabric8.kubernetes.api.model.OwnerReferenceBuilder in project keycloak by keycloak.
the class OperatorManagedResource method setOwnerReferences.
protected void setOwnerReferences(HasMetadata resource) {
if (!cr.getMetadata().getNamespace().equals(resource.getMetadata().getNamespace())) {
return;
}
OwnerReference owner = new OwnerReferenceBuilder().withApiVersion(cr.getApiVersion()).withKind(cr.getKind()).withName(cr.getMetadata().getName()).withUid(cr.getMetadata().getUid()).withBlockOwnerDeletion(true).withController(true).build();
resource.getMetadata().setOwnerReferences(Collections.singletonList(owner));
}
Aggregations