ConfirmUsable looks a particular context and determines if that particular part of the config is useable. There might still be errors in the config, but no errors in the sections requested or referenced. It does not return early so that it can find as many errors as possible.
(config clientcmdapi.Config, passedContextName string)
| 132 | // ConfirmUsable looks a particular context and determines if that particular part of the config is useable. There might still be errors in the config, |
| 133 | // but no errors in the sections requested or referenced. It does not return early so that it can find as many errors as possible. |
| 134 | func ConfirmUsable(config clientcmdapi.Config, passedContextName string) error { |
| 135 | validationErrors := make([]error, 0) |
| 136 | |
| 137 | if clientcmdapi.IsConfigEmpty(&config) { |
| 138 | return newErrConfigurationInvalid([]error{ErrEmptyConfig}) |
| 139 | } |
| 140 | |
| 141 | var contextName string |
| 142 | if len(passedContextName) != 0 { |
| 143 | contextName = passedContextName |
| 144 | } else { |
| 145 | contextName = config.CurrentContext |
| 146 | } |
| 147 | |
| 148 | if len(contextName) == 0 { |
| 149 | return ErrNoContext |
| 150 | } |
| 151 | |
| 152 | context, exists := config.Contexts[contextName] |
| 153 | if !exists { |
| 154 | validationErrors = append(validationErrors, &errContextNotFound{contextName}) |
| 155 | } |
| 156 | |
| 157 | if exists { |
| 158 | validationErrors = append(validationErrors, validateContext(contextName, *context, config)...) |
| 159 | validationErrors = append(validationErrors, validateAuthInfo(context.AuthInfo, *config.AuthInfos[context.AuthInfo])...) |
| 160 | validationErrors = append(validationErrors, validateClusterInfo(context.Cluster, *config.Clusters[context.Cluster])...) |
| 161 | } |
| 162 | |
| 163 | return newErrConfigurationInvalid(validationErrors) |
| 164 | } |
| 165 | |
| 166 | // validateClusterInfo looks for conflicts and errors in the cluster info |
| 167 | func validateClusterInfo(clusterName string, clusterInfo clientcmdapi.Cluster) []error { |