utils

package
v0.0.0-...-02e5558 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxSize int64

MaxSize defines the max supported file size

Functions

func DigestManifest

func DigestManifest(data []byte) (string, error)

DigestManifest gets the real digest content of a docker manifest

func FromReader

func FromReader(rd io.Reader) (string, error)

FromReader gets the digest from an io.Reader

func GetDigest

func GetDigest(alg string, data []byte) string

GetDigest gets the digest value from an algrithm and a data value

func Payload

func Payload(data []byte) ([]byte, error)

Payload gets the playload of a docker manifest file

func Snap

func Snap(digestFull string) (string, string)

Snap gets the digest value of a full digest string TODO: lots of todo, need to verify the digest

Types

type Algorithm

type Algorithm string

Algorithm identifies and implementation of a digester by an identifier. Note the that this defines both the hash algorithm used and the string encoding.

const (
	SHA256         Algorithm = "sha256"           // sha256 with hex encoding
	SHA384         Algorithm = "sha384"           // sha384 with hex encoding
	SHA512         Algorithm = "sha512"           // sha512 with hex encoding
	TarsumV1SHA256 Algorithm = "tarsum+v1+sha256" // supported tarsum version, verification only

	// Canonical is the primary digest algorithm used with the distribution
	// project. Other digests may be used but this one is the primary storage
	// digest.
	Canonical = SHA256
)

supported digest types

func (Algorithm) Available

func (a Algorithm) Available() bool

Available returns true if the digest type is available for use. If this returns false, New and Hash will return nil.

func (Algorithm) Hash

func (a Algorithm) Hash() hash.Hash

Hash gets the hash of an algorithm

func (Algorithm) New

func (a Algorithm) New() Digester

New creates a new digester

type Digester

type Digester interface {
	Hash() hash.Hash // provides direct access to underlying hash instance.
	Digest() string
}

Digester defines a Hash and Digest operation

Jump to

Keyboard shortcuts

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