Validate checks for errors in the Config. It does not return early so that it can find as many errors as possible.
(config clientcmdapi.Config)
| 102 | |
| 103 | // Validate checks for errors in the Config. It does not return early so that it can find as many errors as possible. |
| 104 | func Validate(config clientcmdapi.Config) error { |
| 105 | validationErrors := make([]error, 0) |
| 106 | |
| 107 | if clientcmdapi.IsConfigEmpty(&config) { |
| 108 | return newErrConfigurationInvalid([]error{ErrEmptyConfig}) |
| 109 | } |
| 110 | |
| 111 | if len(config.CurrentContext) != 0 { |
| 112 | if _, exists := config.Contexts[config.CurrentContext]; !exists { |
| 113 | validationErrors = append(validationErrors, &errContextNotFound{config.CurrentContext}) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | for contextName, context := range config.Contexts { |
| 118 | validationErrors = append(validationErrors, validateContext(contextName, *context, config)...) |
| 119 | } |
| 120 | |
| 121 | for authInfoName, authInfo := range config.AuthInfos { |
| 122 | validationErrors = append(validationErrors, validateAuthInfo(authInfoName, *authInfo)...) |
| 123 | } |
| 124 | |
| 125 | for clusterName, clusterInfo := range config.Clusters { |
| 126 | validationErrors = append(validationErrors, validateClusterInfo(clusterName, *clusterInfo)...) |
| 127 | } |
| 128 | |
| 129 | return newErrConfigurationInvalid(validationErrors) |
| 130 | } |
| 131 | |
| 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. |