Skip to content

Commit 5fb3883

Browse files
author
Mrunal Patel
authored
Merge pull request #681 from q384566678/generate-version
generate: add oci-version option
2 parents 4a85ba2 + b90e5bc commit 5fb3883

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

cmd/oci-runtime-tool/generate.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ var generateFlags = []cli.Flag{
9191
cli.StringSliceFlag{Name: "mounts-add", Usage: "configures additional mounts inside container"},
9292
cli.StringSliceFlag{Name: "mounts-remove", Usage: "remove destination mountpoints from inside container"},
9393
cli.BoolFlag{Name: "mounts-remove-all", Usage: "remove all mounts inside container"},
94+
cli.StringFlag{Name: "oci-version", Usage: "specify the version of the Open Container Initiative runtime specification"},
9495
cli.StringFlag{Name: "os", Value: runtime.GOOS, Usage: "operating system the container is created for"},
9596
cli.StringFlag{Name: "output", Usage: "output file (defaults to stdout)"},
9697
cli.BoolFlag{Name: "privileged", Usage: "enable privileged container settings"},
@@ -203,6 +204,10 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
203204
g.SetHostname(context.String("hostname"))
204205
}
205206

207+
if context.IsSet("oci-version") {
208+
g.SetOCIVersion(context.String("oci-version"))
209+
}
210+
206211
if context.IsSet("label") {
207212
annotations := context.StringSlice("label")
208213
for _, s := range annotations {

completions/bash/oci-runtime-tool

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ _oci-runtime-tool_generate() {
369369
--linux-uidmappings
370370
--mounts-add
371371
--mounts-remove
372+
--oci-version
372373
--os
373374
--output
374375
--process-cap-add

generate/generate.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,12 @@ func (g *Generator) SetHostname(s string) {
368368
g.Config.Hostname = s
369369
}
370370

371+
// SetOCIVersion sets g.Config.Version.
372+
func (g *Generator) SetOCIVersion(s string) {
373+
g.initConfig()
374+
g.Config.Version = s
375+
}
376+
371377
// ClearAnnotations clears g.Config.Annotations.
372378
func (g *Generator) ClearAnnotations() {
373379
if g.Config == nil {

man/oci-runtime-tool-generate.1.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,9 @@ read the configuration from `config.json`.
356356
Remove all mounts inside the container. The default is *false*.
357357
When specified with --mount-add, this option will be parsed first.
358358

359+
**--oci-version**=""
360+
Set the version of the Open Container Initiative runtime specification.
361+
359362
**--os**=OS
360363
Operating system used within the container.
361364

0 commit comments

Comments
 (0)