mirror of
https://github.com/regclient/regclient.git
synced 2025-07-29 09:01:11 +03:00
Blob type linting and docs
Signed-off-by: Brandon Mitchell <git@bmitch.net>
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
// Package blob is the underlying type for pushing and pulling blobs
|
||||
package blob
|
||||
|
||||
import (
|
||||
@ -14,7 +15,7 @@ type Blob interface {
|
||||
RawBody() ([]byte, error)
|
||||
}
|
||||
|
||||
type BlobConfig struct {
|
||||
type blobConfig struct {
|
||||
desc ociv1.Descriptor
|
||||
header http.Header
|
||||
image ociv1.Image
|
||||
@ -23,36 +24,46 @@ type BlobConfig struct {
|
||||
resp *http.Response
|
||||
}
|
||||
|
||||
type Opts func(*BlobConfig)
|
||||
type Opts func(*blobConfig)
|
||||
|
||||
// WithDesc specifies the descriptor associated with the blob
|
||||
func WithDesc(d ociv1.Descriptor) Opts {
|
||||
return func(bc *BlobConfig) {
|
||||
return func(bc *blobConfig) {
|
||||
bc.desc = d
|
||||
}
|
||||
}
|
||||
|
||||
// WithHeader defines the headers received when pulling a blob
|
||||
func WithHeader(header http.Header) Opts {
|
||||
return func(bc *BlobConfig) {
|
||||
return func(bc *blobConfig) {
|
||||
bc.header = header
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// WithImage provides the OCI Image config needed for config blobs
|
||||
func WithImage(image ociv1.Image) Opts {
|
||||
return func(bc *BlobConfig) {
|
||||
return func(bc *blobConfig) {
|
||||
bc.image = image
|
||||
}
|
||||
}
|
||||
|
||||
// WithReader defines the reader for a new blob
|
||||
func WithReader(rc io.Reader) Opts {
|
||||
return func(bc *BlobConfig) {
|
||||
return func(bc *blobConfig) {
|
||||
bc.rdr = rc
|
||||
}
|
||||
}
|
||||
|
||||
// WithRef specifies the reference where the blob was pulled from
|
||||
func WithRef(r ref.Ref) Opts {
|
||||
return func(bc *BlobConfig) {
|
||||
return func(bc *blobConfig) {
|
||||
bc.r = r
|
||||
}
|
||||
}
|
||||
|
||||
// WithResp includes the http response, which is used to extract the headers and reader
|
||||
func WithResp(resp *http.Response) Opts {
|
||||
return func(bc *BlobConfig) {
|
||||
return func(bc *blobConfig) {
|
||||
bc.resp = resp
|
||||
if bc.header == nil {
|
||||
bc.header = resp.Header
|
||||
|
Reference in New Issue
Block a user