osbuild / images

Image builder image definition library
Apache License 2.0
23 stars 52 forks source link

many: use new `disk.PartitionTableType` instead of string #1025

Closed mvo5 closed 1 week ago

mvo5 commented 1 week ago

This commit makes use of the new `disk.PartitionTableType instead of just using an untyped string (thanks to Achilleas for adding the new type and to Tomáš for suggesting to use it more).


disk: add json marshal/unmarshal to PartitionTableType

This commit adds json marshal/unmarshal to PartitionTableType The reason is that the otk utils serialize this type as a JSON. While the json is strictly internal and we make no gurantees about it is still nicer to serialize as strings because otherwise the diff in the json looks something like:

@@ -147,7 +147,7 @@ func TestUnmarshalOutput(t *testing.T) {
       "partition-table": {
         "Size": 911,
         "UUID": "",
-        "Type": "gpt",
+        "Type": 2,
         "Partitions": [
           {
             "Start": 0,

and it is also nicer for general debug-ability.

achilleas-k commented 1 week ago

Also, can you update the top PR comment/description to avoid confusion in the future?

mvo5 commented 1 week ago

Very nice. Should we do the same for filesystem types?

Yeah, I guess we want this for GetFSType() too (and friends, not sure how many there are)

achilleas-k commented 1 week ago

Very nice. Should we do the same for filesystem types?

Yeah, I guess we want this for GetFSType() too (and friends, not sure how many there are)

Fine to do in a separate PR.