Class BuildContext
- java.lang.Object
-
- com.google.cloud.tools.jib.configuration.BuildContext
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class BuildContext extends java.lang.Object implements java.io.Closeable
Build context for the builder process. Includes static build configuration options as well as various services for execution (such as event dispatching, thread execution service, and HTTP client). Informational instances (particularly configuration options such asContainerConfiguration
,ImageConfiguration
, andFileEntriesLayer
) held in are immutable.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BuildContext.Builder
Builds an immutableBuildContext
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BuildContext.Builder
builder()
Creates a newBuildContext.Builder
to build aBuildContext
.void
close()
com.google.common.collect.ImmutableSet<java.lang.String>
getAllTargetImageTags()
Returns all image tags configured for this build.boolean
getAlwaysCacheBaseImage()
Gets whether or not to force caching the base images.Cache
getApplicationLayersCache()
Gets theCache
for application layers.ImageConfiguration
getBaseImageConfiguration()
Cache
getBaseImageLayersCache()
Gets theCache
for base image layers.ContainerConfiguration
getContainerConfiguration()
boolean
getEnablePlatformTags()
EventHandlers
getEventHandlers()
java.util.concurrent.ExecutorService
getExecutorService()
com.google.common.collect.ImmutableList<com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer>
getLayerConfigurations()
Gets the configurations for building the layers.com.google.common.collect.ImmutableListMultimap<java.lang.String,java.lang.String>
getRegistryMirrors()
Gets the registry mirrors.java.lang.Class<? extends BuildableManifestTemplate>
getTargetFormat()
ImageConfiguration
getTargetImageConfiguration()
java.lang.String
getToolName()
java.lang.String
getToolVersion()
boolean
isOffline()
Gets whether or not to run the build in offline mode.RegistryClient.Factory
newBaseImageRegistryClientFactory()
Creates a newRegistryClient.Factory
for the base image with fields from the build configuration.RegistryClient.Factory
newBaseImageRegistryClientFactory(java.lang.String serverUrl)
Creates a newRegistryClient.Factory
for the base image repository on the registryserverUrl
.RegistryClient.Factory
newTargetImageRegistryClientFactory()
Creates a newRegistryClient.Factory
for the target image with fields from the build configuration.
-
-
-
Method Detail
-
builder
public static BuildContext.Builder builder()
Creates a newBuildContext.Builder
to build aBuildContext
.- Returns:
- a new
BuildContext.Builder
-
getBaseImageConfiguration
public ImageConfiguration getBaseImageConfiguration()
-
getEnablePlatformTags
public boolean getEnablePlatformTags()
-
getTargetImageConfiguration
public ImageConfiguration getTargetImageConfiguration()
-
getAllTargetImageTags
public com.google.common.collect.ImmutableSet<java.lang.String> getAllTargetImageTags()
Returns all image tags configured for this build.- Returns:
- the set of image tags configured for this build
-
getContainerConfiguration
public ContainerConfiguration getContainerConfiguration()
-
getTargetFormat
public java.lang.Class<? extends BuildableManifestTemplate> getTargetFormat()
-
getToolName
public java.lang.String getToolName()
-
getToolVersion
@Nullable public java.lang.String getToolVersion()
-
getEventHandlers
public EventHandlers getEventHandlers()
-
getExecutorService
public java.util.concurrent.ExecutorService getExecutorService()
-
getBaseImageLayersCache
public Cache getBaseImageLayersCache()
Gets theCache
for base image layers.- Returns:
- the
Cache
for base image layers
-
getApplicationLayersCache
public Cache getApplicationLayersCache()
Gets theCache
for application layers.- Returns:
- the
Cache
for application layers
-
isOffline
public boolean isOffline()
Gets whether or not to run the build in offline mode.- Returns:
true
if the build will run in offline mode;false
otherwise
-
getAlwaysCacheBaseImage
public boolean getAlwaysCacheBaseImage()
Gets whether or not to force caching the base images.- Returns:
true
if the user wants to force the build to always pull the image layers.
-
getLayerConfigurations
public com.google.common.collect.ImmutableList<com.google.cloud.tools.jib.api.buildplan.FileEntriesLayer> getLayerConfigurations()
Gets the configurations for building the layers.- Returns:
- the list of layer configurations
-
getRegistryMirrors
public com.google.common.collect.ImmutableListMultimap<java.lang.String,java.lang.String> getRegistryMirrors()
Gets the registry mirrors.- Returns:
- the registry mirrors
-
newBaseImageRegistryClientFactory
public RegistryClient.Factory newBaseImageRegistryClientFactory()
Creates a newRegistryClient.Factory
for the base image with fields from the build configuration. The server URL is derived from the baseImageConfiguration
.- Returns:
- a new
RegistryClient.Factory
-
newBaseImageRegistryClientFactory
public RegistryClient.Factory newBaseImageRegistryClientFactory(java.lang.String serverUrl)
Creates a newRegistryClient.Factory
for the base image repository on the registryserverUrl
. Compared to @link #newBaseImageRegistryClientFactory()), this method is useful to try a mirror.- Parameters:
serverUrl
- the server URL for the registry (for example,gcr.io
)- Returns:
- a new
RegistryClient.Factory
-
newTargetImageRegistryClientFactory
public RegistryClient.Factory newTargetImageRegistryClientFactory()
Creates a newRegistryClient.Factory
for the target image with fields from the build configuration.- Returns:
- a new
RegistryClient.Factory
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-