Skip to content

Commit 6367e88

Browse files
committed
validation: Support per-architecture tarballs
And use the appropriate one for the current architecture. Renaming the old 'runtime' -> 'runtimeCommand' avoids clobbering the runtime package name. Renaming our local variable to match what container.go is using seemed like a better choice than inventing a custom name for the local package import. Signed-off-by: W. Trevor King <[email protected]>
1 parent ff5e578 commit 6367e88

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed
File renamed without changes.

validation/validation_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"os/exec"
88
"path/filepath"
9+
"runtime"
910
"testing"
1011

1112
"github.com/mrunalp/fileutils"
@@ -18,13 +19,13 @@ import (
1819
)
1920

2021
var (
21-
runtime = "runc"
22+
runtimeCommand = "runc"
2223
)
2324

2425
func init() {
2526
runtimeInEnv := os.Getenv("RUNTIME")
2627
if runtimeInEnv != "" {
27-
runtime = runtimeInEnv
28+
runtimeCommand = runtimeInEnv
2829
}
2930
}
3031

@@ -36,7 +37,7 @@ func prepareBundle() (string, error) {
3637
}
3738

3839
// Untar the root fs
39-
untarCmd := exec.Command("tar", "-xf", "../rootfs.tar.gz", "-C", bundleDir)
40+
untarCmd := exec.Command("tar", "-xf", fmt.Sprintf("../rootfs-%s.tar.gz", runtime.GOARCH), "-C", bundleDir)
4041
_, err = untarCmd.CombinedOutput()
4142
if err != nil {
4243
os.RemoveAll(bundleDir)
@@ -58,7 +59,7 @@ func runtimeInsideValidate(g *generate.Generator) error {
5859
if err != nil {
5960
return err
6061
}
61-
r, err := NewRuntime(runtime, bundleDir)
62+
r, err := NewRuntime(runtimeCommand, bundleDir)
6263
if err != nil {
6364
os.RemoveAll(bundleDir)
6465
return err
@@ -102,7 +103,7 @@ func TestValidateCreate(t *testing.T) {
102103
bundleDir, err := prepareBundle()
103104
assert.Nil(t, err)
104105

105-
r, err := NewRuntime(runtime, bundleDir)
106+
r, err := NewRuntime(runtimeCommand, bundleDir)
106107
assert.Nil(t, err)
107108
defer r.Clean(true)
108109

0 commit comments

Comments
 (0)