Skip to content

Commit 21d3518

Browse files
committed
resolve feedback
1 parent 7073672 commit 21d3518

File tree

5 files changed

+76
-58
lines changed

5 files changed

+76
-58
lines changed

docs/imagecustomizer/developer-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sudo go test -C ./toolkit/tools ./...
4747
2. Download the test RPM files:
4848

4949
```bash
50-
./toolkit/tools/internal/testutils/testrpms/download-test-rpms.sh
50+
./toolkit/tools/internal/testutils/testrpms/download-test-utils.sh
5151
```
5252

5353
3. Run the tests:

toolkit/tools/internal/testutils/testrpms/download-test-rpms.sh

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,21 @@
1-
#!/usr/bin/env bash
2-
set -eu
3-
4-
SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
5-
CONTAINER_TAG="imagecustomizertestrpms:latest"
6-
DOCKERFILE_DIR="$SCRIPT_DIR/downloader"
7-
8-
AZURELINUX_2_CONTAINER_IMAGE="mcr.microsoft.com/cbl-mariner/base/core:2.0"
9-
AZURELINUX_3_CONTAINER_IMAGE="mcr.microsoft.com/azurelinux/base/core:3.0"
10-
11-
IMAGE_VERSION="2.0"
12-
13-
IMAGE_CREATOR="false"
14-
TOOLS_FILE="$SCRIPT_DIR/tools.tar.gz"
1+
#!/bin/bash
152

3+
set -e
4+
CONTAINER_IMAGE="$1"
5+
IMAGE_CREATOR="$2"
166

17-
while getopts "s:t:" flag
18-
do
19-
case "${flag}" in
20-
s) IMAGE_CREATOR="$OPTARG";;
21-
t) IMAGE_VERSION="$OPTARG";;
22-
h) ;;&
23-
?)
24-
echo "Usage: download-test-rpms.sh [-t IMAGE_VERSION] [-s IMAGE_CREATOR]"
25-
echo ""
26-
echo "Args:"
27-
echo " -t IMAGE_VERSION The Azure Image version to download the RPMs for."
28-
echo " -s IMAGE_CREATOR If set to true, the script will create a tar.gz file with the tools and download the rpms needed to test imagecreator."
29-
echo " -h Show help"
30-
exit 1;;
31-
esac
32-
done
337

34-
35-
case "${IMAGE_VERSION}" in
36-
3.0)
37-
CONTAINER_IMAGE="$AZURELINUX_3_CONTAINER_IMAGE"
38-
;;
39-
2.0)
40-
CONTAINER_IMAGE="$AZURELINUX_2_CONTAINER_IMAGE"
41-
;;
42-
*)
43-
echo "error: unsupported Azure Linux version: $IMAGE_VERSION"
44-
exit 1;;
45-
esac
46-
47-
set -x
48-
49-
# call the script to create the tools file if requested
50-
if [ "$IMAGE_CREATOR" = "true" ]; then
51-
echo "Creating tools file: $TOOLS_FILE"
52-
$SCRIPT_DIR/create-tools-file.sh "$CONTAINER_IMAGE" "$TOOLS_FILE"
53-
echo "Tools file created successfully."
54-
else
55-
echo "Skipping tools file creation."
8+
# Check if the required arguments are provided
9+
if [[ -z "$CONTAINER_IMAGE" || -z "$IMAGE_CREATOR" ]]; then
10+
echo "Usage: $0 <container_image> <image_creator>"
11+
echo "Example: $0 mcr.microsoft.com/azurelinux/base/core:3.0 true"
12+
exit 1
5613
fi
5714

