RelativizeAuthInfoLocalPaths first absolutizes the paths by calling ResolveLocalPaths. This assumes that any NEW path is already absolute, but any existing path will be resolved relative to LocationOfOrigin
(authInfo *clientcmdapi.AuthInfo)
| 515 | // RelativizeAuthInfoLocalPaths first absolutizes the paths by calling ResolveLocalPaths. This assumes that any NEW path is already |
| 516 | // absolute, but any existing path will be resolved relative to LocationOfOrigin |
| 517 | func RelativizeAuthInfoLocalPaths(authInfo *clientcmdapi.AuthInfo) error { |
| 518 | if len(authInfo.LocationOfOrigin) == 0 { |
| 519 | return fmt.Errorf("no location of origin for %v", authInfo) |
| 520 | } |
| 521 | base, err := filepath.Abs(filepath.Dir(authInfo.LocationOfOrigin)) |
| 522 | if err != nil { |
| 523 | return fmt.Errorf("could not determine the absolute path of config file %s: %v", authInfo.LocationOfOrigin, err) |
| 524 | } |
| 525 | |
| 526 | if err := ResolvePaths(GetAuthInfoFileReferences(authInfo), base); err != nil { |
| 527 | return err |
| 528 | } |
| 529 | if err := RelativizePathWithNoBacksteps(GetAuthInfoFileReferences(authInfo), base); err != nil { |
| 530 | return err |
| 531 | } |
| 532 | |
| 533 | return nil |
| 534 | } |
| 535 | |
| 536 | func RelativizeConfigPaths(config *clientcmdapi.Config, base string) error { |
| 537 | return RelativizePathWithNoBacksteps(GetConfigFileReferences(config), base) |
no test coverage detected