imageparser

package
v1.16.4 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.
	TagRegexp = match(`[\w][\w.-]{0,127}`)

	// DigestRegexp matches valid digests.
	DigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`)
)

Functions

func SplitHostname

func SplitHostname(name string) (hostname, remoteName string)

SplitHostname splits a repository name(ie: k8s.gcr.io/kube-apiserver) to hostname(k8s.gcr.io) and remotename(kube-apiserver) string.

Types

type Components

type Components struct {
	// contains filtered or unexported fields
}

Components make up a whole image. Basically we presume an image can be made of `[domain][:port][path]<name>[:tag][@sha256:digest]`, ie: fictional.registry.example:10443/karmada/karmada-controller-manager:v1.0.0 or fictional.registry.example:10443/karmada/karmada-controller-manager@sha256:50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c

func Parse

func Parse(image string) (*Components, error)

Parse returns a Components of the given image.

func (*Components) Digest

func (c *Components) Digest() string

Digest returns the digest.

func (*Components) FullRepository

func (c *Components) FullRepository() string

FullRepository returns the whole repository, including hostname if not empty.

func (*Components) Hostname

func (c *Components) Hostname() string

Hostname returns the hostname, as well known as image registry.

func (*Components) RemoveDigest

func (c *Components) RemoveDigest()

RemoveDigest removes the digest.

func (*Components) RemoveHostname

func (c *Components) RemoveHostname()

RemoveHostname removes the hostname.

func (*Components) RemoveRepository

func (c *Components) RemoveRepository()

RemoveRepository removes the repository.

func (*Components) RemoveTag

func (c *Components) RemoveTag()

RemoveTag removes the tag.

func (*Components) RemoveTagOrDigest

func (c *Components) RemoveTagOrDigest()

RemoveTagOrDigest removes tag or digest. Since tag and digest don't co-exist, so remove tag if tag not empty, otherwise remove digest.

func (*Components) Repository

func (c *Components) Repository() string

Repository returns the repository without hostname.

func (*Components) SetDigest

func (c *Components) SetDigest(digest string)

SetDigest sets the digest.

func (*Components) SetHostname

func (c *Components) SetHostname(hostname string)

SetHostname sets the hostname.

func (*Components) SetRepository

func (c *Components) SetRepository(repository string)

SetRepository sets the repository.

func (*Components) SetTag

func (c *Components) SetTag(tag string)

SetTag sets the tag.

func (*Components) SetTagOrDigest

func (c *Components) SetTagOrDigest(input string)

SetTagOrDigest sets image tag or digest by matching the input.

func (Components) String

func (c Components) String() string

String returns the full name of the image, including repository and tag(or digest).

func (*Components) Tag

func (c *Components) Tag() string

Tag returns the tag.

func (*Components) TagOrDigest

func (c *Components) TagOrDigest() string

TagOrDigest returns image tag if not empty otherwise returns image digest.

Jump to

Keyboard shortcuts

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