Debian Codegraph @

content/storage.go

raw symbols SCIP
1 /*
2 Copyright The ORAS Authors.
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 */
15
16 package contentscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/
17
18 import (
19 "contextscip-go gomod github.com/golang/go/src go1.23.0 context/"
20 "ioscip-go gomod github.com/golang/go/src go1.23.0 io/"
21
22 ocispecscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/ "github.com/opencontainers/image-spec/specs-go/v1scip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/"
23 )
24
25 // Fetcher fetches content.
26 type Fetcherscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Fetcher# interface {
27 // Fetch fetches the content identified by the descriptor.
28 Fetchscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Fetcher#Fetch.(ctx contextscip-go gomod github.com/golang/go/src go1.23.0 context/.Contextscip-go gomod github.com/golang/go/src go1.23.0 context/Context#, target ocispecscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/.Descriptorscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/Descriptor#) (ioscip-go gomod github.com/golang/go/src go1.23.0 io/.ReadCloserscip-go gomod github.com/golang/go/src go1.23.0 io/ReadCloser#, error)
29 }
30
31 // Pusher pushes content.
32 type Pusherscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Pusher# interface {
33 // Push pushes the content, matching the expected descriptor.
34 // Reader is preferred to Writer so that the suitable buffer size can be
35 // chosen by the underlying implementation. Furthermore, the implementation
36 // can also do reflection on the Reader for more advanced I/O optimization.
37 Pushscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Pusher#Push.(ctx contextscip-go gomod github.com/golang/go/src go1.23.0 context/.Contextscip-go gomod github.com/golang/go/src go1.23.0 context/Context#, expected ocispecscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/.Descriptorscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/Descriptor#, content ioscip-go gomod github.com/golang/go/src go1.23.0 io/.Readerscip-go gomod github.com/golang/go/src go1.23.0 io/Reader#) error
38 }
39
40 // Storage represents a content-addressable storage (CAS) where contents are
41 // accessed via Descriptors.
42 // The storage is designed to handle blobs of large sizes.
43 type Storagescip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Storage# interface {
44 ReadOnlyStoragescip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/ReadOnlyStorage#
45 Pusherscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Pusher#
46 }
47
48 // ReadOnlyStorage represents a read-only Storage.
49 type ReadOnlyStoragescip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/ReadOnlyStorage# interface {
50 Fetcherscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Fetcher#
51
52 // Exists returns true if the described content exists.
53 Existsscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/ReadOnlyStorage#Exists.(ctx contextscip-go gomod github.com/golang/go/src go1.23.0 context/.Contextscip-go gomod github.com/golang/go/src go1.23.0 context/Context#, target ocispecscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/.Descriptorscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/Descriptor#) (bool, error)
54 }
55
56 // Deleter removes content.
57 // Deleter is an extension of Storage.
58 type Deleterscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Deleter# interface {
59 // Delete removes the content identified by the descriptor.
60 Deletescip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Deleter#Delete.(ctx contextscip-go gomod github.com/golang/go/src go1.23.0 context/.Contextscip-go gomod github.com/golang/go/src go1.23.0 context/Context#, target ocispecscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/.Descriptorscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/Descriptor#) error
61 }
62
63 // FetchAll safely fetches the content described by the descriptor.
64 // The fetched content is verified against the size and the digest.
65 func FetchAllscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/FetchAll().(ctx contextscip-go gomod github.com/golang/go/src go1.23.0 context/.Contextscip-go gomod github.com/golang/go/src go1.23.0 context/Context#, fetcher Fetcherscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Fetcher#, desc ocispecscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/.Descriptorscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/Descriptor#) ([]byte, error) {
66 rc, err := fetcher.Fetchscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/Fetcher#Fetch.(ctx, desc)
67 if err != nil {
68 return nil, err
69 }
70 defer rc.Closescip-go gomod github.com/golang/go/src go1.23.0 io/Closer#Close().()
71 return ReadAllscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/ReadAll().(rc, desc)
72 }
73
74 // FetcherFunc is the basic Fetch method defined in Fetcher.
75 type FetcherFuncscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/FetcherFunc# func(ctx contextscip-go gomod github.com/golang/go/src go1.23.0 context/.Contextscip-go gomod github.com/golang/go/src go1.23.0 context/Context#, target ocispecscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/.Descriptorscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/Descriptor#) (ioscip-go gomod github.com/golang/go/src go1.23.0 io/.ReadCloserscip-go gomod github.com/golang/go/src go1.23.0 io/ReadCloser#, error)
76
77 // Fetch performs Fetch operation by the FetcherFunc.
78 func (fn FetcherFuncscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/FetcherFunc#) Fetchscip-go gomod oras.land/oras-go/v2 . `oras.land/oras-go/v2/content`/FetcherFunc#Fetch().(ctx contextscip-go gomod github.com/golang/go/src go1.23.0 context/.Contextscip-go gomod github.com/golang/go/src go1.23.0 context/Context#, target ocispecscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/.Descriptorscip-go gomod github.com/opencontainers/image-spec v1.1.1 `github.com/opencontainers/image-spec/specs-go/v1`/Descriptor#) (ioscip-go gomod github.com/golang/go/src go1.23.0 io/.ReadCloserscip-go gomod github.com/golang/go/src go1.23.0 io/ReadCloser#, error) {
79 return fn(ctx, target)
80 }