diff options
author | Jeff Johnston | 2017-05-15 20:55:56 +0000 |
---|---|---|
committer | Jeff Johnston | 2017-05-17 17:06:30 +0000 |
commit | 9cdc1bc3deacf3d0d050bf482108c0750a6f2c66 (patch) | |
tree | 762826c28eca621de6136651322f577eaf97e3aa | |
parent | 17693f9a9085ee1513c6ae5023837dd7494c8883 (diff) | |
download | org.eclipse.linuxtools-9cdc1bc3deacf3d0d050bf482108c0750a6f2c66.tar.gz org.eclipse.linuxtools-9cdc1bc3deacf3d0d050bf482108c0750a6f2c66.tar.xz org.eclipse.linuxtools-9cdc1bc3deacf3d0d050bf482108c0750a6f2c66.zip |
Bug 516683 - Add method to get container changes in DockerConnection
- add containerChanges method to IDockerConnection
- add containerChanges method to DockerConnection
- add new IDockerContainerChange interface
- add new DockerContainerChange class
Change-Id: Ib21c7f1dd912ad7dcec8e3da264082b10d851d45
Reviewed-on: https://git.eclipse.org/r/97145
Tested-by: Hudson CI
Reviewed-by: Jeff Johnston <jjohnstn@redhat.com>
4 files changed, 95 insertions, 0 deletions
diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java index 4566d9e98d..a321e70280 100644 --- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java +++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerConnection.java @@ -438,4 +438,19 @@ public interface IDockerConnection { final OutputStream err) throws DockerException, InterruptedException, IOException; + /** + * Get list of changes to filesystem for a Container. + * + * @param id + * id of container + * @return list of IDockerChange instances + * @throws DockerException + * in case of underlying problem (server error) + * @throws InterruptedException + * if the operation is interrupted + * @since 3.0 + */ + public List<IDockerContainerChange> containerChanges(final String id) + throws DockerException, InterruptedException; + } diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerContainerChange.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerContainerChange.java new file mode 100644 index 0000000000..521c552c8e --- /dev/null +++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/docker/core/IDockerContainerChange.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2017 Red Hat. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - Initial Contribution + *******************************************************************************/ +package org.eclipse.linuxtools.docker.core; + +/** + * @since 3.0 + */ +public interface IDockerContainerChange { + + enum ChangeKind { + MODIFY, ADD, DELETE + } + + String path(); + + ChangeKind kind(); + +} diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java index 2ed229b3af..a390ee671d 100644 --- a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java +++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerConnection.java @@ -63,6 +63,7 @@ import org.eclipse.linuxtools.docker.core.IDockerConnectionInfo; import org.eclipse.linuxtools.docker.core.IDockerConnectionSettings; import org.eclipse.linuxtools.docker.core.IDockerConnectionSettings.BindingType; import org.eclipse.linuxtools.docker.core.IDockerContainer; +import org.eclipse.linuxtools.docker.core.IDockerContainerChange; import org.eclipse.linuxtools.docker.core.IDockerContainerConfig; import org.eclipse.linuxtools.docker.core.IDockerContainerExit; import org.eclipse.linuxtools.docker.core.IDockerContainerInfo; @@ -101,6 +102,7 @@ import com.spotify.docker.client.exceptions.DockerCertificateException; import com.spotify.docker.client.exceptions.DockerTimeoutException; import com.spotify.docker.client.messages.AuthConfig; import com.spotify.docker.client.messages.Container; +import com.spotify.docker.client.messages.ContainerChange; import com.spotify.docker.client.messages.ContainerConfig; import com.spotify.docker.client.messages.ContainerCreation; import com.spotify.docker.client.messages.ContainerExit; @@ -1816,6 +1818,23 @@ public class DockerConnection return stream; } + @Override + public List<IDockerContainerChange> containerChanges(final String id) + throws DockerException, InterruptedException { + List<IDockerContainerChange> containerChanges = new ArrayList<>(); + try { + DockerClient copy = getClientCopy(); + List<ContainerChange> changes = copy.inspectContainerChanges(id); + for (ContainerChange change : changes) { + containerChanges.add(new DockerContainerChange(change.path(), + change.kind())); + } + } catch (com.spotify.docker.client.exceptions.DockerException e) { + throw new DockerException(e.getMessage(), e.getCause()); + } + return containerChanges; + } + public boolean isLocal() { if (isLocalConnection != null) return isLocalConnection.booleanValue(); diff --git a/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainerChange.java b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainerChange.java new file mode 100644 index 0000000000..617d62ba3f --- /dev/null +++ b/containers/org.eclipse.linuxtools.docker.core/src/org/eclipse/linuxtools/internal/docker/core/DockerContainerChange.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2017 Red Hat. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Red Hat - Initial Contribution + *******************************************************************************/ +package org.eclipse.linuxtools.internal.docker.core; + +import org.eclipse.linuxtools.docker.core.IDockerContainerChange; + +public class DockerContainerChange implements IDockerContainerChange { + + private String path; + private ChangeKind changeKind; + + public DockerContainerChange(String path, Integer kind) { + this.path = path; + this.changeKind = ChangeKind.values()[kind.intValue()]; + } + + @Override + public String path() { + return path; + } + + @Override + public ChangeKind kind() { + return changeKind; + } + +} |