Skip to content

Commit 902370f

Browse files
efectnigorpecovnik
authored andcommitted
support refactored json format
1 parent 2376dbb commit 902370f

File tree

2 files changed

+10
-80
lines changed

2 files changed

+10
-80
lines changed

map.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
// ErrUnsupportedFormat is returned when an unsupported map format is used.
2020
var ErrUnsupportedFormat = errors.New("unsupported map format")
21+
var extensionFormats = []string{".asc", ".sha", ".torrent"}
2122

2223
// loadMapFile loads a file as a map
2324
func loadMapFile(file string, specialExtensions map[string]string) (map[string]string, error) {
@@ -128,18 +129,18 @@ func loadMapJSON(f io.Reader, specialExtensions map[string]string) (map[string]s
128129
}
129130
}
130131

131-
sb.WriteString(".")
132+
// Also add entries for .asc .sha and .torrent
133+
for _, ext := range extensionFormats {
134+
if strings.HasSuffix(file.Extension, ext) {
135+
continue
136+
}
132137

133-
if strings.HasSuffix(file.Extension, ".sha") {
134-
sb.WriteString("sha")
135-
} else if strings.HasSuffix(file.Extension, ".asc") {
136-
sb.WriteString("asc")
137-
} else if strings.HasSuffix(file.Extension, ".torrent") {
138-
sb.WriteString("torrent")
139-
} else {
140-
sb.WriteString(file.Extension)
138+
m[sb.String()+ext] = u.Path + ext
141139
}
142140

141+
sb.WriteString(".")
142+
sb.WriteString(file.Extension)
143+
143144
m[sb.String()] = u.Path // Add board into the map with an extension
144145
}
145146

map_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,6 @@ var _ = Describe("Map", func() {
6060
"download_repository": "archive",
6161
"file_extension": "img.xz"
6262
},
63-
{
64-
"board_slug": "khadas-vim1",
65-
"file_url": "https://dl.armbian.com/khadas-vim1/archive/Armbian_23.11.1_Khadas-vim1_bookworm_current_6.1.63_xfce_desktop.img.xz.sha",
66-
"file_updated": "2023-11-30T01:06:34Z",
67-
"file_size": "1605260504",
68-
"distro_release": "bookworm",
69-
"kernel_branch": "current",
70-
"image_variant": "xfce",
71-
"preinstalled_application": "",
72-
"promoted": "false",
73-
"download_repository": "archive",
74-
"file_extension": "img.xz.sha"
75-
},
7663
{
7764
"board_slug": "khadas-vim1",
7865
"file_url": "https://dl.armbian.com/khadas-vim1/archive/Armbian_23.11.1_Khadas-vim1_bookworm_current_6.1.63_xfce_desktop.img.xz",
@@ -112,34 +99,6 @@ var _ = Describe("Map", func() {
11299
"promoted": "true",
113100
"download_repository": "archive",
114101
"file_extension": "oowow.img.xz"
115-
},
116-
{
117-
"board_slug": "khadas-vim4",
118-
"armbian_version": "23.11.1",
119-
"file_url": "https://dl.armbian.com/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz.asc",
120-
"file_updated": "2023-11-30T01:03:05Z",
121-
"file_size": "833",
122-
"distro_release": "bookworm",
123-
"kernel_branch": "legacy",
124-
"image_variant": "server",
125-
"preinstalled_application": "",
126-
"promoted": "true",
127-
"download_repository": "archive",
128-
"file_extension": "oowow.img.xz.asc"
129-
},
130-
{
131-
"board_slug": "khadas-vim4",
132-
"armbian_version": "23.11.1",
133-
"file_url": "https://dl.armbian.com/khadas-vim4/archive/Armbian_23.11.1_Khadas-vim4_bookworm_legacy_5.4.180.oowow.img.xz.sha",
134-
"file_updated": "2023-11-30T01:03:05Z",
135-
"file_size": "178",
136-
"distro_release": "bookworm",
137-
"kernel_branch": "legacy",
138-
"image_variant": "server",
139-
"preinstalled_application": "",
140-
"promoted": "true",
141-
"download_repository": "archive",
142-
"file_extension": "oowow.img.xz.sha"
143102
},
144103
{
145104
"board_slug": "uefi-arm64",
@@ -155,36 +114,6 @@ var _ = Describe("Map", func() {
155114
"promoted": "false",
156115
"download_repository": "archive",
157116
"file_extension": "img.qcow2"
158-
},
159-
{
160-
"board_slug": "uefi-arm64",
161-
"armbian_version": "24.5.5",
162-
"file_url": "https://dl.armbian.com/uefi-arm64/archive/Armbian_24.5.5_Uefi-arm64_bookworm_current_6.6.42_minimal.img.qcow2.asc",
163-
"redi_url": "https://dl.armbian.com/uefi-arm64/Bookworm_current_minimal.asc",
164-
"file_updated": "2024-07-25T18:01:20Z",
165-
"file_size": "833",
166-
"distro_release": "bookworm",
167-
"kernel_branch": "current",
168-
"image_variant": "minimal",
169-
"preinstalled_application": "",
170-
"promoted": "false",
171-
"download_repository": "archive",
172-
"file_extension": "img.qcow2.asc"
173-
},
174-
{
175-
"board_slug": "uefi-arm64",
176-
"armbian_version": "24.5.5",
177-
"file_url": "https://dl.armbian.com/uefi-arm64/archive/Armbian_24.5.5_Uefi-arm64_bookworm_current_6.6.42_minimal.img.qcow2.sha",
178-
"redi_url": "https://dl.armbian.com/uefi-arm64/Bookworm_current_minimal.sha",
179-
"file_updated": "2024-07-25T18:01:20Z",
180-
"file_size": "194",
181-
"distro_release": "bookworm",
182-
"kernel_branch": "current",
183-
"image_variant": "minimal",
184-
"preinstalled_application": "",
185-
"promoted": "false",
186-
"download_repository": "archive",
187-
"file_extension": "img.qcow2.sha"
188117
},
189118
{
190119
"board_slug": "qemu-uboot-arm64",

0 commit comments

Comments
 (0)