// List retrieves a list of Projects that match label. func (s *REST) List(ctx kapi.Context, options *kapi.ListOptions) (runtime.Object, error) { user, ok := kapi.UserFrom(ctx) if !ok { return nil, kerrors.NewForbidden(projectapi.Resource("project"), "", fmt.Errorf("unable to list projects without a user on the context")) } namespaceList, err := s.lister.List(user) if err != nil { return nil, err } m := nsregistry.MatchNamespace(oapi.ListOptionsToSelectors(options)) list, err := filterList(namespaceList, m, nil) if err != nil { return nil, err } return projectutil.ConvertNamespaceList(list.(*kapi.NamespaceList)), nil }
func getProjects(oClient *client.Client, kClient kclient.Interface) ([]api.Project, error) { projects, err := oClient.Projects().List(kapi.ListOptions{}) if err == nil { return projects.Items, nil } if err != nil && !kapierrors.IsNotFound(err) { return nil, err } namespaces, err := kClient.Namespaces().List(kapi.ListOptions{}) if err != nil { return nil, err } projects = projectutil.ConvertNamespaceList(namespaces) return projects.Items, nil }
func getProjects(oClient *client.Client, kClient kclientset.Interface) ([]api.Project, error) { projects, err := oClient.Projects().List(kapi.ListOptions{}) if err == nil { return projects.Items, nil } // if this is kube with authorization enabled, this endpoint will be forbidden. OpenShift allows this for everyone. if err != nil && !(kapierrors.IsNotFound(err) || kapierrors.IsForbidden(err)) { return nil, err } namespaces, err := kClient.Core().Namespaces().List(kapi.ListOptions{}) if err != nil { return nil, err } projects = projectutil.ConvertNamespaceList(namespaces) return projects.Items, nil }