| ... | ... |
@@ -48,25 +48,6 @@ type TagStore struct {
|
| 48 | 48 |
// Repository maps tags to image IDs. |
| 49 | 49 |
type Repository map[string]string |
| 50 | 50 |
|
| 51 |
-// Update updates repository mapping with content of repository 'u'. |
|
| 52 |
-func (r Repository) Update(u Repository) {
|
|
| 53 |
- for k, v := range u {
|
|
| 54 |
- r[k] = v |
|
| 55 |
- } |
|
| 56 |
-} |
|
| 57 |
- |
|
| 58 |
-// Contains returns true if the contents of Repository u are wholly contained |
|
| 59 |
-// in Repository r. |
|
| 60 |
-func (r Repository) Contains(u Repository) bool {
|
|
| 61 |
- for k, v := range u {
|
|
| 62 |
- // if u's key is not present in r OR u's key is present, but not the same value |
|
| 63 |
- if rv, ok := r[k]; !ok || (ok && rv != v) {
|
|
| 64 |
- return false |
|
| 65 |
- } |
|
| 66 |
- } |
|
| 67 |
- return true |
|
| 68 |
-} |
|
| 69 |
- |
|
| 70 | 51 |
// TagStoreConfig provides parameters for a new TagStore. |
| 71 | 52 |
type TagStoreConfig struct {
|
| 72 | 53 |
// Graph is the versioned image store |
| ... | ... |
@@ -213,35 +194,6 @@ func (store *TagStore) HasReferences(img *image.Image) bool {
|
| 213 | 213 |
return len(store.ByID()[img.ID]) > 0 |
| 214 | 214 |
} |
| 215 | 215 |
|
| 216 |
-// ImageName returns name of an image, given the image's ID. |
|
| 217 |
-func (store *TagStore) ImageName(id string) string {
|
|
| 218 |
- if names, exists := store.ByID()[id]; exists && len(names) > 0 {
|
|
| 219 |
- return names[0] |
|
| 220 |
- } |
|
| 221 |
- return stringid.TruncateID(id) |
|
| 222 |
-} |
|
| 223 |
- |
|
| 224 |
-// DeleteAll removes images identified by a specific ID from the store. |
|
| 225 |
-func (store *TagStore) DeleteAll(id string) error {
|
|
| 226 |
- names, exists := store.ByID()[id] |
|
| 227 |
- if !exists || len(names) == 0 {
|
|
| 228 |
- return nil |
|
| 229 |
- } |
|
| 230 |
- for _, name := range names {
|
|
| 231 |
- if strings.Contains(name, ":") {
|
|
| 232 |
- nameParts := strings.Split(name, ":") |
|
| 233 |
- if _, err := store.Delete(nameParts[0], nameParts[1]); err != nil {
|
|
| 234 |
- return err |
|
| 235 |
- } |
|
| 236 |
- } else {
|
|
| 237 |
- if _, err := store.Delete(name, ""); err != nil {
|
|
| 238 |
- return err |
|
| 239 |
- } |
|
| 240 |
- } |
|
| 241 |
- } |
|
| 242 |
- return nil |
|
| 243 |
-} |
|
| 244 |
- |
|
| 245 | 216 |
// Delete deletes a repository or a specific tag. If ref is empty, the entire |
| 246 | 217 |
// repository named repoName will be deleted; otherwise only the tag named by |
| 247 | 218 |
// ref will be deleted. |
| ... | ... |
@@ -408,22 +360,6 @@ func (store *TagStore) GetImage(repoName, refOrID string) (*image.Image, error) |
| 408 | 408 |
return nil, nil |
| 409 | 409 |
} |
| 410 | 410 |
|
| 411 |
-// GetRepoRefs returns a map with image IDs as keys, and slices listing |
|
| 412 |
-// repo/tag references as the values. It covers all repositories. |
|
| 413 |
-func (store *TagStore) GetRepoRefs() map[string][]string {
|
|
| 414 |
- store.Lock() |
|
| 415 |
- reporefs := make(map[string][]string) |
|
| 416 |
- |
|
| 417 |
- for name, repository := range store.Repositories {
|
|
| 418 |
- for tag, id := range repository {
|
|
| 419 |
- shortID := stringid.TruncateID(id) |
|
| 420 |
- reporefs[shortID] = append(reporefs[shortID], utils.ImageReference(name, tag)) |
|
| 421 |
- } |
|
| 422 |
- } |
|
| 423 |
- store.Unlock() |
|
| 424 |
- return reporefs |
|
| 425 |
-} |
|
| 426 |
- |
|
| 427 | 411 |
// validateRepoName validates the name of a repository. |
| 428 | 412 |
func validateRepoName(name string) error {
|
| 429 | 413 |
if name == "" {
|