From a7afc01562bf7cedc4d36f2ef127c62a716a4f84 Mon Sep 17 00:00:00 2001 From: Punit Agrawal Date: Thu, 24 Sep 2020 11:36:37 +0900 Subject: [PATCH] actions/image-partition: Consistently use artifactdir The "image-partition" action uses artifactdir in the PostMachineCleanup() step but not during the PreMachine() and PreNoMachine() steps. Also, other debos actions such as pack, unpack are relative to the specified "artifactdir" when invoking debos. Fix this inconsistency by bringing image-partition action to the fold. Also update the documentation to clarify this. Signed-off-by: Punit Agrawal --- actions/image_partition_action.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/actions/image_partition_action.go b/actions/image_partition_action.go index 6a0d5df..0037a86 100644 --- a/actions/image_partition_action.go +++ b/actions/image_partition_action.go @@ -20,7 +20,7 @@ Yaml syntax: Mandatory properties: -- imagename -- the name of the image file. +- imagename -- the name of the image file, relative to the artifact directory. - imagesize -- generated image size in human-readable form, examples: 100MB, 1GB, etc. @@ -287,7 +287,8 @@ func (i *ImagePartitionAction) triggerDeviceNodes(context *debos.DebosContext) e func (i ImagePartitionAction) PreMachine(context *debos.DebosContext, m *fakemachine.Machine, args *[]string) error { - image, err := m.CreateImage(i.ImageName, i.size) + ImagePath := path.Join(context.Artifactdir, i.ImageName) + image, err := m.CreateImage(ImagePath, i.size) if err != nil { return err } @@ -367,7 +368,8 @@ func (i ImagePartitionAction) formatPartition(p *Partition, context debos.DebosC func (i *ImagePartitionAction) PreNoMachine(context *debos.DebosContext) error { - img, err := os.OpenFile(i.ImageName, os.O_WRONLY|os.O_CREATE, 0666) + ImagePath = path.Join(context.Artifactdir, i.ImageName) + img, err := os.OpenFile(ImagePath, os.O_WRONLY|os.O_CREATE, 0666) if err != nil { return fmt.Errorf("Couldn't open image file: %v", err) } @@ -379,7 +381,7 @@ func (i *ImagePartitionAction) PreNoMachine(context *debos.DebosContext) error { img.Close() - i.loopDev, err = losetup.Attach(i.ImageName, 0, false) + i.loopDev, err = losetup.Attach(ImagePath, 0, false) if err != nil { return fmt.Errorf("Failed to setup loop device") }