本文整理汇总了Golang中github.com/openshift/origin/pkg/util/restoptions.ApplyOptions函数的典型用法代码示例。如果您正苦于以下问题:Golang ApplyOptions函数的具体用法?Golang ApplyOptions怎么用?Golang ApplyOptions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ApplyOptions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewStorage
// NewStorage returns a RESTStorage object that will work against nodes.
func NewStorage(optsGetter restoptions.Getter) (*REST, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return "aapi.ClusterResourceQuota{} },
NewListFunc: func() runtime.Object { return "aapi.ClusterResourceQuotaList{} },
QualifiedResource: quotaapi.Resource("clusterresourcequotas"),
KeyRootFunc: func(ctx kapi.Context) string {
return ClusterResourceQuotaPath
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return util.NoNamespaceKeyFunc(ctx, ClusterResourceQuotaPath, id)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*quotaapi.ClusterResourceQuota).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return Matcher(label, field)
},
CreateStrategy: Strategy,
UpdateStrategy: Strategy,
DeleteStrategy: Strategy,
ReturnDeletedObject: false,
}
if err := restoptions.ApplyOptions(optsGetter, store, ClusterResourceQuotaPath); err != nil {
return nil, err
}
return &REST{store}, nil
}
示例2: NewREST
// NewREST returns a RESTStorage object that will work against Build objects.
func NewREST(optsGetter restoptions.Getter) (*REST, *DetailsREST, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.Build{} },
NewListFunc: func() runtime.Object { return &api.BuildList{} },
QualifiedResource: api.Resource("builds"),
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Build).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) *generic.SelectionPredicate {
return build.Matcher(label, field)
},
CreateStrategy: build.Strategy,
UpdateStrategy: build.Strategy,
DeleteStrategy: build.Strategy,
Decorator: build.Decorator,
ReturnDeletedObject: false,
}
if err := restoptions.ApplyOptions(optsGetter, store, true, storage.NoTriggerPublisher); err != nil {
return nil, nil, err
}
detailsStore := *store
detailsStore.UpdateStrategy = build.DetailsStrategy
return &REST{store}, &DetailsREST{&detailsStore}, nil
}
示例3: NewREST
// NewREST returns a deploymentConfigREST containing the REST storage for DeploymentConfig objects,
// a statusREST containing the REST storage for changing the status of a DeploymentConfig,
// and a scaleREST containing the REST storage for the Scale subresources of DeploymentConfigs.
func NewREST(optsGetter restoptions.Getter) (*REST, *StatusREST, *ScaleREST, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.DeploymentConfig{} },
NewListFunc: func() runtime.Object { return &api.DeploymentConfigList{} },
QualifiedResource: api.Resource("deploymentconfigs"),
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.DeploymentConfig).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
return deployconfig.Matcher(label, field)
},
CreateStrategy: deployconfig.Strategy,
UpdateStrategy: deployconfig.Strategy,
DeleteStrategy: deployconfig.Strategy,
ReturnDeletedObject: false,
}
if err := restoptions.ApplyOptions(optsGetter, store, true, storage.NoTriggerPublisher); err != nil {
return nil, nil, nil, err
}
deploymentConfigREST := &REST{store}
statusStore := *store
statusStore.UpdateStrategy = deployconfig.StatusStrategy
statusREST := &StatusREST{store: &statusStore}
scaleREST := &ScaleREST{registry: deployconfig.NewRegistry(deploymentConfigREST)}
return deploymentConfigREST, statusREST, scaleREST, nil
}
示例4: NewREST
// NewREST returns a RESTStorage object that will work against egress network policy
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.EgressNetworkPolicy{} },
NewListFunc: func() runtime.Object { return &api.EgressNetworkPolicyList{} },
KeyRootFunc: func(ctx kapi.Context) string {
return registry.NamespaceKeyRootFunc(ctx, etcdPrefix)
},
KeyFunc: func(ctx kapi.Context, name string) (string, error) {
return registry.NamespaceKeyFunc(ctx, etcdPrefix, name)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.EgressNetworkPolicy).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return egressnetworkpolicy.Matcher(label, field)
},
QualifiedResource: api.Resource("egressnetworkpolicies"),
CreateStrategy: egressnetworkpolicy.Strategy,
UpdateStrategy: egressnetworkpolicy.Strategy,
}
if err := restoptions.ApplyOptions(optsGetter, store, etcdPrefix); err != nil {
return nil, err
}
return &REST{*store}, nil
}
示例5: NewStorage
// NewStorage returns a RESTStorage object that will work against nodes.
func NewStorage(optsGetter restoptions.Getter) (*REST, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return &authorizationapi.ClusterPolicy{} },
NewListFunc: func() runtime.Object { return &authorizationapi.ClusterPolicyList{} },
QualifiedResource: authorizationapi.Resource("clusterpolicies"),
KeyRootFunc: func(ctx kapi.Context) string {
return ClusterPolicyPath
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return util.NoNamespaceKeyFunc(ctx, ClusterPolicyPath, id)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*authorizationapi.ClusterPolicy).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return clusterpolicy.Matcher(label, field)
},
CreateStrategy: clusterpolicy.Strategy,
UpdateStrategy: clusterpolicy.Strategy,
}
if err := restoptions.ApplyOptions(optsGetter, store, ClusterPolicyPath); err != nil {
return nil, err
}
return &REST{store}, nil
}
示例6: NewREST
// NewREST returns a RESTStorage object that will work against oauth clients
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.OAuthClient{} },
NewListFunc: func() runtime.Object { return &api.OAuthClientList{} },
KeyRootFunc: func(ctx kapi.Context) string {
return EtcdPrefix
},
KeyFunc: func(ctx kapi.Context, name string) (string, error) {
return util.NoNamespaceKeyFunc(ctx, EtcdPrefix, name)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.OAuthClient).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return oauthclient.Matcher(label, field)
},
QualifiedResource: api.Resource("oauthclients"),
CreateStrategy: oauthclient.Strategy,
UpdateStrategy: oauthclient.Strategy,
}
if err := restoptions.ApplyOptions(optsGetter, store, EtcdPrefix); err != nil {
return nil, err
}
return &REST{*store}, nil
}
示例7: NewREST
// NewREST returns a RESTStorage object that will work against routes.
func NewREST(optsGetter restoptions.Getter, allocator route.RouteAllocator) (*REST, *StatusREST, error) {
strategy := rest.NewStrategy(allocator)
prefix := "/routes"
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.Route{} },
NewListFunc: func() runtime.Object { return &api.RouteList{} },
KeyRootFunc: func(ctx kapi.Context) string {
return registry.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return registry.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,
}
if err := restoptions.ApplyOptions(optsGetter, store, prefix); err != nil {
return nil, nil, err
}
statusStore := *store
statusStore.UpdateStrategy = rest.StatusStrategy
return &REST{store}, &StatusREST{&statusStore}, nil
}
示例8: NewREST
// NewREST returns a RESTStorage object that will work against routes.
func NewREST(optsGetter restoptions.Getter, allocator route.RouteAllocator) (*REST, *StatusREST, error) {
strategy := rest.NewStrategy(allocator)
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.Route{} },
NewListFunc: func() runtime.Object { return &api.RouteList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Route).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
return rest.Matcher(label, field)
},
QualifiedResource: api.Resource("routes"),
CreateStrategy: strategy,
UpdateStrategy: strategy,
}
if err := restoptions.ApplyOptions(optsGetter, store, true, storage.NoTriggerPublisher); err != nil {
return nil, nil, err
}
statusStore := *store
statusStore.UpdateStrategy = rest.StatusStrategy
return &REST{store}, &StatusREST{&statusStore}, nil
}
示例9: NewREST
// NewREST returns a RESTStorage object that will work against templates.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
prefix := "/templates"
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.Template{} },
NewListFunc: func() runtime.Object { return &api.TemplateList{} },
KeyRootFunc: func(ctx kapi.Context) string {
return registry.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx kapi.Context, name string) (string, error) {
return registry.NamespaceKeyFunc(ctx, prefix, name)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Template).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return tregistry.Matcher(label, field)
},
QualifiedResource: api.Resource("templates"),
CreateStrategy: tregistry.Strategy,
UpdateStrategy: tregistry.Strategy,
ReturnDeletedObject: true,
}
if err := restoptions.ApplyOptions(optsGetter, store, prefix); err != nil {
return nil, err
}
return &REST{store}, nil
}
示例10: NewREST
// NewStorage returns a RESTStorage object that will work against Build objects.
func NewREST(optsGetter restoptions.Getter) (*REST, *DetailsREST, error) {
prefix := "/builds"
store := ®istry.Store{
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 registry.NamespaceKeyRootFunc(ctx, prefix)
},
KeyFunc: func(ctx kapi.Context, id string) (string, error) {
return registry.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,
}
if err := restoptions.ApplyOptions(optsGetter, store, prefix); err != nil {
return nil, nil, err
}
detailsStore := *store
detailsStore.UpdateStrategy = build.DetailsStrategy
return &REST{store}, &DetailsREST{&detailsStore}, nil
}
示例11: NewREST
// NewREST returns a new REST.
func NewREST(optsGetter restoptions.Getter) (*REST, error) {
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.Image{} },
// NewListFunc returns an object capable of storing results of an etcd list.
NewListFunc: func() runtime.Object { return &api.ImageList{} },
// Retrieve the name field of an image
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.Image).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 image.Matcher(label, field)
},
QualifiedResource: api.Resource("images"),
// Used to validate image creation
CreateStrategy: image.Strategy,
// Used to validate image updates
UpdateStrategy: image.Strategy,
ReturnDeletedObject: false,
}
if err := restoptions.ApplyOptions(optsGetter, store, false, storage.NoTriggerPublisher); err != nil {
return nil, err
}
return &REST{store}, nil
}
示例12: NewREST
// NewREST returns a RESTStorage object that will work against authorize tokens
func NewREST(optsGetter restoptions.Getter, clientGetter oauthclient.Getter) (*REST, error) {
strategy := oauthauthorizetoken.NewStrategy(clientGetter)
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.OAuthAuthorizeToken{} },
NewListFunc: func() runtime.Object { return &api.OAuthAuthorizeTokenList{} },
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.OAuthAuthorizeToken).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) *generic.SelectionPredicate {
return oauthauthorizetoken.Matcher(label, field)
},
TTLFunc: func(obj runtime.Object, existing uint64, update bool) (uint64, error) {
token := obj.(*api.OAuthAuthorizeToken)
expires := uint64(token.ExpiresIn)
return expires, nil
},
QualifiedResource: api.Resource("oauthauthorizetokens"),
CreateStrategy: strategy,
UpdateStrategy: strategy,
}
if err := restoptions.ApplyOptions(optsGetter, store, false, storage.NoTriggerPublisher); err != nil {
return nil, err
}
return &REST{store}, nil
}
示例13: NewREST
// 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
}
示例14: NewREST
// NewREST returns a RESTStorage object that will work against access tokens
func NewREST(optsGetter restoptions.Getter, clientGetter oauthclient.Getter, backends ...storage.Interface) (*REST, error) {
strategy := oauthaccesstoken.NewStrategy(clientGetter)
store := ®istry.Store{
NewFunc: func() runtime.Object { return &api.OAuthAccessToken{} },
NewListFunc: func() runtime.Object { return &api.OAuthAccessTokenList{} },
KeyRootFunc: func(ctx kapi.Context) string {
return EtcdPrefix
},
KeyFunc: func(ctx kapi.Context, name string) (string, error) {
return util.NoNamespaceKeyFunc(ctx, EtcdPrefix, name)
},
ObjectNameFunc: func(obj runtime.Object) (string, error) {
return obj.(*api.OAuthAccessToken).Name, nil
},
PredicateFunc: func(label labels.Selector, field fields.Selector) generic.Matcher {
return oauthaccesstoken.Matcher(label, field)
},
TTLFunc: func(obj runtime.Object, existing uint64, update bool) (uint64, error) {
token := obj.(*api.OAuthAccessToken)
expires := uint64(token.ExpiresIn)
return expires, nil
},
QualifiedResource: api.Resource("oauthaccesstokens"),
CreateStrategy: strategy,
UpdateStrategy: strategy,
}
if err := restoptions.ApplyOptions(optsGetter, store, EtcdPrefix); err != nil {
return nil, err
}
if len(backends) > 0 {
// Build identical stores that talk to a single etcd, so we can verify the token is distributed after creation
watchers := []rest.Watcher{}
for i := range backends {
watcher := *store
watcher.Storage = backends[i]
watchers = append(watchers, &watcher)
}
// Observe the cluster for the particular resource version, requiring at least one backend to succeed
observer := observe.NewClusterObserver(store.Storage.Versioner(), watchers, 1)
// After creation, wait for the new token to propagate
store.AfterCreate = func(obj runtime.Object) error {
return observer.ObserveResourceVersion(obj.(*api.OAuthAccessToken).ResourceVersion, 5*time.Second)
}
}
return &REST{store}, nil
}
示例15: NewREST
// 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
}