Beispiel #1
0
// NewREST returns a RESTStorage object that will work against replication controllers.
func NewREST(opts generic.RESTOptions) (*REST, *StatusREST) {
	prefix := "/ingress"

	newListFunc := func() runtime.Object { return &extensions.IngressList{} }
	storageInterface := opts.Decorator(
		opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.Ingress), &extensions.Ingress{}, prefix, ingress.Strategy, newListFunc)

	store := &registry.Store{
		NewFunc: func() runtime.Object { return &extensions.Ingress{} },

		// NewListFunc returns an object capable of storing results of an etcd list.
		NewListFunc: newListFunc,
		// Produces a ingress that etcd understands, to the root of the resource
		// by combining the namespace in the context with the given prefix
		KeyRootFunc: func(ctx api.Context) string {
			return registry.NamespaceKeyRootFunc(ctx, prefix)
		},
		// Produces a ingress that etcd understands, to the resource by combining
		// the namespace in the context with the given prefix
		KeyFunc: func(ctx api.Context, name string) (string, error) {
			return registry.NamespaceKeyFunc(ctx, prefix, name)
		},
		// Retrieve the name field of a replication controller
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*extensions.Ingress).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 ingress.MatchIngress(label, field)
		},
		QualifiedResource:       extensions.Resource("ingresses"),
		DeleteCollectionWorkers: opts.DeleteCollectionWorkers,

		// Used to validate controller creation
		CreateStrategy: ingress.Strategy,

		// Used to validate controller updates
		UpdateStrategy: ingress.Strategy,
		DeleteStrategy: ingress.Strategy,

		Storage: storageInterface,
	}
	statusStore := *store
	statusStore.UpdateStrategy = ingress.StatusStrategy
	return &REST{store}, &StatusREST{store: &statusStore}
}
Beispiel #2
0
// NewREST returns a RESTStorage object that will work against replication controllers.
func NewREST(s storage.Interface) (*REST, *StatusREST) {
	store := &etcdgeneric.Etcd{
		NewFunc: func() runtime.Object { return &extensions.Ingress{} },

		// NewListFunc returns an object capable of storing results of an etcd list.
		NewListFunc: func() runtime.Object { return &extensions.IngressList{} },
		// Produces a ingress that etcd understands, to the root of the resource
		// by combining the namespace in the context with the given prefix
		KeyRootFunc: func(ctx api.Context) string {
			return etcdgeneric.NamespaceKeyRootFunc(ctx, IngressPath)
		},
		// Produces a ingress that etcd understands, to the resource by combining
		// the namespace in the context with the given prefix
		KeyFunc: func(ctx api.Context, name string) (string, error) {
			return etcdgeneric.NamespaceKeyFunc(ctx, IngressPath, name)
		},
		// Retrieve the name field of a replication controller
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*extensions.Ingress).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 ingress.MatchIngress(label, field)
		},
		EndpointName: "ingresses",

		// Used to validate controller creation
		CreateStrategy: ingress.Strategy,

		// Used to validate controller updates
		UpdateStrategy: ingress.Strategy,

		Storage: s,
	}
	statusStore := *store
	statusStore.UpdateStrategy = ingress.StatusStrategy
	return &REST{store}, &StatusREST{store: &statusStore}
}