Comments (11)
I'm going to dig into this now and will submit a PR with proposed changes.
from go-lxc.
What are your thoughts on something like the following for the API:
c.RunCommand([]string{"/bin/sh"}, &AttachOptions{ClearEnv: true})
So the primary change would be the signature is always args + options. We could also add something like NewAttachOptions to set any defaults that might be needed.
from go-lxc.
I'm assuming you are proposing this instead your old approach (see below), right?
cmd := &Command{Args: []string{"/bin/sh"}, ClearEnv: true,}
cmd.Run(container)
If so I think I like this args + options (+NewAttachOptions for defaults) signature more than previous.
from go-lxc.
@caglar10ur yeah I am. I think it's a better approach, and if we're gonna break API compatibility it seems reasonable to me.
from go-lxc.
Oh by the way, would it be possible for you to base your commits on top of v2 branch?
from go-lxc.
@caglar10ur regarding the API, do you prefer RunCommand(options, args...) or RunCommand([]args, options) ?
from go-lxc.
I believe RunCommand([]args, options) makes more sense cause first one allows one to skip args parameter and I don't think that's a valid use.
from go-lxc.
Oh wait I think I misunderstood something. Are you putting the command name into the options struct?
from go-lxc.
@caglar10ur I was planning to put the entirety of the command (same as it is now) in the first param
So:
c.RunCommand([]string{"/bin/sh", "ls"}, &AttachOptions{
Stdinfd: os.Stdin.Fd(),
Stdoutfd: os.Stdout.Fd(),
Stderrfd: os.Stderr.Fd(),
Cwd: "/tmp",
Env: []string{"FOO=BAR"},
})
from go-lxc.
@dcramer OK we are in the same page :)
from go-lxc.
I think we now have everything in, closing this...
from go-lxc.
Related Issues (20)
- incorrect status code from runCommandStatus
- Wrong cgroup file for KernelMemoryLimit
- CgroupItem and pids namespace HOT 1
- undefined reference to `lxc_config_item_is_supported' HOT 5
- Support working without template
- ERROR: Creating container faled + other error HOT 2
- DefaultConfigPath not consistent with GetConfigPath and SetConfigPath HOT 1
- tag semantic releases HOT 3
- starting the container failed HOT 11
- Version checking checks compile time version rather than runtime
- Failed to create loopback storage
- Import path to gopkg.in/lxc/go-lxc.v2 breaks module replacement HOT 5
- Build failed when specify ldflags -static HOT 1
- create example not working HOT 1
- Create fails when custom dir is specified; possible use-after-free?
- HasAPIExtension does not work because liblxc version check is broken HOT 1
- How to create new virtual machine? HOT 2
- console: handle escape character specification HOT 1
- container: add ConsoleLog() API extension
- Wait() function isn't blocking HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-lxc.