tarball

package
v3.0.2+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2019 License: Apache-2.0 Imports: 19 Imported by: 77

Documentation

Overview

Package tarball provides a way to generate images using one or more layer tarballs and an optional template configuration.

An example:

package main

import (
	"fmt"

	cp "github.com/containers/image/copy"
	"github.com/containers/image/tarball"
	"github.com/containers/image/transports/alltransports"

	imgspecv1 "github.com/containers/image/transports/alltransports"
)

func imageFromTarball() {
	src, err := alltransports.ParseImageName("tarball:/var/cache/mock/fedora-26-x86_64/root_cache/cache.tar.gz")
	// - or -
	// src, err := tarball.Transport.ParseReference("/var/cache/mock/fedora-26-x86_64/root_cache/cache.tar.gz")
	if err != nil {
		panic(err)
	}
	updater, ok := src.(tarball.ConfigUpdater)
	if !ok {
		panic("unexpected: a tarball reference should implement tarball.ConfigUpdater")
	}
	config := imgspecv1.Image{
		Config: imgspecv1.ImageConfig{
			Cmd: []string{"/bin/bash"},
		},
	}
	annotations := make(map[string]string)
	annotations[imgspecv1.AnnotationDescription] = "test image built from a mock root cache"
	err = updater.ConfigUpdate(config, annotations)
	if err != nil {
		panic(err)
	}
	dest, err := alltransports.ParseImageName("docker-daemon:mock:latest")
	if err != nil {
		panic(err)
	}
	err = cp.Image(nil, dest, src, nil)
	if err != nil {
		panic(err)
	}
}

Index

Constants

This section is empty.

Variables

View Source
var (
	// Transport implements the types.ImageTransport interface for "tarball:" images,
	// which are makeshift images constructed using one or more possibly-compressed tar
	// archives.
	Transport = &tarballTransport{}
)

Functions

This section is empty.

Types

type ConfigUpdater

type ConfigUpdater interface {
	ConfigUpdate(config imgspecv1.Image, annotations map[string]string) error
}

ConfigUpdater is an interface that ImageReferences for "tarball" images also implement. It can be used to set values for a configuration, and to set image annotations which will be present in the images returned by the reference's NewImage() or NewImageSource() methods.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL