image

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GetName = func(i string) (string, error) {
	ref, err := name.ParseReference(i)
	if err != nil {
		return "", fmt.Errorf("error parsing image %s: %v", i, err)
	}

	if ref.Context().RegistryStr() == name.DefaultRegistry {
		suffix := strings.SplitN(ref.Name(), i, 2)[1]
		return i + suffix, nil
	}

	return ref.Name(), nil
}

GetName returns the fullname of the image

View Source
var GetNameSlug = func(i string) (string, error) {
	name, err := GetName(i)
	if err != nil {
		return "", err
	}
	return util.Slugify(name), nil
}

GetNameSlug returns the slugified fullname of the image

View Source
var GetNamesFromTarball = func(path string) ([]string, error) {
	opener := func() (io.ReadCloser, error) {
		return os.Open(path)
	}

	manifest, err := tarball.LoadManifest(opener)
	if err != nil {
		return nil, fmt.Errorf("error loading manifest from tarball: %v", err)
	}

	var repoTags []string
	for _, descriptor := range manifest {
		if len(descriptor.RepoTags) > 0 {
			repoTags = append(repoTags, descriptor.RepoTags...)
		}
	}

	if len(repoTags) == 0 {
		logrus.Debugf("No repository tags found in manifest of %s", path)
		return nil, nil
	}

	return repoTags, nil
}

GetNamesFromTarball is a helper function to get the image names from a tarball

View Source
var Load = load

Load loads the image from a tarball.

Functions

func Extract added in v1.5.0

func Extract(img *Image, rootfs string, ignore ...string) error

Types

type GetConf added in v0.5.0

type GetConf struct {
	File             string
	Image            string
	RegistryMirror   string
	RegistryPassword string
	RegistryUsername string
	CacheDir         string
	Update           bool
	Save             bool
}

func (*GetConf) Get added in v0.5.0

func (conf *GetConf) Get() (*Image, error)

func (*GetConf) Pull added in v1.0.0

func (conf *GetConf) Pull() (*Image, error)

Pull pulls the image using both provided credentials and the default keychain.

type Image

type Image struct {
	Image v1.Image
	Name  string
	File  string
}

Image represents a pulled container image

func New added in v1.0.0

func New(ref name.Reference, src, dst string, config v1.Config) (*Image, error)

func (*Image) Config added in v0.3.0

func (img *Image) Config(file ...string) (v1.ConfigFile, error)

Config pulls an image and returns its config

func (*Image) Save added in v0.3.0

func (img *Image) Save(path string) error

Save saves the full image to a tarball.

Jump to

Keyboard shortcuts

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