Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
distribution/blobs.go at master · igrayson/distribution · GitHub
Skip to content
Navigation Menu
Sign in
Products
Platform
GitHub
Repository hosting, code review, and collaboration
Copilot
AI coding agent for tasks, projects and automated work
Build & Ship
Actions
CI/CD and automation
Code Quality
Quality analysis, fixes, and enforcement
Codespaces
Cloud development environments
Secure
Code Security
Vulnerability detection and remediation
Secret Protection
Secret scanning and leak prevention
All Features
Developers
Learn
Documentation
Training
Certifications
Build
Build with Copilot
Customize Copilot
Integrations
Explore
Trending repos
GitHub Sponsors
Events
Changelog
Changelog
Your source for the latest features, improvements, and fixes across GitHub products, all in one place.
Businesses
By Stage
Enterprises
Team
Startups
Nonprofits
By Industry
Healthcare
Financial services
Manufacturing
Government
See all industries
Evaluate GitHub
Why GitHub
Customer Stories
Business insights
Trust Center
Add-ons
GitHub Advanced Security
Enterprise-grade code security
Copilot for business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Resources
Learn & Connect
Documentation
Resource center
Blog
Events & webinars
Community Forum
Customer Stories
Integrations
Support
Customer support
Training
GitHub Status
Company
About
Partners
Changelog
GitHub Universe
GitHub Universe
The event for developers, by developers — talks, workshops, and what’s next for GitHub.
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
igrayson
distribution
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
distribution
/
blobs.go
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
202 lines (169 loc) · 7.44 KB
master
Breadcrumbs
distribution
/
blobs.go
Copy path
Top
File metadata and controls
Code
Blame
202 lines (169 loc) · 7.44 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package
distribution
import
(
"errors"
"fmt"
"io"
"net/http"
"time"
"github.com/docker/distribution/context"
"github.com/docker/distribution/digest"
)
var
(
// ErrBlobExists returned when blob already exists
ErrBlobExists
=
errors
.
New
(
"blob exists"
)
// ErrBlobDigestUnsupported when blob digest is an unsupported version.
ErrBlobDigestUnsupported
=
errors
.
New
(
"unsupported blob digest"
)
// ErrBlobUnknown when blob is not found.
ErrBlobUnknown
=
errors
.
New
(
"unknown blob"
)
// ErrBlobUploadUnknown returned when upload is not found.
ErrBlobUploadUnknown
=
errors
.
New
(
"blob upload unknown"
)
// ErrBlobInvalidLength returned when the blob has an expected length on
// commit, meaning mismatched with the descriptor or an invalid value.
ErrBlobInvalidLength
=
errors
.
New
(
"blob invalid length"
)
)
// ErrBlobInvalidDigest returned when digest check fails.
type
ErrBlobInvalidDigest
struct
{
Digest
digest.
Digest
Reason
error
}
func
(
err
ErrBlobInvalidDigest
)
Error
()
string
{
return
fmt
.
Sprintf
(
"invalid digest for referenced layer: %v, %v"
,
err
.
Digest
,
err
.
Reason
)
}
// Descriptor describes targeted content. Used in conjunction with a blob
// store, a descriptor can be used to fetch, store and target any kind of
// blob. The struct also describes the wire protocol format. Fields should
// only be added but never changed.
type
Descriptor
struct
{
// MediaType describe the type of the content. All text based formats are
// encoded as utf-8.
MediaType
string
`json:"mediaType,omitempty"`
// Size in bytes of content.
Size
int64
`json:"size,omitempty"`
// Digest uniquely identifies the content. A byte stream can be verified
// against against this digest.
Digest
digest.
Digest
`json:"digest,omitempty"`
// NOTE: Before adding a field here, please ensure that all
// other options have been exhausted. Much of the type relationships
// depend on the simplicity of this type.
}
// BlobStatter makes blob descriptors available by digest. The service may
// provide a descriptor of a different digest if the provided digest is not
// canonical.
type
BlobStatter
interface
{
// Stat provides metadata about a blob identified by the digest. If the
// blob is unknown to the describer, ErrBlobUnknown will be returned.
Stat
(
ctx
context.
Context
,
dgst
digest.
Digest
) (
Descriptor
,
error
)
}
// BlobDeleter enables deleting blobs from storage.
type
BlobDeleter
interface
{
Delete
(
ctx
context.
Context
,
dgst
digest.
Digest
)
error
}
// BlobDescriptorService manages metadata about a blob by digest. Most
// implementations will not expose such an interface explicitly. Such mappings
// should be maintained by interacting with the BlobIngester. Hence, this is
// left off of BlobService and BlobStore.
type
BlobDescriptorService
interface
{
BlobStatter
// SetDescriptor assigns the descriptor to the digest. The provided digest and
// the digest in the descriptor must map to identical content but they may
// differ on their algorithm. The descriptor must have the canonical
// digest of the content and the digest algorithm must match the
// annotators canonical algorithm.
//
// Such a facility can be used to map blobs between digest domains, with
// the restriction that the algorithm of the descriptor must match the
// canonical algorithm (ie sha256) of the annotator.
SetDescriptor
(
ctx
context.
Context
,
dgst
digest.
Digest
,
desc
Descriptor
)
error
// Clear enables descriptors to be unlinked
Clear
(
ctx
context.
Context
,
dgst
digest.
Digest
)
error
}
// ReadSeekCloser is the primary reader type for blob data, combining
// io.ReadSeeker with io.Closer.
type
ReadSeekCloser
interface
{
io.
ReadSeeker
io.
Closer
}
// BlobProvider describes operations for getting blob data.
type
BlobProvider
interface
{
// Get returns the entire blob identified by digest along with the descriptor.
Get
(
ctx
context.
Context
,
dgst
digest.
Digest
) ([]
byte
,
error
)
// Open provides a ReadSeekCloser to the blob identified by the provided
// descriptor. If the blob is not known to the service, an error will be
// returned.
Open
(
ctx
context.
Context
,
dgst
digest.
Digest
) (
ReadSeekCloser
,
error
)
}
// BlobServer can serve blobs via http.
type
BlobServer
interface
{
// ServeBlob attempts to serve the blob, identifed by dgst, via http. The
// service may decide to redirect the client elsewhere or serve the data
// directly.
//
// This handler only issues successful responses, such as 2xx or 3xx,
// meaning it serves data or issues a redirect. If the blob is not
// available, an error will be returned and the caller may still issue a
// response.
//
// The implementation may serve the same blob from a different digest
// domain. The appropriate headers will be set for the blob, unless they
// have already been set by the caller.
ServeBlob
(
ctx
context.
Context
,
w
http.
ResponseWriter
,
r
*
http.
Request
,
dgst
digest.
Digest
)
error
}
// BlobIngester ingests blob data.
type
BlobIngester
interface
{
// Put inserts the content p into the blob service, returning a descriptor
// or an error.
Put
(
ctx
context.
Context
,
mediaType
string
,
p
[]
byte
) (
Descriptor
,
error
)
// Create allocates a new blob writer to add a blob to this service. The
// returned handle can be written to and later resumed using an opaque
// identifier. With this approach, one can Close and Resume a BlobWriter
// multiple times until the BlobWriter is committed or cancelled.
Create
(
ctx
context.
Context
) (
BlobWriter
,
error
)
// Resume attempts to resume a write to a blob, identified by an id.
Resume
(
ctx
context.
Context
,
id
string
) (
BlobWriter
,
error
)
}
// BlobWriter provides a handle for inserting data into a blob store.
// Instances should be obtained from BlobWriteService.Writer and
// BlobWriteService.Resume. If supported by the store, a writer can be
// recovered with the id.
type
BlobWriter
interface
{
io.
WriteSeeker
io.
ReaderFrom
io.
Closer
// ID returns the identifier for this writer. The ID can be used with the
// Blob service to later resume the write.
ID
()
string
// StartedAt returns the time this blob write was started.
StartedAt
() time.
Time
// Commit completes the blob writer process. The content is verified
// against the provided provisional descriptor, which may result in an
// error. Depending on the implementation, written data may be validated
// against the provisional descriptor fields. If MediaType is not present,
// the implementation may reject the commit or assign "application/octet-
// stream" to the blob. The returned descriptor may have a different
// digest depending on the blob store, referred to as the canonical
// descriptor.
Commit
(
ctx
context.
Context
,
provisional
Descriptor
) (
canonical
Descriptor
,
err
error
)
// Cancel ends the blob write without storing any data and frees any
// associated resources. Any data written thus far will be lost. Cancel
// implementations should allow multiple calls even after a commit that
// result in a no-op. This allows use of Cancel in a defer statement,
// increasing the assurance that it is correctly called.
Cancel
(
ctx
context.
Context
)
error
// Get a reader to the blob being written by this BlobWriter
Reader
() (io.
ReadCloser
,
error
)
}
// BlobService combines the operations to access, read and write blobs. This
// can be used to describe remote blob services.
type
BlobService
interface
{
BlobStatter
BlobProvider
BlobIngester
}
// BlobStore represent the entire suite of blob related operations. Such an
// implementation can access, read, write, delete and serve blobs.
type
BlobStore
interface
{
BlobService
BlobServer
BlobDeleter
}
You can’t perform that action at this time.