// NewREST returns a new REST. func NewREST(h tools.EtcdHelper, defaultRegistry imagestream.DefaultRegistry, subjectAccessReviewRegistry subjectaccessreview.Registry) (*REST, *StatusREST) { prefix := "/imagestreams" store := etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &api.ImageStream{} }, NewListFunc: func() runtime.Object { return &api.ImageStreamList{} }, KeyRootFunc: func(ctx kapi.Context) string { return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix) }, KeyFunc: func(ctx kapi.Context, name string) (string, error) { return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name) }, ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.ImageStream).Name, nil }, EndpointName: "imageStream", ReturnDeletedObject: false, Helper: h, } strategy := imagestream.NewStrategy(defaultRegistry, subjectAccessReviewRegistry) rest := &REST{subjectAccessReviewRegistry: subjectAccessReviewRegistry} strategy.ImageStreamGetter = rest statusStore := store statusStore.UpdateStrategy = imagestream.NewStatusStrategy(strategy) store.CreateStrategy = strategy store.UpdateStrategy = strategy store.Decorator = strategy.Decorate rest.store = &store return rest, &StatusREST{store: &statusStore} }
// NewREST returns a new REST. func NewREST(optsGetter restoptions.Getter, defaultRegistry api.DefaultRegistry, subjectAccessReviewRegistry subjectaccessreview.Registry, limitVerifier imageadmission.LimitVerifier) (*REST, *StatusREST, *InternalREST, error) { prefix := "/imagestreams" store := registry.Store{ NewFunc: func() runtime.Object { return &api.ImageStream{} }, // NewListFunc returns an object capable of storing results of an etcd list. NewListFunc: func() runtime.Object { return &api.ImageStreamList{} }, // Produces a path that etcd understands, to the root of the resource // by combining the namespace in the context with the given prefix. KeyRootFunc: func(ctx kapi.Context) string { return registry.NamespaceKeyRootFunc(ctx, prefix) }, // Produces a path that etcd understands, to the resource by combining // the namespace in the context with the given prefix KeyFunc: func(ctx kapi.Context, name string) (string, error) { return registry.NamespaceKeyFunc(ctx, prefix, name) }, // Retrieve the name field of an image ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.ImageStream).Name, nil }, // Used to match objects based on labels/fields for list and watch PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return imagestream.MatchImageStream(label, field) }, QualifiedResource: api.Resource("imagestreams"), ReturnDeletedObject: false, } strategy := imagestream.NewStrategy(defaultRegistry, subjectAccessReviewRegistry, limitVerifier) rest := &REST{Store: &store, subjectAccessReviewRegistry: subjectAccessReviewRegistry} strategy.ImageStreamGetter = rest store.CreateStrategy = strategy store.UpdateStrategy = strategy store.Decorator = strategy.Decorate if err := restoptions.ApplyOptions(optsGetter, &store, prefix); err != nil { return nil, nil, nil, err } statusStore := store statusStore.Decorator = nil statusStore.CreateStrategy = nil statusStore.UpdateStrategy = imagestream.NewStatusStrategy(strategy) internalStore := store internalStrategy := imagestream.NewInternalStrategy(strategy) internalStore.Decorator = nil internalStore.CreateStrategy = internalStrategy internalStore.UpdateStrategy = internalStrategy return rest, &StatusREST{store: &statusStore}, &InternalREST{store: &internalStore}, nil }
// NewREST returns a new REST. func NewREST(s storage.Interface, defaultRegistry imagestream.DefaultRegistry, subjectAccessReviewRegistry subjectaccessreview.Registry) (*REST, *StatusREST, *InternalREST) { prefix := "/imagestreams" store := etcdgeneric.Etcd{ NewFunc: func() runtime.Object { return &api.ImageStream{} }, // NewListFunc returns an object capable of storing results of an etcd list. NewListFunc: func() runtime.Object { return &api.ImageStreamList{} }, // Produces a path that etcd understands, to the root of the resource // by combining the namespace in the context with the given prefix. KeyRootFunc: func(ctx kapi.Context) string { return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix) }, // Produces a path that etcd understands, to the resource by combining // the namespace in the context with the given prefix KeyFunc: func(ctx kapi.Context, name string) (string, error) { return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name) }, // Retrieve the name field of an image ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.ImageStream).Name, nil }, // Used to match objects based on labels/fields for list and watch PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher { return imagestream.MatchImageStream(label, field) }, EndpointName: "imageStream", ReturnDeletedObject: false, Storage: s, } strategy := imagestream.NewStrategy(defaultRegistry, subjectAccessReviewRegistry) rest := &REST{subjectAccessReviewRegistry: subjectAccessReviewRegistry} strategy.ImageStreamGetter = rest statusStore := store statusStore.UpdateStrategy = imagestream.NewStatusStrategy(strategy) internalStore := store internalStrategy := imagestream.NewInternalStrategy(strategy) internalStore.CreateStrategy = internalStrategy internalStore.UpdateStrategy = internalStrategy store.CreateStrategy = strategy store.UpdateStrategy = strategy store.Decorator = strategy.Decorate rest.Etcd = &store return rest, &StatusREST{store: &statusStore}, &InternalREST{store: &internalStore} }
// NewREST returns a new REST. func NewREST(optsGetter restoptions.Getter, defaultRegistry api.DefaultRegistry, subjectAccessReviewRegistry subjectaccessreview.Registry, limitVerifier imageadmission.LimitVerifier) (*REST, *StatusREST, *InternalREST, error) { store := registry.Store{ NewFunc: func() runtime.Object { return &api.ImageStream{} }, // NewListFunc returns an object capable of storing results of an etcd list. NewListFunc: func() runtime.Object { return &api.ImageStreamList{} }, // Retrieve the name field of an image ObjectNameFunc: func(obj runtime.Object) (string, error) { return obj.(*api.ImageStream).Name, nil }, // Used to match objects based on labels/fields for list and watch PredicateFunc: func(label labels.Selector, field fields.Selector) *generic.SelectionPredicate { return imagestream.Matcher(label, field) }, QualifiedResource: api.Resource("imagestreams"), ReturnDeletedObject: false, } rest := &REST{ Store: &store, subjectAccessReviewRegistry: subjectAccessReviewRegistry, } // strategy must be able to load image streams across namespaces during tag verification strategy := imagestream.NewStrategy(defaultRegistry, subjectAccessReviewRegistry, limitVerifier, rest) store.CreateStrategy = strategy store.UpdateStrategy = strategy store.Decorator = strategy.Decorate if err := restoptions.ApplyOptions(optsGetter, &store, true, storage.NoTriggerPublisher); err != nil { return nil, nil, nil, err } statusStrategy := imagestream.NewStatusStrategy(strategy) statusStore := store statusStore.Decorator = nil statusStore.CreateStrategy = nil statusStore.UpdateStrategy = statusStrategy statusREST := &StatusREST{store: &statusStore} internalStore := store internalStrategy := imagestream.NewInternalStrategy(strategy) internalStore.Decorator = nil internalStore.CreateStrategy = internalStrategy internalStore.UpdateStrategy = internalStrategy internalREST := &InternalREST{store: &internalStore} return rest, statusREST, internalREST, nil }