This repository has been archived by the owner on Jun 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added ability to use
exec
on filesystems.
Currently works only for the docker plugin. Signed-off-by: Spencer Brower <[email protected]>
- Loading branch information
Spencer Brower
committed
Apr 15, 2020
1 parent
00ae27b
commit ebe4432
Showing
5 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package volume | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/puppetlabs/wash/plugin" | ||
) | ||
|
||
type execableInterface interface { | ||
Interface | ||
VolumeExec(ctx context.Context, path string, cmd string, args []string, opts plugin.ExecOptions) (plugin.ExecCommand, error) | ||
} | ||
|
||
// execableDir adds the exec action to dir. | ||
type execableDir struct { | ||
dir | ||
impl execableInterface | ||
} | ||
|
||
func newExecDir(name string, attr plugin.EntryAttributes, impl execableInterface, path string) *execableDir { | ||
e := new(execableDir) | ||
e.dir = *newDir(name, attr, impl, path) | ||
e.impl = impl | ||
return e | ||
} | ||
|
||
func (v *execableDir) Exec(ctx context.Context, cmd string, args []string, opts plugin.ExecOptions) (plugin.ExecCommand, error) { | ||
return v.impl.VolumeExec(ctx, v.path, cmd, args, opts) | ||
} | ||
|
||
func (v *execableDir) generateChildren(dirmap *dirMap) []plugin.Entry { | ||
entries := v.dir.generateChildren(dirmap) | ||
|
||
for i, entry := range entries { | ||
dir, ok := entry.(*dir) | ||
if ok { | ||
fmt.Println(dir) | ||
entries[i] = &execableDir{dir: *dir, impl: v.impl} | ||
} | ||
} | ||
return entries | ||
} | ||
|
||
// List lists the children of the directory. | ||
func (v *execableDir) List(ctx context.Context) ([]plugin.Entry, error) { | ||
if v.dirmap != nil { | ||
// Children have been pre-populated by a source parent. | ||
return v.generateChildren(v.dirmap), nil | ||
} | ||
|
||
// Generate child hierarchy. Don't store it on this entry, but populate new dirs from it. | ||
dirmap, err := v.impl.VolumeList(ctx, v.path) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return v.generateChildren(&dirMap{mp: dirmap}), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters