Пример #1
0
// NewREST returns a registry which will store ThirdPartyResource in the given helper
func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator) *REST {
	prefix := "/thirdpartyresources"

	// We explicitly do NOT do any decoration here yet.
	storageInterface := s

	store := &etcdgeneric.Etcd{
		NewFunc:     func() runtime.Object { return &extensions.ThirdPartyResource{} },
		NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceList{} },
		KeyRootFunc: func(ctx api.Context) string {
			return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
		},
		KeyFunc: func(ctx api.Context, id string) (string, error) {
			return etcdgeneric.NamespaceKeyFunc(ctx, prefix, id)
		},
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*extensions.ThirdPartyResource).Name, nil
		},
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return thirdpartyresource.Matcher(label, field)
		},
		QualifiedResource: extensions.Resource("thirdpartyresources"),
		CreateStrategy:    thirdpartyresource.Strategy,
		UpdateStrategy:    thirdpartyresource.Strategy,

		Storage: storageInterface,
	}

	return &REST{store}
}
Пример #2
0
// NewREST returns a registry which will store ThirdPartyResource in the given helper
func NewREST(s storage.Interface) *REST {
	prefix := "/thirdpartyresources"

	store := &etcdgeneric.Etcd{
		NewFunc:     func() runtime.Object { return &expapi.ThirdPartyResource{} },
		NewListFunc: func() runtime.Object { return &expapi.ThirdPartyResourceList{} },
		KeyRootFunc: func(ctx api.Context) string {
			return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
		},
		KeyFunc: func(ctx api.Context, id string) (string, error) {
			return etcdgeneric.NamespaceKeyFunc(ctx, prefix, id)
		},
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*expapi.ThirdPartyResource).Name, nil
		},
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return thirdpartyresource.Matcher(label, field)
		},
		EndpointName:   "thirdPartyResources",
		CreateStrategy: thirdpartyresource.Strategy,
		UpdateStrategy: thirdpartyresource.Strategy,

		Storage: s,
	}

	return &REST{store}
}
Пример #3
0
// NewREST returns a registry which will store ThirdPartyResource in the given helper
func NewREST(opts generic.RESTOptions) *REST {
	prefix := "/thirdpartyresources"

	// We explicitly do NOT do any decoration here yet.
	storageInterface := opts.Storage

	store := &registry.Store{
		NewFunc:     func() runtime.Object { return &extensions.ThirdPartyResource{} },
		NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceList{} },
		KeyRootFunc: func(ctx api.Context) string {
			return prefix
		},
		KeyFunc: func(ctx api.Context, id string) (string, error) {
			return registry.NoNamespaceKeyFunc(ctx, prefix, id)
		},
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*extensions.ThirdPartyResource).Name, nil
		},
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return thirdpartyresource.Matcher(label, field)
		},
		QualifiedResource:       extensions.Resource("thirdpartyresources"),
		DeleteCollectionWorkers: opts.DeleteCollectionWorkers,
		CreateStrategy:          thirdpartyresource.Strategy,
		UpdateStrategy:          thirdpartyresource.Strategy,
		DeleteStrategy:          thirdpartyresource.Strategy,

		Storage: storageInterface,
	}

	return &REST{store}
}