[no-relnote] Remove redundant changeRoot for link target

Since hostRoot is always the empty string and we are changing the root in the
target path to /, the call to changeRoot is redundant.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2024-10-22 12:08:31 +02:00 committed by Christopher Desiniotis
parent fa59d12973
commit 6a6a3e6055
No known key found for this signature in database
GPG Key ID: 603C8E544D789A89

View File

@ -114,23 +114,18 @@ func (m command) run(c *cli.Context, cfg *config) error {
return nil return nil
} }
func (m command) createLink(hostRoot string, containerRoot string, target string, link string) error { func (m command) createLink(hostRoot string, containerRoot string, targetPath string, link string) error {
linkPath, err := changeRoot(hostRoot, containerRoot, link) linkPath, err := changeRoot(hostRoot, containerRoot, link)
if err != nil { if err != nil {
m.logger.Warningf("Failed to resolve path for link %v relative to %v: %v", link, containerRoot, err) m.logger.Warningf("Failed to resolve path for link %v relative to %v: %v", link, containerRoot, err)
} }
targetPath, err := changeRoot(hostRoot, "/", target)
if err != nil {
m.logger.Warningf("Failed to resolve path for target %v relative to %v: %v", target, "/", err)
}
m.logger.Infof("Symlinking %v to %v", linkPath, targetPath) m.logger.Infof("Symlinking %v to %v", linkPath, targetPath)
err = os.MkdirAll(filepath.Dir(linkPath), 0755) err = os.MkdirAll(filepath.Dir(linkPath), 0755)
if err != nil { if err != nil {
return fmt.Errorf("failed to create directory: %v", err) return fmt.Errorf("failed to create directory: %v", err)
} }
err = os.Symlink(target, linkPath) err = os.Symlink(targetPath, linkPath)
if err != nil { if err != nil {
return fmt.Errorf("failed to create symlink: %v", err) return fmt.Errorf("failed to create symlink: %v", err)
} }