INNER CODE UNIT · Go

checkContextName

sunny0826/kubecm · cmd/add.go:224

func checkContextName(name string, oldConfig *clientcmdapi.Config) bool {
	if _, ok := oldConfig.Contexts[name]; ok {
		return true
	}
	return false
}

// checkClusterAndUserName check if the cluster and user exist in the same context, or just cluster or user exist
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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…