Exemple #1
0
// NewREST returns a RESTStorage object that will work against secrets.
func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator) *REST {
	prefix := "/secrets"

	newListFunc := func() runtime.Object { return &api.SecretList{} }
	storageInterface := storageDecorator(
		s, 100, &api.Secret{}, prefix, true, newListFunc)

	store := &etcdgeneric.Etcd{
		NewFunc:     func() runtime.Object { return &api.Secret{} },
		NewListFunc: newListFunc,
		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.(*api.Secret).Name, nil
		},
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return secret.Matcher(label, field)
		},
		QualifiedResource: api.Resource("secrets"),

		CreateStrategy: secret.Strategy,
		UpdateStrategy: secret.Strategy,

		Storage: storageInterface,
	}
	return &REST{store}
}
Exemple #2
0
// NewREST returns a RESTStorage object that will work against secrets.
func NewREST(s storage.Interface) *REST {
	prefix := "/secrets"

	store := &etcdgeneric.Etcd{
		NewFunc:     func() runtime.Object { return &api.Secret{} },
		NewListFunc: func() runtime.Object { return &api.SecretList{} },
		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.(*api.Secret).Name, nil
		},
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return secret.Matcher(label, field)
		},
		EndpointName: "secrets",

		CreateStrategy: secret.Strategy,
		UpdateStrategy: secret.Strategy,

		Storage: s,
	}
	return &REST{store}
}
Exemple #3
0
// NewREST returns a RESTStorage object that will work against secrets.
func NewREST(opts generic.RESTOptions) *REST {
	prefix := "/secrets"

	newListFunc := func() runtime.Object { return &api.SecretList{} }
	storageInterface := opts.Decorator(
		opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.Secrets), &api.Secret{}, prefix, secret.Strategy, newListFunc)

	store := &registry.Store{
		NewFunc:     func() runtime.Object { return &api.Secret{} },
		NewListFunc: newListFunc,
		KeyRootFunc: func(ctx api.Context) string {
			return registry.NamespaceKeyRootFunc(ctx, prefix)
		},
		KeyFunc: func(ctx api.Context, id string) (string, error) {
			return registry.NamespaceKeyFunc(ctx, prefix, id)
		},
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*api.Secret).Name, nil
		},
		PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
			return secret.Matcher(label, field)
		},
		QualifiedResource:       api.Resource("secrets"),
		DeleteCollectionWorkers: opts.DeleteCollectionWorkers,

		CreateStrategy: secret.Strategy,
		UpdateStrategy: secret.Strategy,
		DeleteStrategy: secret.Strategy,

		Storage: storageInterface,
	}
	return &REST{store}
}