forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest.go
45 lines (38 loc) · 1.35 KB
/
rest.go
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
package imagerepositorytag
import (
kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/openshift/origin/pkg/image/api"
"github.com/openshift/origin/pkg/image/registry/imagestreamtag"
)
// REST implements the RESTStorage interface for ImageRepositoryTag.
type REST struct {
imageStreamTagRegistry imagestreamtag.Registry
}
// NewREST returns a new REST.
func NewREST(r imagestreamtag.Registry) *REST {
return &REST{r}
}
// New is only implemented to make REST implement RESTStorage
func (r *REST) New() runtime.Object {
return &api.Image{}
}
// Get retrieves an image that has been tagged by repo and tag. `id` is of the format
// <repo name>:<tag>.
func (r *REST) Get(ctx kapi.Context, id string) (runtime.Object, error) {
ist, err := r.imageStreamTagRegistry.GetImageStreamTag(ctx, id)
if err != nil {
return nil, err
}
irt := api.ImageRepositoryTag{}
if err := kapi.Scheme.Convert(ist, &irt); err != nil {
return nil, err
}
return &irt, nil
}
// Delete removes a tag from a repo. `id` is of the format <repo name>:<tag>.
// The associated image that the tag points to is *not* deleted.
// The tag history remains intact and is not deleted.
func (r *REST) Delete(ctx kapi.Context, id string) (runtime.Object, error) {
return r.imageStreamTagRegistry.DeleteImageStreamTag(ctx, id)
}