2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2024-11-24 16:46:24 +00:00

tests: fix permissions error

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
Adphi 2023-02-28 18:10:30 +01:00 committed by Adphi
parent 0c3a736977
commit f7b4861b1d
2 changed files with 5 additions and 2 deletions

View File

@ -81,7 +81,7 @@ func (i DockerImage) AsRunScript(w io.Writer) error {
} }
func NewImage(ctx context.Context, tag string, imageTmpPath string) (*image, error) { func NewImage(ctx context.Context, tag string, imageTmpPath string) (*image, error) {
if err := os.MkdirAll(imageTmpPath, perm); err != nil { if err := os.MkdirAll(imageTmpPath, os.ModePerm); err != nil {
return nil, err return nil, err
} }
// save the image to a tar file to avoid loading it in memory // save the image to a tar file to avoid loading it in memory
@ -110,6 +110,9 @@ type image struct {
} }
func (i image) Flatten(ctx context.Context, out string) error { func (i image) Flatten(ctx context.Context, out string) error {
if err := os.MkdirAll(out, os.ModePerm); err != nil {
return err
}
tar := filepath.Join(i.dir, "img.tar") tar := filepath.Join(i.dir, "img.tar")
f, err := os.Create(tar) f, err := os.Create(tar)
if err != nil { if err != nil {

View File

@ -134,7 +134,7 @@ RUN rm -rf /etc/apk
) )
exec.SetDebug(true) exec.SetDebug(true)
tmp := filepath.Join(os.TempDir(), "d2vm-tests", "image-flatten") tmp := filepath.Join(os.TempDir(), "d2vm-tests", "image-flatten")
require.NoError(t, os.MkdirAll(tmp, perm)) require.NoError(t, os.MkdirAll(tmp, os.ModePerm))
defer os.RemoveAll(tmp) defer os.RemoveAll(tmp)
require.NoError(t, os.WriteFile(filepath.Join(tmp, "hostname"), []byte("d2vm-flatten-test"), perm)) require.NoError(t, os.WriteFile(filepath.Join(tmp, "hostname"), []byte("d2vm-flatten-test"), perm))