Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // AllDigestTypes are all known DigestTypes. AllDigestTypes = []DigestType{ DigestTypeP1, } )
Functions ¶
func DigestEqual ¶ added in v1.47.0
DigestEqual returns true if the given Digests are considered equal.
If both Digests are nil, this returns true.
This checks both the DigestType and Digest value.
Types ¶
type Commit ¶ added in v1.47.0
type Commit interface {
// PluginKey returns the PluginKey for the Commit.
PluginKey() PluginKey
// CreateTime returns the time the Commit was created on the BSR.
CreateTime() (time.Time, error)
// contains filtered or unexported methods
}
Commit represents a Commit for a Plugin on the BSR.
type Digest ¶ added in v1.47.0
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 NewDigest ¶ added in v1.47.0
func NewDigest(digestType DigestType, bufcasDigest bufcas.Digest) (Digest, error)
NewDigest creates a new Digest.
func ParseDigest ¶ added in v1.47.0
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 returned.
This reverses Digest.String().
Returns an error of type *bufparse.ParseError if the string could not be parsed.
type DigestMismatchError ¶ added in v1.47.0
type DigestMismatchError struct {
FullName bufparse.FullName
CommitID uuid.UUID
ExpectedDigest Digest
ActualDigest Digest
}
DigestMismatchError is the error returned if the Digest of a downloaded Plugin or Commit does not match the expected digest in a buf.lock file.
func (*DigestMismatchError) Error ¶ added in v1.47.0
func (m *DigestMismatchError) Error() string
Error implements the error interface.
type DigestType ¶ added in v1.47.0
type DigestType int
DigestType is a type of digest.
const ( // DigestTypeP1 represents the p1 plugin digest type. // // The string value of this is "p1". DigestTypeP1 DigestType = iota + 1 )
func ParseDigestType ¶ added in v1.47.0
func ParseDigestType(s string) (DigestType, error)
ParseDigestType parses a DigestType from its string representation.
This reverses DigestType.String().
Returns an error of type *bufparse.ParseError if the string could not be parsed.
func (DigestType) String ¶ added in v1.47.0
func (d DigestType) String() string
String prints the string representation of the DigestType.
type PluginData ¶ added in v1.47.0
type PluginData interface {
// PluginKey used to downoad this PluginData.
//
// The Digest from this PluginKey is used for tamper-proofing. It will be checked
// against the actual data downloaded before Data() returns.
PluginKey() PluginKey
// Data returns the bytes of the Plugin as a Wasm module.
//
// This is the raw bytes of the Wasm module in an uncompressed form.
Data() ([]byte, error)
// contains filtered or unexported methods
}
PluginData presents the raw Plugin data read by PluginKey.
A PluginData generally represents the data on a Plugin read from the BSR API or a cache.
Tamper-proofing is done as part of every function.
func NewPluginData ¶ added in v1.47.0
func NewPluginData( ctx context.Context, pluginKey PluginKey, getData func() ([]byte, error), ) (PluginData, error)
NewPluginData returns a new PluginData.
getData is expected to be lazily-loaded function where possible.
type PluginDataProvider ¶ added in v1.47.0
type PluginDataProvider interface {
// GetPluginDatasForPluginKeys gets the PluginDatas for the PluginKeys.
//
// Returned PluginDatas will be in the same order as the input PluginKeys.
//
// The input PluginKeys are expected to be unique by FullName. The implementation
// may error if this is not the case.
//
// The input PluginKeys are expected to have the same DigestType. The implementation
// may error if this is not the case.
//
// If there is no error, the length of the PluginDatas returned will match the length of the PluginKeys.
// If there is an error, no PluginDatas will be returned.
// If any PluginKey is not found, an error with fs.ErrNotExist will be returned.
GetPluginDatasForPluginKeys(
context.Context,
[]PluginKey,
) ([]PluginData, error)
}
PluginDataProvider provides PluginsDatas.
var ( // NopPluginDataProvider is a no-op PluginDataProvider. NopPluginDataProvider PluginDataProvider = nopPluginDataProvider{} )
type PluginKey ¶ added in v1.47.0
type PluginKey interface {
// String returns "registry/owner/name:dashlessCommitID".
fmt.Stringer
// FullName returns the full name of the Plugin.
//
// Always present.
FullName() bufparse.FullName
// CommitID returns the ID of the Commit.
//
// It is up to the caller to convert this to a dashless ID when necessary.
//
// Always present, that is CommitID() == uuid.Nil will always be false.
CommitID() uuid.UUID
// Digest returns the Plugin digest.
//
// Note this is *not* a bufcas.Digest - this is a Digest.
// bufcas.Digests are a lower-level type that just deal in terms of
// files and content. A PluginDigest is a specific algorithm applied to
// the Plugin data.
Digest() (Digest, error)
// contains filtered or unexported methods
}
PluginKey provides identifying information for a Plugin.
PluginKeys are returned from PluginKeyProviders, and represent a Plugin's complete identity. They also match to what we store in buf.lock files. PluginKeys can be used to get Plugins via a PluginProvider.
func NewPluginKey ¶ added in v1.47.0
func NewPluginKey( pluginFullName bufparse.FullName, commitID uuid.UUID, getDigest func() (Digest, error), ) (PluginKey, error)
NewPluginKey returns a new PluginKey.
The Digest will be loaded lazily if needed. Note this means that NewPluginKey does *not* validate the digest. If you need to validate the digset, call Digest() and evaluate the returned error.
type PluginKeyProvider ¶ added in v1.47.0
type PluginKeyProvider interface {
// GetPluginKeysForPluginRefs gets the PluginKets for the given PluginRefs.
//
// Returned PluginKeys will be in the same order as the input PluginRefs.
//
// The input PluginRefs are expected to be unique by FullName. The implementation
// may error if this is not the case.
//
// If there is no error, the length of the PluginKeys returned will match the length of the Refs.
// If there is an error, no PluginKeys will be returned.
// If any PluginRef is not found, an error with fs.ErrNotExist will be returned.
GetPluginKeysForPluginRefs(context.Context, []bufparse.Ref, DigestType) ([]PluginKey, error)
}
PluginKeyProvider provides PluginKeys for bufparse.Refs.
var ( // NopPluginKeyProvider is a no-op PluginKeyProvider. NopPluginKeyProvider PluginKeyProvider = nopPluginKeyProvider{} )