client-go icon indicating copy to clipboard operation
client-go copied to clipboard

Retrieving ServerGroupsAndResources then Group and Version are empty for APIResources

Open jonathanvila opened this issue 2 years ago • 2 comments

I'm trying to get all the resources for a given Api Group. I'm using the method ServerGroupsAndResource from the client. It returns a list of APIResourceList containing TypeMeta, GroupVersion and APIResources Element GroupVersion is "apps/v1" , "apiregistration.k8s.io/v1" , and so on. But, in the APIResources list inside every APIResourceList the elements have Group and Version empty.

I would expect that APIResourceList.GroupVersion is reflected in every APIResourceList.APIResources.Group & Version

My test code

  func main() {
	k8sclient := kubernetes.NewForConfigOrDie(config)
	groupfilter := "apps/v1"
	_, resources, _ := k8sclient.ServerGroupsAndResources()
	for _, resourceGroup := range resources {
		if resourceGroup.GroupVersion == groupfilter {
			for _, apiResource := range resourceGroup.APIResources {
				groupVersionKind := resourceGroup.GroupVersionKind()
				gkv := schema.GroupVersionResource{
					Group:    groupVersionKind.Group,
					Resource: apiResource.Kind,
					Version:  groupVersionKind.Version,
				}
				resource, err := clientset.Resource(gkv).List(ctx, metav1.ListOptions{})
				fmt.Printf("GKV %+v Resource %+v", gkv, resource, err)
			}
		}
	}
}

jonathanvila avatar Mar 21 '22 15:03 jonathanvila

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot avatar Jun 19 '22 16:06 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot avatar Jul 19 '22 16:07 k8s-triage-robot

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

k8s-triage-robot avatar Aug 18 '22 17:08 k8s-triage-robot

@k8s-triage-robot: Closing this issue.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Aug 18 '22 17:08 k8s-ci-robot