本文整理汇总了Golang中k8s/io/kubernetes/pkg/registry/generic/etcd.NamespaceKeyRootFunc函数的典型用法代码示例。如果您正苦于以下问题:Golang NamespaceKeyRootFunc函数的具体用法?Golang NamespaceKeyRootFunc怎么用?Golang NamespaceKeyRootFunc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NamespaceKeyRootFunc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewREST
func NewREST(s storage.Interface) *REST {
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object {
return &backingserviceinstanceapi.BackingServiceInstance{}
},
NewListFunc: func() runtime.Object {
return &backingserviceinstanceapi.BackingServiceInstanceList{}
},
KeyRootFunc: func(ctx kapi.Context) string {
return etcdgeneric.NamespaceKeyRootFunc(ctx, BackingServiceInstancePath)
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, BackingServiceInstancePath, id)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*backingserviceinstanceapi.BackingServiceInstance).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return backingserviceinstanceregistry.Matcher(label, field)
},
QualifiedResource: backingserviceinstanceapi.Resource("backingserviceinstance"),
CreateStrategy: backingserviceinstanceregistry.BsiStrategy,
UpdateStrategy: backingserviceinstanceregistry.BsiStrategy,
ReturnDeletedObject: false,
Storage: s,
}
return &REST{store: store}
}
示例2: NewREST
// NewREST returns a RESTStorage object that will work against horizontal pod autoscalers.
func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator) *REST {
prefix := "/limitranges"
newListFunc := func() runtime.Object { return &api.LimitRangeList{} }
storageInterface := storageDecorator(
s, 100, &api.LimitRange{}, prefix, limitrange.Strategy, newListFunc)
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.LimitRange{} },
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.LimitRange).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return limitrange.MatchLimitRange(label, field)
},
QualifiedResource: api.Resource("limitranges"),
CreateStrategy: limitrange.Strategy,
UpdateStrategy: limitrange.Strategy,
ExportStrategy: limitrange.Strategy,
Storage: storageInterface,
}
return &REST{store}
}
示例3: NewREST
// NewREST returns a registry which will store ThirdPartyResourceData in the given helper
func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator, group, kind string) *REST {
prefix := "/ThirdPartyResourceData/" + group + "/" + strings.ToLower(kind) + "s"
// We explicitly do NOT do any decoration here yet.
storageInterface := s
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResourceData{} },
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceDataList{} },
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.ThirdPartyResourceData).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return thirdpartyresourcedata.Matcher(label, field)
},
EndpointName: "thirdpartyresourcedata",
CreateStrategy: thirdpartyresourcedata.Strategy,
UpdateStrategy: thirdpartyresourcedata.Strategy,
Storage: storageInterface,
}
return &REST{store}
}
示例4: NewREST
// NewREST returns a RESTStorage object that will work against pod templates.
func NewREST(opts generic.RESTOptions) *REST {
prefix := "/podtemplates"
newListFunc := func() runtime.Object { return &api.PodTemplateList{} }
storageInterface := opts.Decorator(
opts.Storage, cachesize.GetWatchCacheSizeByResource(cachesize.PodTemplates), &api.PodTemplate{}, prefix, podtemplate.Strategy, newListFunc)
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.PodTemplate{} },
NewListFunc: newListFunc,
KeyRootFunc: func(ctx api.Context) string {
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx api.Context, name string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.PodTemplate).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return podtemplate.MatchPodTemplate(label, field)
},
QualifiedResource: api.Resource("podtemplates"),
DeleteCollectionWorkers: opts.DeleteCollectionWorkers,
CreateStrategy: podtemplate.Strategy,
UpdateStrategy: podtemplate.Strategy,
ExportStrategy: podtemplate.Strategy,
ReturnDeletedObject: true,
Storage: storageInterface,
}
return &REST{store}
}
示例5: NewREST
// NewREST returns a registry which will store ThirdPartyResourceData in the given helper
func NewREST(opts generic.RESTOptions, group, kind string) *REST {
prefix := "/ThirdPartyResourceData/" + group + "/" + strings.ToLower(kind) + "s"
// We explicitly do NOT do any decoration here yet.
storageInterface := opts.Storage
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &extensions.ThirdPartyResourceData{} },
NewListFunc: func() runtime.Object { return &extensions.ThirdPartyResourceDataList{} },
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.ThirdPartyResourceData).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return thirdpartyresourcedata.Matcher(label, field)
},
QualifiedResource: extensions.Resource("thirdpartyresourcedatas"),
DeleteCollectionWorkers: opts.DeleteCollectionWorkers,
CreateStrategy: thirdpartyresourcedata.Strategy,
UpdateStrategy: thirdpartyresourcedata.Strategy,
DeleteStrategy: thirdpartyresourcedata.Strategy,
Storage: storageInterface,
}
return &REST{
Etcd: store,
kind: kind,
}
}
示例6: NewREST
// NewStorage returns a RESTStorage object that will work against Build objects.
func NewREST(s storage.Interface) (*REST, *DetailsREST) {
prefix := "/builds"
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.Build{} },
NewListFunc: func() runtime.Object { return &api.BuildList{} },
QualifiedResource: api.Resource("builds"),
KeyRootFunc: func(ctx kapi.Context) string {
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, id)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Build).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return build.Matcher(label, field)
},
CreateStrategy: build.Strategy,
UpdateStrategy: build.Strategy,
DeleteStrategy: build.Strategy,
Decorator: build.Decorator,
ReturnDeletedObject: false,
Storage: s,
}
detailsStore := *store
detailsStore.UpdateStrategy = build.DetailsStrategy
return &REST{store}, &DetailsREST{&detailsStore}
}
示例7: NewREST
// NewREST returns a RESTStorage object that will work against routes.
func NewREST(s storage.Interface, allocator route.RouteAllocator) RouteStorage {
strategy := rest.NewStrategy(allocator)
prefix := "/routes"
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.Route{} },
NewListFunc: func() runtime.Object { return &api.RouteList{} },
KeyRootFunc: func(ctx kapi.Context) string {
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, id)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Route).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return rest.Matcher(label, field)
},
EndpointName: "routes",
CreateStrategy: strategy,
UpdateStrategy: strategy,
Storage: s,
}
return RouteStorage{
Route: &REST{store},
Status: &StatusREST{store},
}
}
示例8: NewREST
// 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)
},
EndpointName: "secrets",
CreateStrategy: secret.Strategy,
UpdateStrategy: secret.Strategy,
Storage: storageInterface,
}
return &REST{store}
}
示例9: NewREST
// NewREST returns a new REST.
func NewREST(s storage.Interface, 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,
Storage: s,
}
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}
}
示例10: NewREST
// NewREST returns a RESTStorage object that will work against events.
func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator, ttl uint64) *REST {
prefix := "/events"
// We explicitly do NOT do any decoration here - switching on Cacher
// for events will lead to too high memory consumption.
storageInterface := s
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.Event{} },
NewListFunc: func() runtime.Object { return &api.EventList{} },
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.Event).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return event.MatchEvent(label, field)
},
TTLFunc: func(runtime.Object, uint64, bool) (uint64, error) {
return ttl, nil
},
QualifiedResource: api.Resource("events"),
CreateStrategy: event.Strategy,
UpdateStrategy: event.Strategy,
Storage: storageInterface,
}
return &REST{store}
}
示例11: NewREST
// NewREST returns a RESTStorage object that will work against routes.
func NewREST(s storage.Interface, allocator route.RouteAllocator) (*REST, *StatusREST) {
strategy := rest.NewStrategy(allocator)
prefix := "/routes"
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.Route{} },
NewListFunc: func() runtime.Object { return &api.RouteList{} },
KeyRootFunc: func(ctx kapi.Context) string {
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, id)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Route).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return rest.Matcher(label, field)
},
QualifiedResource: api.Resource("routes"),
CreateStrategy: strategy,
UpdateStrategy: strategy,
Storage: s,
}
statusStore := *store
statusStore.UpdateStrategy = rest.StatusStrategy
return &REST{store}, &StatusREST{&statusStore}
}
示例12: NewStorage
// NewStorage returns a RESTStorage object that will work against endpoints.
func NewStorage(s storage.Interface) *REST {
prefix := "/services/endpoints"
return &REST{
&etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.Endpoints{} },
NewListFunc: func() runtime.Object { return &api.EndpointsList{} },
KeyRootFunc: func(ctx api.Context) string {
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx api.Context, name string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Endpoints).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return endpoint.MatchEndpoints(label, field)
},
EndpointName: "endpoints",
CreateStrategy: endpoint.Strategy,
UpdateStrategy: endpoint.Strategy,
Storage: s,
},
}
}
示例13: NewREST
// 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 := &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}
}
示例14: NewStorage
// NewStorage returns a RESTStorage object that will work against nodes.
func NewStorage(s storage.Interface) *REST {
store := &etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &authorizationapi.Policy{} },
NewListFunc: func() runtime.Object { return &authorizationapi.PolicyList{} },
QualifiedResource: authorizationapi.Resource("policy"),
KeyRootFunc: func(ctx kapi.Context) string {
return etcdgeneric.NamespaceKeyRootFunc(ctx, PolicyPath)
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, PolicyPath, id)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*authorizationapi.Policy).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return policy.Matcher(label, field)
},
CreateStrategy: policy.Strategy,
UpdateStrategy: policy.Strategy,
Storage: s,
}
return &REST{store}
}
示例15: NewREST
// NewREST returns a RESTStorage object that will work against services.
func NewREST(s storage.Interface) *REST {
prefix := "/services/specs"
store := etcdgeneric.Etcd{
NewFunc: func() runtime.Object { return &api.Service{} },
NewListFunc: func() runtime.Object { return &api.ServiceList{} },
KeyRootFunc: func(ctx api.Context) string {
return etcdgeneric.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx api.Context, name string) (string, error) {
return etcdgeneric.NamespaceKeyFunc(ctx, prefix, name)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Service).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return MatchServices(label, field)
},
EndpointName: "services",
CreateStrategy: rest.Services,
UpdateStrategy: rest.Services,
Storage: s,
}
return &REST{store}
}