MCPcopy
hub / github.com/kubernetes/client-go / RelativizeClusterLocalPaths

Function RelativizeClusterLocalPaths

tools/clientcmd/loader.go:496–513  ·  view source on GitHub ↗

RelativizeClusterLocalPaths 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

(cluster *clientcmdapi.Cluster)

Source from the content-addressed store, hash-verified

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
496func RelativizeClusterLocalPaths(cluster *clientcmdapi.Cluster) error {
497 if len(cluster.LocationOfOrigin) == 0 {
498 return fmt.Errorf("no location of origin for %s", cluster.Server)
499 }
500 base, err := filepath.Abs(filepath.Dir(cluster.LocationOfOrigin))
501 if err != nil {
502 return fmt.Errorf("could not determine the absolute path of config file %s: %v", cluster.LocationOfOrigin, err)
503 }
504
505 if err := ResolvePaths(GetClusterFileReferences(cluster), base); err != nil {
506 return err
507 }
508 if err := RelativizePathWithNoBacksteps(GetClusterFileReferences(cluster), base); err != nil {
509 return err
510 }
511
512 return nil
513}
514
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

Callers 1

ModifyConfigFunction · 0.85

Calls 4

ResolvePathsFunction · 0.85
GetClusterFileReferencesFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected