public class DockerAccessWithHcClient extends Object implements DockerAccess
The design goal here is to provide only the functionality required for this plugin in order to make it as robust as possible against docker API changes (which happen quite frequently). That's also the reason, why no framework like JAX-RS or docker-java is used so that the dependencies are kept low.
Of course, it's a bit more manual work, but it's worth the effort (as long as the Docker API functionality required is not too much).| Modifier and Type | Field and Description |
|---|---|
static String |
API_VERSION |
| Constructor and Description |
|---|
DockerAccessWithHcClient(String baseUrl,
String certPath,
int maxConnections,
org.eclipse.jkube.kit.common.KitLogger log)
Create a new access for the given URL
|
| Modifier and Type | Method and Description |
|---|---|
void |
buildImage(String image,
File dockerArchive,
BuildOptions options)
Create a docker image from a given archive
|
String |
fetchApiVersionFromServer(String baseUrl,
ApacheHttpClientDelegate delegate) |
String |
getImageId(String name)
Get the image id of a given name or
null if no such image exists |
boolean |
hasImage(String name)
Check whether the given name exists as image at the docker daemon
|
void |
loadImage(String image,
File tarArchive)
Load an image from an archive.
|
void |
pullImage(String image,
AuthConfig authConfig,
String registry,
CreateImageOptions options)
Pull an image from a remote registry and store it locally.
|
void |
pushImage(String image,
AuthConfig authConfig,
String registry,
int retries)
Push an image to a registry.
|
boolean |
removeImage(String image,
boolean... forceOpt)
Remove an image from this docker installation
|
void |
saveImage(String image,
String filename,
org.eclipse.jkube.kit.common.archive.ArchiveCompression compression)
Save an image to a tar file
|
void |
shutdown()
Lifecycle method which must be called when this object is not needed anymore.
|
void |
start()
Lifecycle method for this access class which must be called before any other method is called.
|
void |
tag(String sourceImage,
String targetImage,
boolean force)
Alias an image in the repository with a complete new name.
|
public static final String API_VERSION
public DockerAccessWithHcClient(String baseUrl, String certPath, int maxConnections, org.eclipse.jkube.kit.common.KitLogger log) throws IOException
baseUrl - base URL for accessing the docker DaemoncertPath - used to build up a keystore with the given keys and certificates found in this
directorymaxConnections - maximum parallel connections allowed to docker daemon (if a pool is used)log - a log handler for printing out logging informationIOException - in case of I/O exceptionpublic void buildImage(String image, File dockerArchive, BuildOptions options) throws DockerAccessException
DockerAccessbuildImage in interface DockerAccessimage - name of the image to build or null if none should be useddockerArchive - from which the docker image should be buildoptions - additional query arguments to add when building the image. Can be null.DockerAccessException - if docker host reports an error during building of an imagepublic boolean hasImage(String name) throws DockerAccessException
DockerAccesshasImage in interface DockerAccessname - image name to checkDockerAccessException - docker access exceptionpublic String getImageId(String name) throws DockerAccessException
DockerAccessnull if no such image existsgetImageId in interface DockerAccessname - name to lookupnullDockerAccessException - docker access exceptionpublic void loadImage(String image, File tarArchive) throws DockerAccessException
DockerAccessloadImage in interface DockerAccessimage - the image to pull.tarArchive - archive fileDockerAccessException - if the image couldn't be loaded.public void pullImage(String image, AuthConfig authConfig, String registry, CreateImageOptions options) throws DockerAccessException
DockerAccesspullImage in interface DockerAccessimage - the image to pull.authConfig - authentication configuration used when pulling an imageregistry - an optional registry from where to pull the image. Can be null.options - additional query arguments to add when creating the image. Can be null.DockerAccessException - if the image couldn't be pulled.public void pushImage(String image, AuthConfig authConfig, String registry, int retries) throws DockerAccessException
DockerAccesspushImage in interface DockerAccessimage - image name to pushauthConfig - authentication configurationregistry - optional registry to which the image should be pushed.retries - optional number of times the push should be retried on a 500 errorDockerAccessException - in case pushing failspublic void saveImage(String image, String filename, org.eclipse.jkube.kit.common.archive.ArchiveCompression compression) throws DockerAccessException
DockerAccesssaveImage in interface DockerAccessimage - image to savefilename - target filenamecompression - compression to use for the archiveDockerAccessException - if an image cannot be removedpublic void tag(String sourceImage, String targetImage, boolean force) throws DockerAccessException
DockerAccesstag in interface DockerAccesssourceImage - full name (including tag) of the image to aliastargetImage - the alias nameforce - forced taggingDockerAccessException - if the original image doesn't exist or another error occurs somehow.public boolean removeImage(String image, boolean... forceOpt) throws DockerAccessException
DockerAccessremoveImage in interface DockerAccessimage - image to removeforceOpt - if set to true remove containers as well (only the first vararg is evaluated)DockerAccessException - if an image cannot be removedpublic void start()
DockerAccessstart in interface DockerAccesspublic void shutdown()
DockerAccessshutdown in interface DockerAccesspublic String fetchApiVersionFromServer(String baseUrl, ApacheHttpClientDelegate delegate) throws IOException
IOExceptionCopyright © 2024. All rights reserved.