Giter Club home page Giter Club logo

Comments (11)

dcramer avatar dcramer commented on June 1, 2024

I'm going to dig into this now and will submit a PR with proposed changes.

from go-lxc.

dcramer avatar dcramer commented on June 1, 2024

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.

caglar10ur avatar caglar10ur commented on June 1, 2024

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.

dcramer avatar dcramer commented on June 1, 2024

@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.

caglar10ur avatar caglar10ur commented on June 1, 2024

Oh by the way, would it be possible for you to base your commits on top of v2 branch?

from go-lxc.

dcramer avatar dcramer commented on June 1, 2024

@caglar10ur regarding the API, do you prefer RunCommand(options, args...) or RunCommand([]args, options) ?

from go-lxc.

caglar10ur avatar caglar10ur commented on June 1, 2024

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.

caglar10ur avatar caglar10ur commented on June 1, 2024

Oh wait I think I misunderstood something. Are you putting the command name into the options struct?

from go-lxc.

dcramer avatar dcramer commented on June 1, 2024

@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.

caglar10ur avatar caglar10ur commented on June 1, 2024

@dcramer OK we are in the same page :)

from go-lxc.

caglar10ur avatar caglar10ur commented on June 1, 2024

I think we now have everything in, closing this...

from go-lxc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.