|
| 1 | +// Copyright 2016 The Linux Foundation |
| 2 | +// |
| 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 | +// Package refs implements generic name-based reference access. |
| 16 | +package refs |
| 17 | + |
| 18 | +import ( |
| 19 | + "github.com/opencontainers/image-spec/image/structure" |
| 20 | +) |
| 21 | + |
| 22 | +// Engine represents a name-based reference storage engine. |
| 23 | +type Engine interface { |
| 24 | + |
| 25 | + // Put adds a new reference to the store. |
| 26 | + Put(name string, descriptor *structure.Descriptor) (err error) |
| 27 | + |
| 28 | + // Get returns a reference from the store. |
| 29 | + Get(name string) (descriptor *structure.Descriptor, err error) |
| 30 | + |
| 31 | + // List returns a slice of available names from the store. |
| 32 | + // |
| 33 | + // Results are sorted alphabetically. |
| 34 | + // |
| 35 | + // Arguments: |
| 36 | + // |
| 37 | + // * prefix: limits the result set to names starting with that |
| 38 | + // value. |
| 39 | + // * size: limits the length of the result set to the first 'size' |
| 40 | + // matches. A value of -1 means "all results". |
| 41 | + // * from: shifts the result set to start from the 'from'th match. |
| 42 | + // |
| 43 | + // For example, a store with names like: |
| 44 | + // |
| 45 | + // * 123 |
| 46 | + // * abcd |
| 47 | + // * abce |
| 48 | + // * abcf |
| 49 | + // * abcg |
| 50 | + // |
| 51 | + // will have the following call/result pairs: |
| 52 | + // |
| 53 | + // * List("", -1, 0) -> ["123", "abcd", "abce", "abcf", "abcg"]. |
| 54 | + // * List("", 2, 0) -> ["123", "abcd"] |
| 55 | + // * List("", 2, 1) -> ["abcd", "abce"] |
| 56 | + // * List("abc", 2, 1) -> ["abce", "abcf"]. |
| 57 | + List(prefix string, size int, from int) (names []string, err error) |
| 58 | + |
| 59 | + // Delete removes a reference from the store. |
| 60 | + Delete(name string) (err error) |
| 61 | + |
| 62 | + // Close releases resources held by the engine. Subsequent engine |
| 63 | + // method calls will fail. |
| 64 | + Close() (err error) |
| 65 | +} |
0 commit comments