func coreResDetails(cfg api.Config, context string) (result string, err error) {
	cs, err := csForContext(cfg, context)
	if err != nil {
		return "", errors.Wrap(err, "Can't create a clientset based on config provided")
	}
	namespaces, err := cs.CoreV1().Namespaces().List(metav1.ListOptions{})
	if err != nil {
		return "", errors.Wrap(err, "Can't get namespaces in cluster")
	}
	for _, ns := range namespaces.Items {
		nsname := ns.Name
		result += fmt.Sprintf("# namespace [%v]\n", nsname)
		pods, err := cs.CoreV1().Pods(nsname).List(metav1.ListOptions{})
		if err != nil {
			return "", errors.Wrap(err, "Can't get pods")
		}
		switch len(pods.Items) {
		case 0:
			result += fmt.Sprintf("has no pods\n")
		default:
			result += fmt.Sprintf("has %v pod(s) overall:\n", len(pods.Items))
			for _, pod := range pods.Items {
				result += fmt.Sprintf("- %v", podInfo(pod))
			}
		}
		svcs, err := cs.CoreV1().Services(nsname).List(metav1.ListOptions{})
		if err != nil {
			return "", errors.Wrap(err, "Can't get services")
		}
		switch len(svcs.Items) {
		case 0:
			result += fmt.Sprintf("has no services\n")
		default:
			result += fmt.Sprintf("has %v service(s) overall:\n", len(svcs.Items))
			for _, svc := range svcs.Items {
				result += fmt.Sprintf("- %v", svcInfo(svc))
			}
		}
		result += strings.Repeat("-", 80) + "\n\n"
	}
	return result, nil
}
coreResDetails returns details about useful core resources in given context.
Useful core resources include pods, services, deployments,
package fleet
import (
	"fmt"
	"strings"
	"github.com/pkg/errors"
	v1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/cli-runtime/pkg/genericclioptions"
	"k8s.io/client-go/tools/clientcmd/api"
)
func Details(configFlags *genericclioptions.ConfigFlags, args []string) error {
	clientcfg := configFlags.ToRawKubeConfigLoader()
	cfg, err := clientcfg.RawConfig()
	if err != nil {
		return errors.Wrap(err, "Can't assemble raw config")
	}
	if len(args) < 1 {
		return errors.New("need a cluster to operate on, please provide the cluster name")
	}
	clusterID := args[0]
	cluster := cfg.Clusters[clusterID]
	if cluster == nil {
		return errors.New(fmt.Sprintf("cluster %q not found in kubeconfig", clusterID))
	}
	fmt.Printf("API server endpoint: %v\n", cluster.Server)
	context := contextOf(cfg, clusterID)
	coreres, err := coreResDetails(cfg, context)
	if err != nil {
		return err
	}
	fmt.Printf("\n%v\n", coreres)
	return nil
}