resolveLocalPaths is a modified copy of k8s.io/kubernetes/pkg/client/unversioned/clientcmd.ClientConfigLoadingRules.resolveLocalPaths. ResolveLocalPaths resolves all relative paths in the config object with respect to the stanza's LocationOfOrigin this cannot be done directly inside of LoadFromFile
(config *clientcmdConfig)
| 655 | // this cannot be done directly inside of LoadFromFile because doing so there would make it impossible to load a file without |
| 656 | // modification of its contents. |
| 657 | func resolveLocalPaths(config *clientcmdConfig) error { |
| 658 | for _, cluster := range config.Clusters { |
| 659 | if len(cluster.LocationOfOrigin) == 0 { |
| 660 | continue |
| 661 | } |
| 662 | base, err := filepath.Abs(filepath.Dir(cluster.LocationOfOrigin)) |
| 663 | if err != nil { |
| 664 | return fmt.Errorf("Could not determine the absolute path of config file %s: %w", cluster.LocationOfOrigin, err) |
| 665 | } |
| 666 | |
| 667 | if err := resolvePaths(getClusterFileReferences(cluster), base); err != nil { |
| 668 | return err |
| 669 | } |
| 670 | } |
| 671 | for _, authInfo := range config.AuthInfos { |
| 672 | if len(authInfo.LocationOfOrigin) == 0 { |
| 673 | continue |
| 674 | } |
| 675 | base, err := filepath.Abs(filepath.Dir(authInfo.LocationOfOrigin)) |
| 676 | if err != nil { |
| 677 | return fmt.Errorf("Could not determine the absolute path of config file %s: %w", authInfo.LocationOfOrigin, err) |
| 678 | } |
| 679 | |
| 680 | if err := resolvePaths(getAuthInfoFileReferences(authInfo), base); err != nil { |
| 681 | return err |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | return nil |
| 686 | } |
| 687 | |
| 688 | // getClusterFileReferences is a modified copy of k8s.io/kubernetes/pkg/client/unversioned/clientcmd.ClientConfigLoadingRules.GetClusterFileReferences. |
| 689 | func getClusterFileReferences(cluster *clientcmdCluster) []*string { |
no test coverage detected
searching dependent graphs…