Skip to content

Commit 7aa89a6

Browse files
committed
feat: parse yaml from alpine latest-releases
1 parent 67888cc commit 7aa89a6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lib/rootfs/data.rb

+26
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,31 @@ def from_gentoo_txt(str, keywords)
5959
end
6060
results
6161
end
62+
63+
def from_alpine_yaml(str)
64+
results = {}
65+
flavors = str.split("-\n")
66+
flavors.each do |flavor|
67+
next unless flavor.include?("flavor: alpine-minirootfs")
68+
69+
lines = flavor.split("\n")
70+
lines.each do |line|
71+
line = line.delete_prefix(" ")
72+
arr = line.split(":")
73+
key = arr[0]
74+
value = arr[1]
75+
value = value.delete_prefix(" ") if value
76+
77+
results[:version] = value if key == "version"
78+
results[:file] = value if key == "file"
79+
if key == "sha256"
80+
results[:sha256] = value
81+
break
82+
end
83+
end
84+
break
85+
end
86+
results
87+
end
6288
end
6389
end

0 commit comments

Comments
 (0)