-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHE-4197: Apply CHE_DOCKER_ALWAYS__PULL__IMAGE to container creation (#…
- Loading branch information
Mykola Morhun
committed
May 18, 2017
1 parent
9ba1c22
commit 064fdcb
Showing
8 changed files
with
260 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...er-client/src/main/java/org/eclipse/che/plugin/docker/client/params/ListImagesParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* 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: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.docker.client.params; | ||
|
||
import org.eclipse.che.plugin.docker.client.json.Filters; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Arguments holder for {@link org.eclipse.che.plugin.docker.client.DockerConnector#listImages(ListImagesParams)}. | ||
* | ||
* @author Mykola Morhun | ||
*/ | ||
public class ListImagesParams { | ||
|
||
private Boolean all; | ||
private Filters filters; | ||
private Boolean digests; | ||
|
||
/** | ||
* Creates arguments holder. | ||
*/ | ||
public static ListImagesParams create() { | ||
return new ListImagesParams(); | ||
} | ||
|
||
private ListImagesParams() {} | ||
|
||
/** | ||
* Adds all flag to this parameters. | ||
* | ||
* @param all | ||
* if true show all images. | ||
* Only images from a final layer (no children) are shown by default. | ||
* @return this params instance | ||
*/ | ||
public ListImagesParams withAll(Boolean all) { | ||
this.all = all; | ||
return this; | ||
} | ||
|
||
/** | ||
* Adds filters to this parameters. | ||
* | ||
* @param filters | ||
* Available filters: | ||
* <ul> | ||
* <li><code>before</code>=(<code><image-name>[:<tag>]</code>, <code><image id></code> or <code><image@digest></code>)</li> | ||
* <li><code>dangling=true</code></li> | ||
* <li><code>label=key</code> or <code>label="key=value"</code> of an image label</li> | ||
* <li><code>reference</code>=(<code><image-name>[:<tag>]</code>)</li> | ||
* <li><code>since</code>=(<code><image-name>[:<tag>]</code>, <code><image id></code> or <code><image@digest></code>)</li> | ||
* </ul> | ||
* @return this params instance | ||
*/ | ||
public ListImagesParams withFilters(Filters filters) { | ||
this.filters = filters; | ||
return this; | ||
} | ||
|
||
/** | ||
* Adds all flag to this parameters. | ||
* | ||
* @param digests | ||
* if true show digest information on each image | ||
* @return this params instance | ||
*/ | ||
public ListImagesParams withDigestst(Boolean digests) { | ||
this.digests = digests; | ||
return this; | ||
} | ||
|
||
public Boolean getAll() { | ||
return all; | ||
} | ||
|
||
public Filters getFilters() { | ||
return filters; | ||
} | ||
|
||
public Boolean getDigests() { | ||
return digests; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
ListImagesParams that = (ListImagesParams)o; | ||
return Objects.equals(all, that.all) && | ||
Objects.equals(filters, that.filters) && | ||
Objects.equals(digests, that.digests); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(all, filters, digests); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...lient/src/test/java/org/eclipse/che/plugin/docker/client/params/ListImagesParamsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2012-2017 Codenvy, S.A. | ||
* 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: | ||
* Codenvy, S.A. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.che.plugin.docker.client.params; | ||
|
||
import org.eclipse.che.plugin.docker.client.json.Filters; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
/** | ||
* @author Mykola Morhun | ||
*/ | ||
public class ListImagesParamsTest { | ||
|
||
private static final boolean WITH_ALL = true; | ||
private static final boolean WITH_DIGEST = true; | ||
private static final Filters FILTERS = new Filters().withFilter("reference", "imageName"); | ||
|
||
private ListImagesParams listImagesParams; | ||
|
||
@Test | ||
public void shouldCreateParamsObjectWithAllPossibleParameters() { | ||
listImagesParams = ListImagesParams.create() | ||
.withAll(WITH_ALL) | ||
.withDigestst(WITH_DIGEST) | ||
.withFilters(FILTERS); | ||
|
||
assertTrue(listImagesParams.getAll() == WITH_ALL); | ||
assertTrue(listImagesParams.getDigests() == WITH_DIGEST); | ||
assertEquals(listImagesParams.getFilters(), FILTERS); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.