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.
()
| 339 | // ConfirmUsable looks a particular context and determines if that particular part of the config is useable. There might still be errors in the config, |
| 340 | // but no errors in the sections requested or referenced. It does not return early so that it can find as many errors as possible. |
| 341 | func (config *DirectClientConfig) ConfirmUsable() error { |
| 342 | validationErrors := make([]error, 0) |
| 343 | |
| 344 | var contextName string |
| 345 | if len(config.contextName) != 0 { |
| 346 | contextName = config.contextName |
| 347 | } else { |
| 348 | contextName = config.config.CurrentContext |
| 349 | } |
| 350 | |
| 351 | if len(contextName) > 0 { |
| 352 | _, exists := config.config.Contexts[contextName] |
| 353 | if !exists { |
| 354 | validationErrors = append(validationErrors, &errContextNotFound{contextName}) |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | authInfoName, _ := config.getAuthInfoName() |
| 359 | authInfo, _ := config.getAuthInfo() |
| 360 | validationErrors = append(validationErrors, validateAuthInfo(authInfoName, authInfo)...) |
| 361 | clusterName, _ := config.getClusterName() |
| 362 | cluster, _ := config.getCluster() |
| 363 | validationErrors = append(validationErrors, validateClusterInfo(clusterName, cluster)...) |
| 364 | // when direct client config is specified, and our only error is that no server is defined, we should |
| 365 | // return a standard "no config" error |
| 366 | if len(validationErrors) == 1 && validationErrors[0] == ErrEmptyCluster { |
| 367 | return newErrConfigurationInvalid([]error{ErrEmptyConfig}) |
| 368 | } |
| 369 | return newErrConfigurationInvalid(validationErrors) |
| 370 | } |
| 371 | |
| 372 | // getContextName returns the default, or user-set context name, and a boolean that indicates |
| 373 | // whether the default context name has been overwritten by a user-set flag, or left as its default value |
no test coverage detected