Пример #1
0
// Get retrieves the APIService from the index for a given name.
func (s *aPIServiceLister) Get(name string) (*v1alpha1.APIService, error) {
	key := &v1alpha1.APIService{ObjectMeta: v1.ObjectMeta{Name: name}}
	obj, exists, err := s.indexer.Get(key)
	if err != nil {
		return nil, err
	}
	if !exists {
		return nil, errors.NewNotFound(apiregistration.Resource("apiservice"), name)
	}
	return obj.(*v1alpha1.APIService), nil
}
Пример #2
0
// NewREST returns a RESTStorage object that will work against API services.
func NewREST(optsGetter generic.RESTOptionsGetter) *REST {
	store := &genericregistry.Store{
		NewFunc:     func() runtime.Object { return &apiregistration.APIService{} },
		NewListFunc: func() runtime.Object { return &apiregistration.APIServiceList{} },
		ObjectNameFunc: func(obj runtime.Object) (string, error) {
			return obj.(*apiregistration.APIService).Name, nil
		},
		PredicateFunc:     apiservice.MatchAPIService,
		QualifiedResource: apiregistration.Resource("apiservices"),

		CreateStrategy: apiservice.Strategy,
		UpdateStrategy: apiservice.Strategy,
		DeleteStrategy: apiservice.Strategy,
	}
	options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: apiservice.GetAttrs}
	if err := store.CompleteWithOptions(options); err != nil {
		panic(err) // TODO: Propagate error up
	}
	return &REST{store}
}