-
Notifications
You must be signed in to change notification settings - Fork 0
/
registry.go
40 lines (33 loc) · 1.18 KB
/
registry.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
package imagestreammapping
import (
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/runtime"
"github.com/openshift/origin/pkg/image/api"
)
// Registry is an interface for things that know how to store ImageStreamMapping objects.
type Registry interface {
// CreateImageStreamMapping creates a new image stream mapping.
CreateImageStreamMapping(ctx kapi.Context, mapping *api.ImageStreamMapping) (*unversioned.Status, error)
}
// Storage is an interface for a standard REST Storage backend
type Storage interface {
Create(ctx kapi.Context, obj runtime.Object) (runtime.Object, error)
}
// storage puts strong typing around storage calls
type storage struct {
Storage
}
// NewRegistry returns a new Registry interface for the given Storage. Any mismatched
// types will panic.
func NewRegistry(s Storage) Registry {
return &storage{s}
}
// CreateImageStreamMapping will create an image stream mapping.
func (s *storage) CreateImageStreamMapping(ctx kapi.Context, mapping *api.ImageStreamMapping) (*unversioned.Status, error) {
obj, err := s.Create(ctx, mapping)
if err != nil {
return nil, err
}
return obj.(*unversioned.Status), nil
}