Skip to content

Commit

Permalink
Merge pull request #681 from q384566678/generate-version
Browse files Browse the repository at this point in the history
generate: add oci-version option
  • Loading branch information
Mrunal Patel authored Mar 1, 2019
2 parents 4a85ba2 + b90e5bc commit 5fb3883
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/oci-runtime-tool/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ var generateFlags = []cli.Flag{
cli.StringSliceFlag{Name: "mounts-add", Usage: "configures additional mounts inside container"},
cli.StringSliceFlag{Name: "mounts-remove", Usage: "remove destination mountpoints from inside container"},
cli.BoolFlag{Name: "mounts-remove-all", Usage: "remove all mounts inside container"},
cli.StringFlag{Name: "oci-version", Usage: "specify the version of the Open Container Initiative runtime specification"},
cli.StringFlag{Name: "os", Value: runtime.GOOS, Usage: "operating system the container is created for"},
cli.StringFlag{Name: "output", Usage: "output file (defaults to stdout)"},
cli.BoolFlag{Name: "privileged", Usage: "enable privileged container settings"},
Expand Down Expand Up @@ -203,6 +204,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
g.SetHostname(context.String("hostname"))
}

if context.IsSet("oci-version") {
g.SetOCIVersion(context.String("oci-version"))
}

if context.IsSet("label") {
annotations := context.StringSlice("label")
for _, s := range annotations {
Expand Down
1 change: 1 addition & 0 deletions completions/bash/oci-runtime-tool
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ _oci-runtime-tool_generate() {
--linux-uidmappings
--mounts-add
--mounts-remove
--oci-version
--os
--output
--process-cap-add
Expand Down
6 changes: 6 additions & 0 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ func (g *Generator) SetHostname(s string) {
g.Config.Hostname = s
}

// SetOCIVersion sets g.Config.Version.
func (g *Generator) SetOCIVersion(s string) {
g.initConfig()
g.Config.Version = s
}

// ClearAnnotations clears g.Config.Annotations.
func (g *Generator) ClearAnnotations() {
if g.Config == nil {
Expand Down
3 changes: 3 additions & 0 deletions man/oci-runtime-tool-generate.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ read the configuration from `config.json`.
Remove all mounts inside the container. The default is *false*.
When specified with --mount-add, this option will be parsed first.

**--oci-version**=""
Set the version of the Open Container Initiative runtime specification.

**--os**=OS
Operating system used within the container.

Expand Down

0 comments on commit 5fb3883

Please sign in to comment.