forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
project.go
52 lines (45 loc) · 1.51 KB
/
project.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// This file was automatically generated by lister-gen
package v1
import (
api "github.com/openshift/origin/pkg/project/api"
v1 "github.com/openshift/origin/pkg/project/api/v1"
"k8s.io/apimachinery/pkg/api/errors"
meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ProjectLister helps list Projects.
type ProjectLister interface {
// List lists all Projects in the indexer.
List(selector labels.Selector) (ret []*v1.Project, err error)
// Get retrieves the Project from the index for a given name.
Get(name string) (*v1.Project, error)
ProjectListerExpansion
}
// projectLister implements the ProjectLister interface.
type projectLister struct {
indexer cache.Indexer
}
// NewProjectLister returns a new ProjectLister.
func NewProjectLister(indexer cache.Indexer) ProjectLister {
return &projectLister{indexer: indexer}
}
// List lists all Projects in the indexer.
func (s *projectLister) List(selector labels.Selector) (ret []*v1.Project, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1.Project))
})
return ret, err
}
// Get retrieves the Project from the index for a given name.
func (s *projectLister) Get(name string) (*v1.Project, error) {
key := &v1.Project{ObjectMeta: meta_v1.ObjectMeta{Name: name}}
obj, exists, err := s.indexer.Get(key)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(api.Resource("project"), name)
}
return obj.(*v1.Project), nil
}