1
0
mirror of https://github.com/regclient/regclient.git synced 2025-07-14 17:20:57 +03:00
Files
regclient/types/blob/common.go
Brandon Mitchell 06a7b6a816 Deprecating redundant methods
Signed-off-by: Brandon Mitchell <git@bmitch.net>
2022-06-26 20:00:47 -04:00

66 lines
1.6 KiB
Go

package blob
import (
"net/http"
// crypto libraries included for go-digest
_ "crypto/sha256"
_ "crypto/sha512"
"github.com/opencontainers/go-digest"
"github.com/regclient/regclient/types"
"github.com/regclient/regclient/types/ref"
)
// Common interface is provided by all Blob implementations
type Common interface {
GetDescriptor() types.Descriptor
Response() *http.Response
RawHeaders() http.Header
// Deprecated: Digest should be replaced by GetDescriptor().Digest
Digest() digest.Digest
// Deprecated: Length should be replaced by GetDescriptor().Size
Length() int64
// Deprecated: MediaType should be replaced by GetDescriptor().MediaType
MediaType() string
}
type common struct {
r ref.Ref
desc types.Descriptor
blobSet bool
rawHeader http.Header
resp *http.Response
}
// GetDescriptor returns the descriptor associated with the blob
func (b *common) GetDescriptor() types.Descriptor {
return b.desc
}
// Digest returns the provided or calculated digest of the blob
func (b *common) Digest() digest.Digest {
return b.desc.Digest
}
// Length returns the provided or calculated length of the blob
func (b *common) Length() int64 {
return b.desc.Size
}
// MediaType returns the Content-Type header received from the registry
func (b *common) MediaType() string {
return b.desc.MediaType
}
// RawHeaders returns the headers received from the registry
func (b *common) RawHeaders() http.Header {
return b.rawHeader
}
// Response returns the response associated with the blob
func (b *common) Response() *http.Response {
return b.resp
}