@@ -33,7 +33,6 @@ type command struct {
3333}
3434
3535type config struct {
36- hostRoot string
3736 links cli.StringSlice
3837 containerSpec string
3938}
@@ -65,12 +64,6 @@ func (m command) build() *cli.Command {
6564 Destination : & cfg .links ,
6665 },
6766 // The following flags are testing-only flags.
68- & cli.StringFlag {
69- Name : "host-root" ,
70- Usage : "The root on the host filesystem to use to resolve symlinks. This is only intended for testing." ,
71- Destination : & cfg .hostRoot ,
72- Hidden : true ,
73- },
7467 & cli.StringFlag {
7568 Name : "container-spec" ,
7669 Usage : "Specify the path to the OCI container spec. If empty or '-' the spec will be read from STDIN. This is only intended for testing." ,
@@ -105,7 +98,7 @@ func (m command) run(c *cli.Context, cfg *config) error {
10598 continue
10699 }
107100
108- err := m .createLink (cfg . hostRoot , containerRoot , parts [0 ], parts [1 ])
101+ err := m .createLink (containerRoot , parts [0 ], parts [1 ])
109102 if err != nil {
110103 m .logger .Warningf ("Failed to create link %v: %v" , parts , err )
111104 }
@@ -114,8 +107,8 @@ func (m command) run(c *cli.Context, cfg *config) error {
114107 return nil
115108}
116109
117- func (m command ) createLink (hostRoot string , containerRoot string , targetPath string , link string ) error {
118- linkPath , err := changeRoot (hostRoot , containerRoot , link )
110+ func (m command ) createLink (containerRoot string , targetPath string , link string ) error {
111+ linkPath , err := changeRoot (containerRoot , link )
119112 if err != nil {
120113 m .logger .Warningf ("Failed to resolve path for link %v relative to %v: %v" , link , containerRoot , err )
121114 }
@@ -133,19 +126,10 @@ func (m command) createLink(hostRoot string, containerRoot string, targetPath st
133126 return nil
134127}
135128
136- func changeRoot (current string , new string , path string ) (string , error ) {
129+ func changeRoot (new string , path string ) (string , error ) {
137130 if ! filepath .IsAbs (path ) {
138131 return path , nil
139132 }
140133
141- relative := path
142- if current != "" {
143- r , err := filepath .Rel (current , path )
144- if err != nil {
145- return "" , err
146- }
147- relative = r
148- }
149-
150- return filepath .Join (new , relative ), nil
134+ return filepath .Join (new , path ), nil
151135}
0 commit comments