-
Notifications
You must be signed in to change notification settings - Fork 29
Add ability to use exec on directories #769
Comments
Thanks for opening your first issue here! We will follow up as soon as we can. |
That's a great idea, I like it. I'm going to mull it over for a bit, but I don't see any way that contradicts how exec might evolve in the future. One thing it does break is a habit I have of equating executable things with directly accessible resources, but that's a kludge I use to limit queries anyway. I think a better solution would be to have a separate property (maybe an |
Thanks for the blazing fast response! 😄 If you need any help implementing this on the docker plugin, just point me in the right direction and I can start a PR. |
I definitely won't get to it immediately, so that would be great. I'd suggest starting by taking a look at https://github.com/puppetlabs/wash/blob/master/CORE_PLUGIN_DEVELOPMENT.md. The Docker plugin includes its view of the filesystem at https://github.com/puppetlabs/wash/blob/master/plugin/docker/container.go#L92-L94; all plugins actually use a shared implementation to view filesystems: https://pkg.go.dev/github.com/puppetlabs/wash/volume?tab=doc via The volume.FS type implements volume.Interface. Calling
You'll also need to override My usual process for implementing this would be:
One extra factor is that |
Thanks for the in-depth information! Sorry to keep bugging you, but how should I handle the |
I was thinking it'd be something like prepending I'd add that as a new option to |
Adding // volume/fs.go
func (d *FS) VolumeExec(ctx context.Context, path string, cmd string, args []string, opts plugin.ExecOptions) (plugin.ExecCommand, error) {
opts.WorkingDir = path
return d.executor.Exec(ctx, cmd, args, opts)
} //docker/container.go
func (c *container) Exec(ctx context.Context, cmd string, args []string, opts plugin.ExecOptions) (plugin.ExecCommand, error) {
// ...
cfg := types.ExecConfig{Cmd: command, AttachStdout: true, AttachStderr: true, Tty: opts.Tty, WorkingDir: opts.WorkingDir}
// ...
} And with that, docker is working. Now I just need to implement that on the other plugins, which I'm not terribly familiar with. It's worth noting that although it is working, I'm not seeing |
Nice work! The Oh, the name used comes from the entry schema, so you probably need to override https://github.com/puppetlabs/wash/blob/master/volume/dir.go#L32-L34 on |
Use Case
When using the docker plugin, in order to run commands in a particular directory, I have to do this:
wexec docker/containers/container_name sh -c 'cd /var/ && ls'
When it would be, IMO, much more convenient and idiomatic to do this:
Describe the Solution You Would Like
Add the "exec" action to directories in the docker fs folder, where exec is equivilant to
docker exec -it -w $directory_name $container_name $cmd
.For example:
would be equivilant to:
wexec docker/containers/devilbox_php_1/fs/shared/httpd pwd
Thanks! I really love the project.
The text was updated successfully, but these errors were encountered: