private boolean restored(String resourceKey, ObjectMeta istioResourceToDelete) { final List<me.snowdrop.istio.api.IstioResource> listRestoredIstioResources = restoredResourcesMap.get(resourceKey); for (me.snowdrop.istio.api.IstioResource restoredIstioResources : listRestoredIstioResources) { final ObjectMeta restoredMetadata = restoredIstioResources.getMetadata(); if (restoredMetadata.getName().equals(istioResourceToDelete.getName()) && restoredMetadata.getNamespace().equals(istioResourceToDelete.getNamespace())) { return true; } } return false; }
private String getActualName(String prefix, Iterable<? extends HasMetadata> objects, String msg) throws Exception { for (HasMetadata hmd : objects) { String name = hmd.getMetadata().getName(); if (name.startsWith(prefix)) { return name; } } throw new Exception(msg); }
@Override public String getName() { return delegate.getMetadata().getName(); }
private IstioResourcesApplier createIstioResourceApplier() { when(istioResource.getMetadata()).thenReturn(meta); when(meta.getName()).thenReturn("recommendation"); when(meta.getNamespace()).thenReturn("tutorial"); when(istioResource2.getMetadata()).thenReturn(meta2); when(meta2.getName()).thenReturn("different"); when(meta2.getNamespace()).thenReturn("tutorial"); when(istioClient.registerCustomResources(any(InputStream.class))) .thenReturn(Arrays.asList(istioResource), Arrays.asList(istioResource2)); return new IstioResourcesApplier(); }
protected String getName(Pod pod) { return pod.getMetadata().getName(); }
private Optional<Project> getProject(String name) { return listProjects().stream() .filter(p -> p.getMetadata().getName().equals(name)) .findFirst(); }
private void destroyPod(Pod pod) throws Exception { if (configuration.isNamespaceCleanupEnabled()) { client.destroy(pod); } else { logger.info("Ignoring cleanup for pod " + pod.getMetadata().getName()); } }
public ServiceCube(Service resource, OpenShiftClient client, CubeOpenShiftConfiguration configuration) { this.id = resource.getMetadata().getName(); this.resource = resource; this.client = client; this.configuration = configuration; this.portBindings = new PortBindings(); addDefaultMetadata(); }
static String getName(ObjectMeta entity) { if (entity != null) { return org.arquillian.cube.openshift.impl.utils.Strings.firstNonBlank(entity.getName(), getAdditionalPropertyText(entity.getAdditionalProperties(), "id"), entity.getUid()); } else { return null; } }
@Override public void visit(HasMetadata item) { logger.get().info("Applying " + item.getKind() + ":" + item.getMetadata().getName()); } }
public BuildablePodCube(Pod resource, OpenShiftClient client, CubeOpenShiftConfiguration configuration) { this.id = resource.getMetadata().getName(); this.resource = resource; this.template = new Template.PodTemplate(resource); this.client = client; this.configuration = configuration; this.portBindings = new PortBindings(); addDefaultMetadata(); }
@Override public void visit(HasMetadata item) { logger.get().info("Applying " + item.getKind() + ":" + item.getMetadata().getName()); } }
@Override public void stop() throws CubeControlException { try { if (configuration.isNamespaceCleanupEnabled()) { client.destroy(resource); } else { logger.info("Ignoring cleanup for service " + resource.getMetadata().getName()); } this.state = State.STOPPED; } catch (Exception e) { this.state = State.STOP_FAILED; throw CubeControlException.failedStop(getId(), e); } }
private int resolvePort(Service service) { final Pod pod = getRandomPod(client, service.getMetadata().getName(), namespace); final ServicePort servicePort = (service.getSpec() != null && service.getSpec().getPorts() != null) ? service.getSpec().getPorts().get(0) : null; final int containerPort = servicePort != null ? servicePort.getTargetPort().getIntVal() : 0; return portForward(pod.getMetadata().getName(), containerPort, namespace); }
private int resolvePort(Service service) { final Pod pod = getRandomPod(client, service.getMetadata().getName(), namespace); final ServicePort servicePort = (service.getSpec() != null && service.getSpec().getPorts() != null) ? service.getSpec().getPorts().get(0) : null; final int containerPort = servicePort != null ? servicePort.getTargetPort().getIntVal() : 0; return portForward(pod.getMetadata().getName(), containerPort, namespace); }
public void destroy(Service resource) throws Exception { getClient().services().inNamespace(namespace).withName(resource.getMetadata().getName()).delete(); }
public void destroy(Pod resource) throws Exception { getClient().pods().inNamespace(namespace).withName(resource.getMetadata().getName()).delete(); }
public List<String> getPods(String prefix) throws Exception { PodList pods; if (prefix == null) { pods = client.pods().inNamespace(configuration.getNamespace()).list(); } else { pods = client.pods().inNamespace(configuration.getNamespace()).withLabels(getLabels(prefix)).list(); } List<String> podNames = new ArrayList<>(); for (Pod pod : pods.getItems()) { podNames.add(pod.getMetadata().getName()); } return podNames; }
public void shutdown() throws Exception { if (forwarder != null) { forwarder.close(); } if (service != null) { client.services().inNamespace(namespace).withName(service.getMetadata().getName()).delete(); } if (server != null) { client.pods().inNamespace(namespace).withName(server.getMetadata().getName()).delete(); client.secrets().inNamespace(namespace).withName("gitserver-config").delete(); } }