Skip to content

Commit 6f10352

Browse files
committed
AddMounts should be AddMount you are only adding a single Mount
AddMount should also take a rspec.Mount object rather then a json string. We are using generate as a library not using the command line tool. The tool should translate the json into a rspec.Mount. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
1 parent c3755c1 commit 6f10352

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

cmd/oci-runtime-tool/generate.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"bufio"
55
"bytes"
6+
"encoding/json"
67
"fmt"
78
"os"
89
"strconv"
@@ -427,8 +428,11 @@ func setupSpec(g *generate.Generator, context *cli.Context) error {
427428
if context.IsSet("mounts-add") {
428429
mounts := context.StringSlice("mounts-add")
429430
for _, mount := range mounts {
430-
err := g.AddMounts(mount)
431-
if err != nil {
431+
mnt := rspec.Mount{}
432+
if err := json.Unmarshal([]byte(mount), &mnt); err != nil {
433+
return err
434+
}
435+
if err := g.AddMount(mnt); err != nil {
432436
return err
433437
}
434438
}

generate/generate.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -980,15 +980,10 @@ func (g *Generator) AddPostStartHook(hookObject string) error {
980980
return nil
981981
}
982982

983-
// AddMounts adds a mount into g.spec.Mounts.
984-
func (g *Generator) AddMounts(mountObject string) error {
983+
// AddMount adds a mount into g.spec.Mounts.
984+
func (g *Generator) AddMount(mnt rspec.Mount) error {
985985
g.initSpec()
986986

987-
mnt := rspec.Mount{}
988-
err := json.Unmarshal([]byte(mountObject), &mnt)
989-
if err != nil {
990-
return err
991-
}
992987
g.spec.Mounts = append(g.spec.Mounts, mnt)
993988

994989
return nil

0 commit comments

Comments
 (0)