Skip to content

Commit

Permalink
use rootdir instead of chroot
Browse files Browse the repository at this point in the history
  • Loading branch information
amritakohli committed Dec 20, 2024
1 parent 7d539f4 commit da32e14
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion toolkit/tools/pkg/imagecustomizerlib/customizeos.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func doOsCustomizations(buildDir string, baseConfigPath string, config *imagecus
return err
}

err = addCustomizerRelease(imageChroot, ToolVersion, buildTime, imageUuid)
err = addCustomizerRelease(imageChroot.RootDir(), ToolVersion, buildTime, imageUuid)
if err != nil {
return err
}
Expand Down
5 changes: 2 additions & 3 deletions toolkit/tools/pkg/imagecustomizerlib/releasefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ import (

"github.com/microsoft/azurelinux/toolkit/tools/internal/file"
"github.com/microsoft/azurelinux/toolkit/tools/internal/logger"
"github.com/microsoft/azurelinux/toolkit/tools/internal/safechroot"
)

func addCustomizerRelease(imageChroot *safechroot.Chroot, toolVersion string, buildTime string, imageUuid string) error {
func addCustomizerRelease(rootDir string, toolVersion string, buildTime string, imageUuid string) error {
var err error

logger.Log.Infof("Creating image customizer release file")

customizerReleaseFilePath := filepath.Join(imageChroot.RootDir(), "/etc/image-customizer-release")
customizerReleaseFilePath := filepath.Join(rootDir, "/etc/image-customizer-release")
lines := []string{
fmt.Sprintf("%s=\"%s\"", "TOOL_VERSION", toolVersion),
fmt.Sprintf("%s=\"%s\"", "BUILD_DATE", buildTime),
Expand Down
11 changes: 3 additions & 8 deletions toolkit/tools/pkg/imagecustomizerlib/releasefile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"testing"
"time"

"github.com/microsoft/azurelinux/toolkit/tools/internal/safechroot"
"github.com/stretchr/testify/assert"
)

Expand All @@ -21,23 +20,19 @@ func TestAddCustomizerRelease(t *testing.T) {
}

proposedDir := filepath.Join(tmpDir, "TestAddCustomizerRelease")
chroot := safechroot.NewChroot(proposedDir, false)
err := chroot.Initialize("", []string{}, []*safechroot.MountPoint{}, false)
assert.NoError(t, err)
defer chroot.Close(false)

err = os.MkdirAll(filepath.Join(chroot.RootDir(), "etc"), os.ModePerm)
err := os.MkdirAll(filepath.Join(proposedDir, "etc"), os.ModePerm)
assert.NoError(t, err)

expectedVersion := "0.1.0"
expectedDate := time.Now().Format("2006-01-02T15:04:05Z")
_, expectedUuid, err := createUuid()
assert.NoError(t, err)

err = addCustomizerRelease(chroot, expectedVersion, expectedDate, expectedUuid)
err = addCustomizerRelease(proposedDir, expectedVersion, expectedDate, expectedUuid)
assert.NoError(t, err)

releaseFilePath := filepath.Join(chroot.RootDir(), "etc/image-customizer-release")
releaseFilePath := filepath.Join(proposedDir, "etc/image-customizer-release")

file, err := os.Open(releaseFilePath)
if err != nil {
Expand Down

0 comments on commit da32e14

Please sign in to comment.