11//go:build linux
22
3- package transform
3+ package bundle
44
55import (
66 "context"
@@ -12,13 +12,11 @@ import (
1212 "github.com/opencontainers/runtime-spec/specs-go"
1313 "github.com/stretchr/testify/assert"
1414 "github.com/stretchr/testify/require"
15-
16- "github.com/spin-stack/spinbox/internal/shim/bundle"
1715)
1816
1917const cgroupPath = "/sys/fs/cgroup"
2018
21- func createTestBundle (t * testing.T , bundlePath string ) {
19+ func setupTransformTestBundle (t * testing.T , bundlePath string ) {
2220 t .Helper ()
2321 require .NoError (t , os .MkdirAll (bundlePath , 0750 ))
2422
@@ -48,13 +46,13 @@ func TestTransformBindMounts(t *testing.T) {
4846 t .Run ("transforms bind mount from bundle path" , func (t * testing.T ) {
4947 tmpDir := t .TempDir ()
5048 bundlePath := filepath .Join (tmpDir , "test-container" )
51- createTestBundle (t , bundlePath )
49+ setupTransformTestBundle (t , bundlePath )
5250
5351 testFile := filepath .Join (bundlePath , "config.yaml" )
5452 testContent := []byte ("key: value\n " )
5553 require .NoError (t , os .WriteFile (testFile , testContent , 0600 ))
5654
57- b , err := bundle . Load (ctx , bundlePath )
55+ b , err := Load (ctx , bundlePath )
5856 require .NoError (t , err )
5957
6058 b .Spec .Mounts = append (b .Spec .Mounts , specs.Mount {
@@ -75,14 +73,14 @@ func TestTransformBindMounts(t *testing.T) {
7573 t .Run ("ignores bind mount from different path" , func (t * testing.T ) {
7674 tmpDir := t .TempDir ()
7775 bundlePath := filepath .Join (tmpDir , "test-container" )
78- createTestBundle (t , bundlePath )
76+ setupTransformTestBundle (t , bundlePath )
7977
8078 otherDir := filepath .Join (tmpDir , "other" )
8179 require .NoError (t , os .MkdirAll (otherDir , 0750 ))
8280 testFile := filepath .Join (otherDir , "secret.txt" )
8381 require .NoError (t , os .WriteFile (testFile , []byte ("secret" ), 0600 ))
8482
85- b , err := bundle . Load (ctx , bundlePath )
83+ b , err := Load (ctx , bundlePath )
8684 require .NoError (t , err )
8785
8886 b .Spec .Mounts = append (b .Spec .Mounts , specs.Mount {
@@ -104,9 +102,9 @@ func TestAdaptForVM(t *testing.T) {
104102 t .Run ("removes network and cgroup namespaces" , func (t * testing.T ) {
105103 tmpDir := t .TempDir ()
106104 bundlePath := filepath .Join (tmpDir , "test-container" )
107- createTestBundle (t , bundlePath )
105+ setupTransformTestBundle (t , bundlePath )
108106
109- b , err := bundle . Load (ctx , bundlePath )
107+ b , err := Load (ctx , bundlePath )
110108 require .NoError (t , err )
111109
112110 err = AdaptForVM (ctx , b )
@@ -134,9 +132,9 @@ func TestAdaptForVM(t *testing.T) {
134132 t .Run ("adds cgroup2 mount if missing" , func (t * testing.T ) {
135133 tmpDir := t .TempDir ()
136134 bundlePath := filepath .Join (tmpDir , "test-container" )
137- createTestBundle (t , bundlePath )
135+ setupTransformTestBundle (t , bundlePath )
138136
139- b , err := bundle . Load (ctx , bundlePath )
137+ b , err := Load (ctx , bundlePath )
140138 require .NoError (t , err )
141139
142140 err = AdaptForVM (ctx , b )
@@ -171,7 +169,7 @@ func TestAdaptForVM(t *testing.T) {
171169 require .NoError (t , os .WriteFile (filepath .Join (bundlePath , "config.json" ), specBytes , 0600 ))
172170 require .NoError (t , os .MkdirAll (filepath .Join (bundlePath , "rootfs" ), 0750 ))
173171
174- b , err := bundle . Load (ctx , bundlePath )
172+ b , err := Load (ctx , bundlePath )
175173 require .NoError (t , err )
176174
177175 err = AdaptForVM (ctx , b )
@@ -185,9 +183,9 @@ func TestAdaptForVM(t *testing.T) {
185183 t .Run ("grants full capabilities" , func (t * testing.T ) {
186184 tmpDir := t .TempDir ()
187185 bundlePath := filepath .Join (tmpDir , "test-container" )
188- createTestBundle (t , bundlePath )
186+ setupTransformTestBundle (t , bundlePath )
189187
190- b , err := bundle . Load (ctx , bundlePath )
188+ b , err := Load (ctx , bundlePath )
191189 require .NoError (t , err )
192190
193191 err = AdaptForVM (ctx , b )
@@ -212,7 +210,7 @@ func TestAdaptForVM(t *testing.T) {
212210 require .NoError (t , os .WriteFile (filepath .Join (bundlePath , "config.json" ), specBytes , 0600 ))
213211 require .NoError (t , os .MkdirAll (filepath .Join (bundlePath , "rootfs" ), 0750 ))
214212
215- b , err := bundle . Load (ctx , bundlePath )
213+ b , err := Load (ctx , bundlePath )
216214 require .NoError (t , err )
217215
218216 err = AdaptForVM (ctx , b )
@@ -226,7 +224,7 @@ func TestLoadForCreate(t *testing.T) {
226224 t .Run ("applies all transforms" , func (t * testing.T ) {
227225 tmpDir := t .TempDir ()
228226 bundlePath := filepath .Join (tmpDir , "test-container" )
229- createTestBundle (t , bundlePath )
227+ setupTransformTestBundle (t , bundlePath )
230228
231229 testFile := filepath .Join (bundlePath , "app.conf" )
232230 require .NoError (t , os .WriteFile (testFile , []byte ("config" ), 0600 ))
0 commit comments