ResolveLocalPaths resolves all relative paths in the config object with respect to the stanza's LocationOfOrigin this cannot be done directly inside of LoadFromFile because doing so there would make it impossible to load a file without modification of its contents.
(config *clientcmdapi.Config)
| 461 | // this cannot be done directly inside of LoadFromFile because doing so there would make it impossible to load a file without |
| 462 | // modification of its contents. |
| 463 | func ResolveLocalPaths(config *clientcmdapi.Config) error { |
| 464 | for _, cluster := range config.Clusters { |
| 465 | if len(cluster.LocationOfOrigin) == 0 { |
| 466 | continue |
| 467 | } |
| 468 | base, err := filepath.Abs(filepath.Dir(cluster.LocationOfOrigin)) |
| 469 | if err != nil { |
| 470 | return fmt.Errorf("Could not determine the absolute path of config file %s: %v", cluster.LocationOfOrigin, err) |
| 471 | } |
| 472 | |
| 473 | if err := ResolvePaths(GetClusterFileReferences(cluster), base); err != nil { |
| 474 | return err |
| 475 | } |
| 476 | } |
| 477 | for _, authInfo := range config.AuthInfos { |
| 478 | if len(authInfo.LocationOfOrigin) == 0 { |
| 479 | continue |
| 480 | } |
| 481 | base, err := filepath.Abs(filepath.Dir(authInfo.LocationOfOrigin)) |
| 482 | if err != nil { |
| 483 | return fmt.Errorf("Could not determine the absolute path of config file %s: %v", authInfo.LocationOfOrigin, err) |
| 484 | } |
| 485 | |
| 486 | if err := ResolvePaths(GetAuthInfoFileReferences(authInfo), base); err != nil { |
| 487 | return err |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | return nil |
| 492 | } |
| 493 | |
| 494 | // RelativizeClusterLocalPaths first absolutizes the paths by calling ResolveLocalPaths. This assumes that any NEW path is already |
| 495 | // absolute, but any existing path will be resolved relative to LocationOfOrigin |
no test coverage detected