// Note: requires RBAC permission to list namespaces at the cluster level
requires RBAC permission to list namespaces at the cluster level
// Note : requires RBAC permission to list namespaces at the cluster level
func GetNamespaces() ([]string, error) {
	customFactory := getConfigClientFactory()
	if customFactory != nil {
		return []string{"default", defaults.GlooSystem}, nil
	}
	cfg, err := kubeutils.GetConfig("", "")
	if err != nil {
		return nil, errors.Wrapf(err, "getting kube config")
	}
	kubeClient, err := kubernetes.NewForConfig(cfg)
	if err != nil {
		return nil, errors.Wrapf(err, "getting kube client")
	}
	var namespaces []string
	nsList, err := kubeClient.CoreV1().Namespaces().List(metav1.ListOptions{})
	if err != nil {
		return nil, err
	}
	for _, ns := range nsList.Items {
		namespaces = append(namespaces, ns.Name)
	}
	return namespaces, nil
}
func GetNamespaces ( ) ( [ ] string , error ) { customFactory := getConfigClientFactory ( ) if customFactory != nil { return [ ] string { " " , defaults . GlooSystem } , nil } cfg , err := kubeutils . GetConfig ( " " , " " ) if err != nil { return nil , errors . Wrapf ( err , " " ) } kubeClient , err := kubernetes . NewForConfig ( cfg ) if err != nil { return nil , errors . Wrapf ( err , " " ) } var namespaces [ ] string nsList , err := kubeClient . CoreV1 ( ) . Namespaces ( ) . List ( metav1 . ListOptions { } ) if err != nil { return nil , err } for _ , ns := range nsList . Items { namespaces = append ( namespaces , ns . Name ) } return namespaces , nil }
requires RBAC permission to list namespaces at the cluster level
requires RBAC permission to list namespaces at the cluster level