diff --git a/cmd/generator.go b/cmd/generator.go index b276489..a3a0005 100644 --- a/cmd/generator.go +++ b/cmd/generator.go @@ -23,6 +23,7 @@ type Generator struct { Workdir string Env []string Volumes []string + Ports string } func (gen *Generator) Run() error { diff --git a/cmd/templates/main.go.tmpl b/cmd/templates/main.go.tmpl index 1dffc7c..3d0775a 100644 --- a/cmd/templates/main.go.tmpl +++ b/cmd/templates/main.go.tmpl @@ -20,6 +20,7 @@ func main() { Workdir: "{{.Workdir}}", Env: {{printf "%#v" .Env}}, Volumes: {{printf "%#v" .Volumes}}, + Ports: "{{.Ports}}", Stdout: ioutil.Discard, Stderr: os.Stderr, } diff --git a/cmd/templates/shim.go b/cmd/templates/shim.go index 7c6e628..acde0fb 100644 --- a/cmd/templates/shim.go +++ b/cmd/templates/shim.go @@ -15,6 +15,7 @@ type Shim struct { Workdir string Env []string Volumes []string + Ports string Stdout io.Writer Stderr io.Writer } @@ -99,6 +100,10 @@ func (shim *Shim) assembleRunArgs() ([]string, error) { args = append(args, "-v", volume) } + if shim.Ports != "" { + args = append(args, "-p", shim.Ports) + } + if shim.Workdir != "" { cwd, err := os.Getwd() if err != nil { diff --git a/main.go b/main.go index e6ecc3b..db07a63 100644 --- a/main.go +++ b/main.go @@ -54,6 +54,10 @@ func main() { Aliases: []string{"t"}, Usage: "platforms and architectures to target", }, + &cli.StringFlag{ + Name: "ports", + Usage: "ports to use", + }, &cli.StringFlag{ Name: "module", Usage: "name of generated golang module", @@ -77,6 +81,7 @@ func generate(c *cli.Context) error { Embed: c.Bool("embed"), Workdir: c.String("workdir"), Env: c.StringSlice("env"), + Ports: c.String("ports"), Volumes: c.StringSlice("volume"), }