Documentation
¶
Index ¶
- func BlobSetToProtoBlobs(blobSet BlobSet, options ...ProtoOption) ([]*storagev1beta1.Blob, error)
- func BlobToProto(blob Blob, options ...ProtoOption) (*storagev1beta1.Blob, error)
- func DigestEqual(a Digest, b Digest) bool
- func DigestToProto(digest Digest, options ...ProtoOption) (*storagev1beta1.Digest, error)
- func FileNodeToProto(fileNode FileNode, options ...ProtoOption) (*storagev1beta1.FileNode, error)
- func FileSetToProtoManifestBlobAndBlobs(fileSet FileSet, options ...ProtoOption) (*storagev1beta1.Blob, []*storagev1beta1.Blob, error)
- func ManifestToProtoBlob(manifest Manifest, options ...ProtoOption) (*storagev1beta1.Blob, error)
- func PutFileSetToBucket(ctx context.Context, fileSet FileSet, bucket storage.WriteBucket) error
- type Blob
- type BlobOption
- type BlobSet
- type Digest
- type DigestOption
- type DigestType
- type FileNode
- type FileSet
- type Manifest
- type ProtoOption
- type ProtoValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlobSetToProtoBlobs ¶
func BlobSetToProtoBlobs(blobSet BlobSet, options ...ProtoOption) ([]*storagev1beta1.Blob, error)
BlobSetToProtoBlobs converts the given BlobSet into proto Blobs.
func BlobToProto ¶
func BlobToProto(blob Blob, options ...ProtoOption) (*storagev1beta1.Blob, error)
BlobToProto converts the given Blob to a proto Blob.
func DigestEqual ¶
DigestEqual returns true if the given Digests are considered equal.
If both Digests are nil, this returns true.
This check both the DigestType and Digest value.
func DigestToProto ¶
func DigestToProto(digest Digest, options ...ProtoOption) (*storagev1beta1.Digest, error)
DigestToProto converts the given Digest to a proto Digest.
func FileNodeToProto ¶
func FileNodeToProto(fileNode FileNode, options ...ProtoOption) (*storagev1beta1.FileNode, error)
FileNodeToProto converts the given FileNode to a proto FileNode.
func FileSetToProtoManifestBlobAndBlobs ¶
func FileSetToProtoManifestBlobAndBlobs( fileSet FileSet, options ...ProtoOption, ) (*storagev1beta1.Blob, []*storagev1beta1.Blob, error)
FileSetToProtoManifestBlobAndBlobs converts the given FileSet into a proto Blob representing the Manifest, and a set of Blobs representing the Files.
func ManifestToProtoBlob ¶
func ManifestToProtoBlob(manifest Manifest, options ...ProtoOption) (*storagev1beta1.Blob, error)
ManifestToProtoBlob converts the string representation of the given Manifest into a proto Blob.
The Manifest is assumed to be non-nil.
func PutFileSetToBucket ¶
PutFileSetToBucket writes the FileSet to the given WriteBucket.
Types ¶
type Blob ¶
type Blob interface { // Digest returns the Digest of the Blob. // // Always non-nil. // // NewDigestForContent(bytes.NewReader(blob.Content())) should always match this value. Digest() Digest // Content returns the content of the Blob. // // May be empty. Content() []byte // contains filtered or unexported methods }
Blob is content with its associated Digest.
func ManifestToBlob ¶
ManifestToBlob converts the string representation of the given Manifest into a Blob.
The Manifest is assumed to be non-nil.
func NewBlobForContent ¶
func NewBlobForContent(reader io.Reader, options ...BlobOption) (Blob, error)
NewBlobForContent returns a new Blob for the content as read from the Reader.
The reader is read until io.EOF.
func ProtoToBlob ¶
func ProtoToBlob(protoBlob *storagev1beta1.Blob, options ...ProtoOption) (Blob, error)
ProtoToBlob converts the given proto Blob to a Blob.
Validation is performed to ensure that the Digest matches the computed Digest of the content.
type BlobOption ¶
type BlobOption func(*blobOptions)
BlobOption is an option when constructing a new Blob
func BlobWithDigestType ¶
func BlobWithDigestType(digestType DigestType) BlobOption
BlobWithDigestType returns a new BlobOption sets the DigestType to be used.
The default is DigestTypeShake256.
func BlobWithKnownDigest ¶
func BlobWithKnownDigest(knownDigest Digest) BlobOption
BlobWithKnownDigest returns a new BlobOption that results in validation that the Digest for the new Blob matches an existing known Digest.
type BlobSet ¶
type BlobSet interface { // GetBlob gets the Blob for the given Digest, or nil if no such Blob exists. GetBlob(digest Digest) Blob // Blobs returns the Blobs associated with this BlobSet, ordered by // the sort value of the Digest. // // TODO: The former version of this package returns the Blobs in unspecified // order. We generally try to give a deterministic order in our codebase. There // are schools of arguments both ways, but we'd like to stay consistent. Blobs() []Blob // contains filtered or unexported methods }
BlobSet is a set of deduplicated Blobs.
func ProtoBlobsToBlobSet ¶
func ProtoBlobsToBlobSet(protoBlobs []*storagev1beta1.Blob, options ...ProtoOption) (BlobSet, error)
ProtoBlobsToBlobSet converts the given proto Blobs into a BlobSet.
type Digest ¶
type Digest interface { // String() prints typeString:hexValue. fmt.Stringer // Type returns the type of digest. // Always a valid value. Type() DigestType // Value returns the digest value. // // Always non-empty. Value() []byte // contains filtered or unexported methods }
Digest is a digest of some content.
It consists of a DigestType and a digest value.
func NewDigestForContent ¶
func NewDigestForContent(reader io.Reader, options ...DigestOption) (Digest, error)
NewDigestForContent creates a new Digest based on the given content read from the Reader.
A valid Digest is returned, even in the case of empty content.
The Reader is read until io.EOF.
func ParseDigest ¶
ParseDigest parses a Digest from its string representation.
A Digest string is of the form typeString:hexValue. The string is expected to be non-empty, If not, an error is treutned.
This reverses Digest.String().
func ProtoToDigest ¶
func ProtoToDigest(protoDigest *storagev1beta1.Digest, options ...ProtoOption) (Digest, error)
ProtoToDigest converts the given proto Digest to a Digest.
Validation is performed to ensure the DigestType is known, and the value is a valid digest value for the given DigestType.
type DigestOption ¶
type DigestOption func(*digestOptions)
DigestOption is an option for a new Digest.
func DigestWithDigestType ¶
func DigestWithDigestType(digestType DigestType) DigestOption
DigestWithDigestType returns a new DigestOption that specifies the DigestType to be used.
The default is DigestTypeShake256.
type DigestType ¶
type DigestType int
DigestType is a type of digest.
const ( // DigestTypeShake256 represents the shake256 digest type. // // This is both the default and the only currently-known value for DigestType. DigestTypeShake256 DigestType = iota + 1 )
func ParseDigestType ¶
func ParseDigestType(s string) (DigestType, error)
ParseDigestType parses a DigestType from its string representation.
This reverses DigestType.String().
func (DigestType) String ¶
func (d DigestType) String() string
String prints the string representation of the DigestType.
type FileNode ¶
type FileNode interface { // String encodes the FileNode into its canonical form: // // digestString[SP][SP]path fmt.Stringer // Path returns the Path of the file. // // The path is normalized and non-empty. Path() string // Digest returns the Digest of the file. // // The Digest is always non-nil. Digest() Digest // contains filtered or unexported methods }
FileNode is a path and associated digest.
func NewFileNode ¶
NewFileNode returns a new FileNode.
The path is validated to be normalized and non-empty. The digest is validated to be non-nil.
func ParseFileNode ¶
ParseFileNode parses the FileNode from its string representation.
The string representation is "digestString[SP][SP]path".
This reverses FileNode.String().
func ProtoToFileNode ¶
func ProtoToFileNode(protoFileNode *storagev1beta1.FileNode, options ...ProtoOption) (FileNode, error)
ProtoToFileNode converts the given proto FileNode to a FileNode.
The path is validated to be normalized and non-empty.
type FileSet ¶
type FileSet interface { // Manifest returns the associated Manifest. Manifest() Manifest // BlobSet returns the associated BlobSet. BlobSet() BlobSet // contains filtered or unexported methods }
FileSet is a pair of a Manifest and its associated BlobSet.
This can be read and written from and to a storage.Bucket.
The Manifest is guaranteed to exactly correlate with the Blobs in the BlobSet, that is the Digests of the FileNodes in the Manifest will exactly match the Digests in the Blobs.
func NewFileSet ¶
NewFileSet returns a new FileSet.
Validation is done to ensure the Manifest exactly matches the BlobSet.
func NewFileSetForBucket ¶
NewFileSetForBucket returns a new FileSet for the given ReadBucket.
func ProtoManifestBlobAndBlobsToFileSet ¶
func ProtoManifestBlobAndBlobsToFileSet( protoManifestBlob *storagev1beta1.Blob, protoBlobs []*storagev1beta1.Blob, options ...ProtoOption, ) (FileSet, error)
ProtoManifestBlobAndBlobsToFileSet converts the given manifest Blob and set of Blobs representing the Files into a FileSet.
Validation is done to ensure the Manifest exactly matches the BlobSet.
type Manifest ¶
type Manifest interface { // fmt.Stringer encodes the Manifest into its canonical form, consisting of // an sorted list of paths and their digests, sorted by path. // // See the documentation on FileNode for how FileNodes are encoded. // // An example encoded manifest: // // shake256:cd22db48cf7c274bbffcb5494a854000cd21b074df7c6edabbd0102c4be8d7623e3931560fcda7acfab286ae1d4f506911daa31f223ee159f59ffce0c7acbbaa buf.lock // shake256:3b353aa5aacd11015e8577f16e2c4e7a242ce773d8e3a16806795bb94f76e601b0db9bf42d5e1907fda63303e1fa1c65f1c175ecc025a3ef29c3456ad237ad84 buf.md // shake256:7c88a20cf931702d042a4ddee3fde5de84814544411f1c62dbf435b1b81a12a8866a070baabcf8b5a0d31675af361ccb2d93ddada4cdcc11bab7ea3d8d7c4667 buf.yaml // shake256:9db25155eafd19b36882cff129daac575baa67ee44d1cb1fd3894342b28c72b83eb21aa595b806e9cb5344759bc8308200c5af98e4329aa83014dde99afa903a pet/v1/pet.proto fmt.Stringer // FileNodes returns the set of FileNodes that make up the Manifest. // // The paths of the given FileNodes are guaranteed to be unique. // The iteration order will be the sorted order of the paths. FileNodes() []FileNode // GetDigest gets the Digest for the given path. // // Returns nil if the path does not exist. GetDigest(path string) Digest // contains filtered or unexported methods }
Manifest is a set of FileNodes.
func BlobToManifest ¶
BlobToManifest converts the given Blob representing the string representation of a Manifest into a Manifest.
The Blob is assumed to be non-nil
func NewManifest ¶
NewManifest returns a new Manifest for the given path -> Digest map.
FileNodes are deduplicated upon construction, however if two FileNodes with the same path have different Digests, an error is returned.
func ParseManifest ¶
ParseManifest parses a Manifest from its string representation.
This reverses Manifest.String().
func ProtoBlobToManifest ¶
func ProtoBlobToManifest(protoBlob *storagev1beta1.Blob, options ...ProtoOption) (Manifest, error)
ProtoBlobToManifest converts the given proto Blob representing the string representation of a Manifest into a Manifest.
The proto Blob is assumed to be non-nil
type ProtoOption ¶
type ProtoOption func(*protoOptions)
ProtoOption is an option for a Protobuf conversion function.
func ProtoWithValidator ¶
func ProtoWithValidator(validator ProtoValidator) ProtoOption
ProtoWithValidator says to use the given ProtoValidator.
The default is to use a global instance of *protovalidator.Validator constructed for this package.
type ProtoValidator ¶
ProtoValidator is a validator for Protobuf messages.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package bufcasalpha temporarily converts v1alpha1 API types to new API types.
|
Package bufcasalpha temporarily converts v1alpha1 API types to new API types. |