Documentation ¶
Overview ¶
Copyright 2015 The Bazel Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. //////////////////////////////////////////////////////////////////// Reads an legacy image layout on disk.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OverrideImageConfig ¶ added in v0.10.0
func OverrideImageConfig(overrideInfo *OverrideConfigOpts) error
OverrideImageConfig updates the current image config file to reflect the given changes and writes out the updated image config to the file specified in the given options.
func ReadImage ¶ added in v0.10.0
func ReadImage(parts ImageParts) (v1.Image, error)
ReadImage loads a v1.Image from the given ImageParts
func WriteImage ¶ added in v0.10.0
WriteImage writes the given image to the given directory in the efficient rules_docker intermediate format:
After calling this, the following filesystem will exist:
directory/
config.json <-- only *.json, the image's config digest <-- sha256 digest of the image's manifest manifest.json <-- the image's manifest 001.tar.gz <-- the first layer's .tar.gz filesystem delta 001.sha256 <-- the sha256 of 1.tar.gz without the "sha256:" prefix. ... N.tar.gz <-- the Nth layer's .tar.gz filesystem delta N.sha256 <-- the sha256 of N.tar.gz without the "sha256:" prefix.
We pad layer indices to only 3 digits because of a known ceiling on the number of filesystem layers Docker supports.
Types ¶
type ImageParts ¶ added in v0.10.0
type ImageParts struct { // Config is the path to the image config. Config string // BaseManifest is the path to the manifest of the base image. BaseManifest string // ImageTarball is the path to the image tarball whose layers can // be extended by the layers in LayerParts. ImageTarball string // Images are the v1.Images whose layers can be extended by the layers in // LayerParts. Images []v1.Image // Layers are the parts of layers in the image defined by this object. Layers []LayerParts }
ImageParts contains paths to a Docker image config and the individual layer parts.
func ImagePartsFromArgs ¶ added in v0.10.0
func ImagePartsFromArgs(config, baseManifest, imgTarball string, layers []string) (ImageParts, error)
ImagePartsFromArgs is a convenience function to convert string arguments defining the parts of an image: config is the path to the image config. baseManifest is the path to the manifest of the first image in the chain of images. imgTarball is the path to the image tarball. This will be used as the base image if one or more layers are specified. layers are strings where each item has the format val1,val2,val3,val4 where:
val1 is the compressed layer tarball. val2 is the uncompressed layer tarball. val3 is the digest file. val4 is the diffID file.
to an ImageParts object.
type LayerParts ¶ added in v0.10.0
type LayerParts struct { // CompressedTarball is the path to the compressed layer tarball. CompressedTarball string // UncompressedTarball is the path to the uncompressed layer tarball. UncompressedTarball string // DigestFile is the path to a file containing the sha256 digest of the // compressed layer. DigestFile string // DiffIDFile is the path to a file containing the sha256 digest of the // uncompressed layer. DiffIDFile string }
LayerParts contains paths to the components needed to fully describe a docker image layer.
func LayerPartsFromString ¶ added in v0.10.0
func LayerPartsFromString(val string) (LayerParts, error)
LayerPartsFromString constructs a LayerParts object from a string in the format val1,val2,val3,val4 where: val1 is the compressed layer tarball. val2 is the uncompressed layer tarball. val3 is the digest file. val4 is the diffID file.
type OverrideConfigOpts ¶ added in v0.10.0
type OverrideConfigOpts struct { // ConfigFile is the base config.json file. ConfigFile *v1.ConfigFile // OutputConfig is where to write the modified config file to. OutputConfig string // CreationTimeString is the creation timestamp. // Accepted in integer or floating point seconds since Unix Epoch, RFC3339 date/time. CreationTimeString string // User is the username to run the commands under. User string // Workdir is the working directory to set for the layer. Workdir string // NullEntrypoint indicates if there is an entrypoint. // If true, Entrypoint will be set to null. NullEntryPoint bool // NullCmd indicates if there is a command. // If true, Command will be set to null. NullCmd bool // Architecture is the architecture of the docker image Architecture string // OperatingSystem is the operating system to creater docker image for. OperatingSystem string // OSVersion is the operating system version to creater docker image for. OSVersion string // CreatedBy is the command that generated the image. Default // "bazel build ...". CreatedBy string // Author is the author of the image. Default bazel. Author string // LabelsArray is the labels used to augment those of the previous layer. LabelsArray []string // Ports are the ports used to augment those of the previous layer. Ports []string // Volumes are the volumes used to augment those of the previous layer. Volumes []string // EntrypointPrefix is the prefix to the entrypoint with the specified arguments. EntrypointPrefix []string // Env are the environments to augment those of the previous layer. Env []string // Command are the command(s) to override those of the previous layer. Command []string // Entrypoint are the new entrypoints to override entrypoint of previous layer. Entrypoint []string // Layer is the list of layer sha256 hashes that compose the image for which the config is written. Layer []string // Stamper will be used to stamp values in the image config. Stamper *Stamper }
OverrideConfigOpts holds all configuration settings for the newly outputted config file.
type Reader ¶ added in v0.20.0
type Reader struct { // parts is the ImageParts being loaded. Parts ImageParts // contains filtered or unexported fields }
Reader maintains the state necessary to build a legacyImage object from an ImageParts object.
type Stamper ¶ added in v0.10.0
type Stamper struct {
// contains filtered or unexported fields
}
Stamper provides functionality to stamp a given string based on key value pairs from a stamp info text file. Each stamp info text file can specify key value pairs in the following format: KEY1 VALUE1 KEY2 VALUE2 ... This will result in the stamper making the following substitutions in the specified order: {KEY1} -> VALUE1 {KEY2} -> VALUE2 ...
func NewStamper ¶ added in v0.10.0
NewStamper creates a Stamper object initialized to stamp strings with the key value pairs in the given stamp info files.