tarball

package
v5.36.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: Apache-2.0 Imports: 22 Imported by: 6 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 (
	"context"

	cp "github.com/containers/image/v5/copy"
	"github.com/containers/image/v5/signature"
	"github.com/containers/image/v5/tarball"
	"github.com/containers/image/v5/transports/alltransports"
	"github.com/containers/image/v5/types"
	imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
)

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)
	}

	policy, err := signature.DefaultPolicy(nil)
	if err != nil {
		panic(err)
	}

	pc, err := signature.NewPolicyContext(policy)
	if err != nil {
		panic(err)
	}
	defer pc.Destroy()
	_, err = cp.Image(context.TODO(), pc, 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

func NewReference added in v5.3.0

func NewReference(fileNames []string, stdin []byte) (types.ImageReference, error)

NewReference creates a new "tarball:" reference for the listed fileNames. If any of the fileNames is "-", the contents of stdin are used instead.

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