github.com/cilium/cilium@v1.16.2/pkg/hubble/k8s/utils.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Hubble
     3  
     4  package k8s
     5  
     6  import (
     7  	"strings"
     8  )
     9  
    10  // ParseNamespaceName returns the object's namespace and name. If namespace is
    11  // not specified, the namespace "default" is returned.
    12  func ParseNamespaceName(namespaceName string) (string, string) {
    13  	nsName := strings.Split(namespaceName, "/")
    14  	ns := nsName[0]
    15  	switch {
    16  	case len(nsName) > 1:
    17  		return ns, nsName[1]
    18  	case ns == "":
    19  		return "", ""
    20  	default:
    21  		return "default", ns
    22  	}
    23  }