Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@
<version>${hamcrest.jpa-matchers}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<distributionManagement>
Expand Down
85 changes: 76 additions & 9 deletions src/main/java/com/github/dockerjava/api/command/BuildImageCmd.java
Original file line number Diff line number Diff line change
@@ -1,44 +1,95 @@
package com.github.dockerjava.api.command;

import java.io.File;
import java.io.InputStream;

import com.github.dockerjava.api.model.AuthConfigurations;
import com.github.dockerjava.api.model.BuildResponseItem;

import javax.annotation.CheckForNull;
import java.io.File;
import java.io.InputStream;
import java.net.URI;

/**
*
* Build an image from Dockerfile.
*
* <p>
* TODO: http://docs.docker.com/reference/builder/#dockerignore
*
* @see <a href="https://docs.docker.com/reference/api/docker_remote_api_v1.20/#build-image-from-a-dockerfile">build-image-from-a-dockerfile</a>
*/
public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildResponseItem> {

public BuildImageCmd withTag(String tag);
// lib specific

public InputStream getTarInputStream();

public AuthConfigurations getBuildAuthConfigs();

// getters

/**
* "t" in API
*/
@CheckForNull
public String getTag();

/**
* "remote" in API
*/
@CheckForNull
public URI getRemote();

/**
* "nocache" in API
*/
public boolean hasNoCacheEnabled();

/**
* "rm" in API
*/
public boolean hasRemoveEnabled();

/**
* "forcerm" in API
*/
public boolean isForcerm();

@CheckForNull
public Boolean getForcerm();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a primitive here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because somebody can set it to null with setter to exclude this parameter from remote call at all.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you switched from objects back to primitives again. As I see all other boolean properties use primitives.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched only existed to keep compatibility, other values are new and i decided to make them as Objects to have "not defined" state (i.e. if remote API wouldn't return some values). I think it should also help keeping backward compatibility with constantly changing remote API versions.


/**
* "q" in API
*/
public boolean isQuiet();

/**
* "pull" in API
*/
public boolean hasPullEnabled();

@CheckForNull
public String getPathToDockerfile();

public AuthConfigurations getBuildAuthConfigs();
@CheckForNull
public Long getMemory();

@CheckForNull
public Long getMemswap();

@CheckForNull
public String getCpushares();

@CheckForNull
public String getCpusetcpus();

// setters

public BuildImageCmd withTag(String tag);

public BuildImageCmd withRemote(URI remote);

public BuildImageCmd withBaseDirectory(File baseDirectory);

public BuildImageCmd withDockerfile(File dockerfile);

public BuildImageCmd withTarInputStream(InputStream tarInputStream);

public BuildImageCmd withNoCache();

public BuildImageCmd withNoCache(boolean noCache);
Expand All @@ -47,6 +98,10 @@ public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildRespon

public BuildImageCmd withRemove(boolean rm);

public BuildImageCmd withForcerm();

public BuildImageCmd withForcerm(Boolean forcerm);

public BuildImageCmd withQuiet();

public BuildImageCmd withQuiet(boolean quiet);
Expand All @@ -55,8 +110,20 @@ public interface BuildImageCmd extends AsyncDockerCmd<BuildImageCmd, BuildRespon

public BuildImageCmd withPull(boolean pull);

public BuildImageCmd withMemory(long memory);

public BuildImageCmd withMemswap(long memswap);

public BuildImageCmd withCpushares(String cpushares);

public BuildImageCmd withCpusetcpus(String cpusetcpus);

// setters lib specific

public BuildImageCmd withBuildAuthConfigs(AuthConfigurations authConfig);

public BuildImageCmd withTarInputStream(InputStream tarInputStream);

public static interface Exec extends DockerCmdAsyncExec<BuildImageCmd, BuildResponseItem> {
}

Expand Down
Loading