This commit is contained in:
Ellen Körbes 2018-03-05 19:15:13 -03:00
parent 3be8109b17
commit a9cf1354c1
2 changed files with 10 additions and 7 deletions

View File

@ -149,7 +149,10 @@ func (p *parser) isGroupVersionMatch(group, version string) bool {
// getOpenAPI retrieves a schema object from the API based on a // getOpenAPI retrieves a schema object from the API based on a
// GroupVersionResource triplet. // GroupVersionResource triplet.
func (p *parser) getOpenAPI(group, version, kind string) proto.Schema { func (p *parser) getOpenAPI(group, version, kind string) proto.Schema {
schema := p.resources.LookupResource(schema.GroupVersionKind{group, version, kind}) schema := p.resources.LookupResource(schema.GroupVersionKind{
Group: group,
Version: version,
Kind: kind})
if schema == nil { if schema == nil {
return nil return nil
} }
@ -180,11 +183,11 @@ func (p *parser) indexResources(gvs []*v1.APIResourceList) (Resources, map[schem
} }
newResource := &Resource{ newResource := &Resource{
Resource: r, Resource: r,
apiGroupVersion: schema.GroupVersion{group, version}, apiGroupVersion: schema.GroupVersion{Group: group, Version: version},
schema: newSchema, schema: newSchema,
} }
resources[name] = append(resources[name], newResource) resources[name] = append(resources[name], newResource)
bygvr[schema.GroupVersionResource{group, version, r.Kind}] = newResource bygvr[schema.GroupVersionResource{Group: group, Version: version, Resource: r.Kind}] = newResource
} }
} }
return resources, bygvr return resources, bygvr
@ -214,7 +217,7 @@ func (p *parser) attachSubResources(
continue continue
} }
// Make sure the Parent resource wasn't filtered out // Make sure the Parent resource wasn't filtered out
gvr := schema.GroupVersionResource{group, version, resourceName} gvr := schema.GroupVersionResource{Group: group, Version: version, Resource: resourceName}
if _, found := bygvr[gvr]; !found { if _, found := bygvr[gvr]; !found {
continue continue
} }
@ -222,7 +225,7 @@ func (p *parser) attachSubResources(
subRes := &SubResource{ subRes := &SubResource{
Resource: r, Resource: r,
parent: parent, parent: parent,
apiGroupVersion: schema.GroupVersion{group, version}, apiGroupVersion: schema.GroupVersion{Group: group, Version: version},
schema: newSchema, schema: newSchema,
} }
parent.SubResources = append(parent.SubResources, subRes) parent.SubResources = append(parent.SubResources, subRes)

View File

@ -52,10 +52,10 @@ func (sr *SubResource) EndpointGroupVersionKind() schema.GroupVersionKind {
// ResourceGroupVersionKind returns a GVK based on the request object. // ResourceGroupVersionKind returns a GVK based on the request object.
func (r *Resource) ResourceGroupVersionKind() schema.GroupVersionKind { func (r *Resource) ResourceGroupVersionKind() schema.GroupVersionKind {
return schema.GroupVersionKind{r.Resource.Group, r.Resource.Version, r.Resource.Kind} return schema.GroupVersionKind{Group: r.Resource.Group, Version: r.Resource.Version, Kind: r.Resource.Kind}
} }
// ResourceGroupVersionKind returns a GVK based on the request object. // ResourceGroupVersionKind returns a GVK based on the request object.
func (sr *SubResource) RequestGroupVersionKind() schema.GroupVersionKind { func (sr *SubResource) RequestGroupVersionKind() schema.GroupVersionKind {
return schema.GroupVersionKind{sr.Resource.Group, sr.Resource.Version, sr.Resource.Kind} return schema.GroupVersionKind{Group: sr.Resource.Group, Version: sr.Resource.Version, Kind: sr.Resource.Kind}
} }