util

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ImageNameLabel     = "containerd.io/snapshot/remote/starlight/imageName.label"
	ImageTagLabel      = "containerd.io/snapshot/remote/starlight/imageTag.label"
	OptimizeLabel      = "containerd.io/snapshot/remote/starlight/optimize.label"
	OptimizeGroupLabel = "containerd.io/snapshot/remote/starlight/optimizeGroup.label"

	ProxyLabel       = "containerd.io/snapshot/remote/starlight/proxy"
	SnapshotterLabel = "containerd.io/gc.ref.snapshot.starlight"

	UserRwLayerText = "containerd.io/layer/user-rw-layer"

	StarlightTOCDigestAnnotation       = "containerd.io/snapshot/remote/starlight/toc.digest"
	StarlightTOCCreationTimeAnnotation = "containerd.io/snapshot/remote/starlight/toc.timestamp"

	// ImageMediaTypeManifestV2 for containerd image TYPE field
	ImageMediaTypeManifestV2 = "application/vnd.docker.distribution.manifest.v2+json"

	// ImageLabelPuller and ImageLabelStarlightMetadata are labels for containerd image
	ImageLabelPuller            = "puller.containerd.io"
	ImageLabelStarlightMetadata = "metadata.starlight.mc256.dev"

	// ContentLabelStarlightMediaType is the media type of the content, can be manifest, config, or starlight
	ContentLabelStarlightMediaType = "mediaType.starlight.mc256.dev"
	// ContentLabelContainerdGC prevents containerd from removing the content
	ContentLabelContainerdGC = "containerd.io/gc.ref.content"
	ContentLabelSnapshotGC   = "containerd.io/gc.ref.snapshot.starlight"
	ContentLabelCompletion   = "complete.starlight.mc256.dev"

	// ---------------------------------------------------------------------------------
	// Snapshot labels have a prefix of "containerd.io/snapshot/"
	// or are the "containerd.io/snapshot.ref" label.
	// SnapshotLabelRefImage is the digest of the image manifest
	SnapshotLabelRefImage        = "containerd.io/snapshot/starlight.ref.image"
	SnapshotLabelRefUncompressed = "containerd.io/snapshot/starlight.ref.uncompressed"
	SnapshotLabelRefLayer        = "containerd.io/snapshot/starlight.ref.layer"

	// find the project root directory
	ProjectIdentifier = "module github.com/mc256/starlight"
)

Variables

View Source
var Version = "0.0.0"

Functions

func BToInt32

func BToInt32(v []byte) uint32

func BToInt64

func BToInt64(v []byte) uint64

func ConfigLogger

func ConfigLogger() (ctx context.Context)

func ConfigLoggerWithLevel

func ConfigLoggerWithLevel(level string) (ctx context.Context)

func ExportToJsonFile

func ExportToJsonFile(v interface{}, p string) error

func FindProjectRoot added in v0.2.0

func FindProjectRoot() string

FindProjectRoot returns the root directory of the Git project if exists. otherwise, it returns os.Getwd(). To identify whether a directory is a root directory, it check the `go.mod` file please making sure the first line of the go mode file is: ``` module github.com/mc256/starlight ```

func GetEtcConfigPath added in v0.2.0

func GetEtcConfigPath() string

GetEtcConfigPath return a path to the configuration json

func GetRandomId added in v0.2.0

func GetRandomId(prefix string) string

func Int32ToB

func Int32ToB(v uint32) []byte

func Int64ToB

func Int64ToB(v uint64) []byte

func NewStarlightLayer added in v0.2.0

func NewStarlightLayer(f *os.File, stargzWriter *common.Writer) (goreg.Layer, error)

NewStarlightLayer mainly populate the hash values for the StarlightLayer object

func OpenDatabase

func OpenDatabase(ctx context.Context, dbPath string) (*bolt.DB, error)

func VersionAction

func VersionAction(context *cli.Context) error

func VersionCommand

func VersionCommand() *cli.Command

Types

type Convertor added in v0.2.0

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

func NewConvertor added in v0.2.0

func NewConvertor(ctx context.Context, src, dst string, optsSrc, dstSrc []name.Option, optsRemote []remote.Option, platforms string) (c *Convertor, err error)

func (*Convertor) GetDst added in v0.2.0

func (c *Convertor) GetDst() name.Reference

func (*Convertor) GetSrc added in v0.2.0

func (c *Convertor) GetSrc() name.Reference

func (*Convertor) String added in v0.4.4

func (c *Convertor) String() string

func (*Convertor) ToStarlightImage added in v0.2.0

func (c *Convertor) ToStarlightImage() (err error)

type CountWriter

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

func NewCountWriter

func NewCountWriter(w io.Writer) (cw *CountWriter)

func (*CountWriter) GetWrittenSize

func (c *CountWriter) GetWrittenSize() int64

func (*CountWriter) Write

func (c *CountWriter) Write(p []byte) (n int, err error)

type DigestWriter added in v0.2.0

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

func NewDigestWriter added in v0.2.0

func NewDigestWriter(w io.Writer) (dw *DigestWriter)

func (*DigestWriter) GetDigest added in v0.2.0

func (d *DigestWriter) GetDigest() []byte

func (*DigestWriter) Write added in v0.2.0

func (d *DigestWriter) Write(p []byte) (n int, err error)

type StarlightLayer added in v0.2.0

type StarlightLayer struct {
	R io.Reader

	// Diff is the hash of the uncompressed layer
	Diff goreg.Hash
	// Hash is the hash of the compressed layer
	Hash goreg.Hash

	SizeVal int64
}

func (StarlightLayer) Compressed added in v0.2.0

func (l StarlightLayer) Compressed() (io.ReadCloser, error)

func (StarlightLayer) DiffID added in v0.2.0

func (l StarlightLayer) DiffID() (goreg.Hash, error)

func (StarlightLayer) Digest added in v0.2.0

func (l StarlightLayer) Digest() (goreg.Hash, error)

func (StarlightLayer) MediaType added in v0.2.0

func (l StarlightLayer) MediaType() (types.MediaType, error)

func (StarlightLayer) Size added in v0.2.0

func (l StarlightLayer) Size() (int64, error)

func (StarlightLayer) Uncompressed added in v0.2.0

func (l StarlightLayer) Uncompressed() (io.ReadCloser, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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