Skip to content

Commit 9a90d76

Browse files
committed
fix formatting and ensurePackageCacheCleanup() on azl4
1 parent 9f6665c commit 9a90d76

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

toolkit/tools/pkg/imagecustomizerlib/customizepackages_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,21 @@ func ensurePackageCacheCleanup(t *testing.T, imageConnection *imageconnection.Im
382382
baseImageInfo testBaseImageInfo,
383383
) {
384384
t.Helper()
385-
if baseImageInfo.Distro == baseImageDistroUbuntu {
385+
switch baseImageInfo.Distro {
386+
case baseImageDistroUbuntu:
386387
ensureAptCacheCleanup(t, imageConnection)
387388
ensureAptServicePreventionRestored(t, imageConnection)
388-
} else {
389-
ensureTdnfCacheCleanup(t, imageConnection, "/var/cache/tdnf", baseImageInfo)
389+
case baseImageDistroAzureLinux:
390+
switch baseImageInfo.Version {
391+
case baseImageVersionAzl2, baseImageVersionAzl3:
392+
ensureRpmCacheCleanup(t, imageConnection, "/var/cache/tdnf", baseImageInfo)
393+
case baseImageVersionAzl4:
394+
ensureRpmCacheCleanup(t, imageConnection, "/var/cache/dnf", baseImageInfo)
395+
default:
396+
t.Fatalf("unsupported Azure Linux version for cache cleanup: %s", baseImageInfo.Version)
397+
}
398+
default:
399+
t.Fatalf("unsupported distro for cache cleanup: %s", baseImageInfo.Distro)
390400
}
391401
}
392402

@@ -558,7 +568,7 @@ func testCustomizeImagePackagesBadRepoHelper(t *testing.T, baseImageInfo testBas
558568
assert.ErrorIs(t, err, ErrPackageRepoMetadataRefresh)
559569
}
560570

561-
func ensureTdnfCacheCleanup(t *testing.T, imageConnection *imageconnection.ImageConnection, dirPath string,
571+
func ensureRpmCacheCleanup(t *testing.T, imageConnection *imageconnection.ImageConnection, dirPath string,
562572
baseImageInfo testBaseImageInfo,
563573
) {
564574
// Array to capture all the files of the provided root directory

toolkit/tools/pkg/imagecustomizerlib/liveosisobuilder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ func createLiveOSFromRawHelper(ctx context.Context, buildDir string, inputArtifa
198198

199199
logger.Log.Debugf("Connecting to raw image (%s)", rawImageFile)
200200
rawImageConnection, _, _, _, err := connectToExistingImage(ctx, rawImageFile, isoBuildDir, "readonly-rootfs-mount",
201-
false /*includeDefaultMounts*/, false /*readonly*/, false /*readonlyVerity*/, false /*ignoreOverlays*/,
201+
false /*includeDefaultMounts*/, false /*readonly*/, false /*readonlyVerity*/, false, /*ignoreOverlays*/
202202
distroHandler)
203203
if err != nil {
204204
return err

0 commit comments

Comments
 (0)