MCPcopy
hub / github.com/kubernetes/client-go / GetAPIGroupResources

Function GetAPIGroupResources

restmapper/discovery.go:147–174  ·  view source on GitHub ↗

GetAPIGroupResources uses the provided discovery client to gather discovery information and populate a slice of APIGroupResources.

(cl discovery.DiscoveryInterface)

Source from the content-addressed store, hash-verified

145// GetAPIGroupResources uses the provided discovery client to gather
146// discovery information and populate a slice of APIGroupResources.
147func GetAPIGroupResources(cl discovery.DiscoveryInterface) ([]*APIGroupResources, error) {
148 gs, rs, err := cl.ServerGroupsAndResources()
149 if rs == nil || gs == nil {
150 return nil, err
151 // TODO track the errors and update callers to handle partial errors.
152 }
153 rsm := map[string]*metav1.APIResourceList{}
154 for _, r := range rs {
155 rsm[r.GroupVersion] = r
156 }
157
158 var result []*APIGroupResources
159 for _, group := range gs {
160 groupResources := &APIGroupResources{
161 Group: *group,
162 VersionedResources: make(map[string][]metav1.APIResource),
163 }
164 for _, version := range group.Versions {
165 resources, ok := rsm[version.GroupVersion]
166 if !ok {
167 continue
168 }
169 groupResources.VersionedResources[version.Version] = resources.APIResources
170 }
171 result = append(result, groupResources)
172 }
173 return result, nil
174}
175
176// DeferredDiscoveryRESTMapper is a RESTMapper that will defer
177// initialization of the RESTMapper until the first mapping is

Callers 3

fakeScaleClientFunction · 0.92
TestGetAPIGroupResourcesFunction · 0.85
getDelegateMethod · 0.85

Calls 1

Tested by 2

fakeScaleClientFunction · 0.74
TestGetAPIGroupResourcesFunction · 0.68