INNER CODE UNIT · Go
checkClusterAndUserName
sunny0826/kubecm · cmd/add.go:232
func checkClusterAndUserName(oldConfig *clientcmdapi.Config, newClusterName, newUserName string) (bool, bool, bool) {
var (
clusterAndUserNameExistInSameContext bool
justClusterNameExist bool
justUserNameExist bool
)
for _, ctx := range oldConfig.Contexts {
if ctx.Cluster == newClusterName && ctx.AuthInfo == newUserName {
clusterAndUserNameExistInSameContext = true
}
if ctx.Cluster == newClusterName {
justClusterNameExist = true
}
if ctx.AuthInfo == newUserName {
justUserNameExist = true
}
}