15+
SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
16+
DOCKERFILE_DIR="$SCRIPT_DIR/downloader"
5817
DOWNLOADER_RPMS_DIRS="$SCRIPT_DIR/downloadedrpms"
18+
CONTAINER_TAG="imagecustomizertestrpms:latest"
5919
OUT_DIR="$DOWNLOADER_RPMS_DIRS/$IMAGE_VERSION"
6020
REPO_WITH_KEY_FILE="$DOWNLOADER_RPMS_DIRS/rpms-$IMAGE_VERSION-withkey.repo"
6121
REPO_NO_KEY_FILE="$DOWNLOADER_RPMS_DIRS/rpms-$IMAGE_VERSION-nokey.repo"
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
5+
6+
AZURELINUX_2_CONTAINER_IMAGE="mcr.microsoft.com/cbl-mariner/base/core:2.0"
7+
AZURELINUX_3_CONTAINER_IMAGE="mcr.microsoft.com/azurelinux/base/core:3.0"
8+
9+
IMAGE_VERSION="2.0"
10+
11+
IMAGE_CREATOR="false"
12+
TOOLS_FILE="$SCRIPT_DIR/tools.tar.gz"
13+
14+
15+
while getopts "s:t:" flag
16+
do
17+
case "${flag}" in
18+
s) IMAGE_CREATOR="$OPTARG";;
19+
t) IMAGE_VERSION="$OPTARG";;
20+
h) ;;&
21+
?)
22+
echo "Usage: download-test-utils.sh [-t IMAGE_VERSION] [-s IMAGE_CREATOR]"
23+
echo ""
24+
echo "Args:"
25+
echo " -t IMAGE_VERSION The Azure Image version to download the RPMs for."
26+
echo " -s IMAGE_CREATOR If set to true, the script will create a tar.gz file with the tools and download the rpms needed to test imagecreator."
27+
echo " -h Show help"
28+
exit 1;;
29+
esac
30+
done
31+
32+
33+
case "${IMAGE_VERSION}" in
34+
3.0)
35+
CONTAINER_IMAGE="$AZURELINUX_3_CONTAINER_IMAGE"
36+
;;
37+
2.0)
38+
CONTAINER_IMAGE="$AZURELINUX_2_CONTAINER_IMAGE"
39+
;;
40+
*)
41+
echo "error: unsupported Azure Linux version: $IMAGE_VERSION"
42+
exit 1;;
43+
esac
44+
45+
set -x
46+
47+
# call the script to create the tools file if requested
48+
if [ "$IMAGE_CREATOR" = "true" ]; then
49+
echo "Creating tools file: $TOOLS_FILE"
50+
$SCRIPT_DIR/create-tools-file.sh "$CONTAINER_IMAGE" "$TOOLS_FILE"
51+
echo "Tools file created successfully."
52+
else
53+
echo "Skipping tools file creation."
54+
fi
55+
56+
# call the script to download the rpms
57+
echo "Downloading test rpms for Azure Linux version: $IMAGE_VERSION"
58+
$SCRIPT_DIR/download-test-rpms.sh "$CONTAINER_IMAGE" "$IMAGE_CREATOR"
59+
echo "Test rpms downloaded successfully."

toolkit/tools/internal/testutils/testutils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func GetDownloadedRpmsDir(t *testing.T, testutilsDir string, azureLinuxVersion s
8484
// log the downloadedRpmsDir
8585
t.Logf("downloadedRpmsDir: %s", downloadedRpmsDir)
8686
t.Logf("test requires offline RPMs")
87-
t.Logf("please run toolkit/tools/internal/testutils/testrpms/download-test-rpms.sh -t %s -s %t",
87+
t.Logf("please run toolkit/tools/internal/testutils/testrpms/download-test-utils.sh -t %s -s %t",
8888
azureLinuxVersion, imagecreator)
8989
t.FailNow()
9090
}
@@ -96,7 +96,7 @@ func GetDownloadedToolsFile(t *testing.T, testutilsDir string, azureLinuxVersion
9696
GetDownloadedToolsFile := filepath.Join(testutilsDir, "testrpms/tools.tar.gz")
9797
if !assert.FileExists(t, GetDownloadedToolsFile) {
9898
t.Logf("test requires downloaded tools file")
99-
t.Logf("please run toolkit/tools/internal/testutils/testrpms/download-test-rpms.sh -t %s -s %t",
99+
t.Logf("please run toolkit/tools/internal/testutils/testrpms/download-test-utils.sh -t %s -s %t",
100100
azureLinuxVersion, imagecreator)
101101
t.FailNow()
102102
}

toolkit/tools/pkg/imagecustomizerlib/customizepackages_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ import (
2121

2222
func TestCustomizeImagePackagesAddOfflineDir(t *testing.T) {
2323
testTmpDir := filepath.Join(tmpDir, "TestCustomizeImagePackagesAddOfflineDir")
24-
baseImageInfo := testBaseImageAzl3CoreEfi
25-
baseImage := checkSkipForCustomizeImage(t, baseImageInfo)
26-
downloadedRpmsDir := testutils.GetDownloadedRpmsDir(t, testutilsDir, "2.0", false)
2724

25+
baseImage, _ := checkSkipForCustomizeDefaultImage(t)
26+
downloadedRpmsDir := testutils.GetDownloadedRpmsDir(t, testutilsDir, "2.0", false)
2827
buildDir := filepath.Join(testTmpDir, "build")
2928
outImageFilePath := filepath.Join(testTmpDir, "image.raw")
3029

0 commit comments

Comments
 (0)