89 lines
2.1 KiB
Go
89 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"math/rand"
|
|
"os"
|
|
)
|
|
|
|
func ExampleAggregateVersions() {
|
|
names := []string{
|
|
"dlkjsgljk",
|
|
"v1.20.16",
|
|
"v1.19.8_containerd.1.4.4",
|
|
"v1.20.15_containerd.1.4.13",
|
|
"v1.20.1_containerd.1.4.3",
|
|
"lkjzsfgj",
|
|
"v1.20.9_containerd.1.4.8",
|
|
"v1.21.0_containerd.1.4.4",
|
|
"v1.21.10_containerd.1.4.12",
|
|
"v1.21.10_containerd.1.4.13",
|
|
"v1.21.10_containerd.1.5.10",
|
|
"v1.21.10_containerd.1.5.9",
|
|
"v1.21.11_containerd.1.4.13",
|
|
"v1.21.14_containerd.1.5.16",
|
|
"v1.21.9_containerd.1.5.9",
|
|
}
|
|
|
|
rand.Shuffle(len(names), func(i, j int) {
|
|
names[i], names[j] = names[j], names[i]
|
|
})
|
|
|
|
agg := aggregateVersions(names)
|
|
|
|
enc := json.NewEncoder(os.Stdout)
|
|
enc.SetIndent("", " ")
|
|
enc.Encode(agg)
|
|
|
|
// Output:
|
|
// {
|
|
// "1": {
|
|
// "Latest": "v1.21.14_containerd.1.5.16",
|
|
// "All": [
|
|
// "v1.19.8_containerd.1.4.4",
|
|
// "v1.20.1_containerd.1.4.3",
|
|
// "v1.20.9_containerd.1.4.8",
|
|
// "v1.20.15_containerd.1.4.13",
|
|
// "v1.20.16",
|
|
// "v1.21.0_containerd.1.4.4",
|
|
// "v1.21.9_containerd.1.5.9",
|
|
// "v1.21.10_containerd.1.4.12",
|
|
// "v1.21.10_containerd.1.4.13",
|
|
// "v1.21.10_containerd.1.5.9",
|
|
// "v1.21.10_containerd.1.5.10",
|
|
// "v1.21.11_containerd.1.4.13",
|
|
// "v1.21.14_containerd.1.5.16"
|
|
// ]
|
|
// },
|
|
// "1.19": {
|
|
// "Latest": "v1.19.8_containerd.1.4.4",
|
|
// "All": [
|
|
// "v1.19.8_containerd.1.4.4"
|
|
// ]
|
|
// },
|
|
// "1.20": {
|
|
// "Latest": "v1.20.16",
|
|
// "All": [
|
|
// "v1.20.1_containerd.1.4.3",
|
|
// "v1.20.9_containerd.1.4.8",
|
|
// "v1.20.15_containerd.1.4.13",
|
|
// "v1.20.16"
|
|
// ]
|
|
// },
|
|
// "1.21": {
|
|
// "Latest": "v1.21.14_containerd.1.5.16",
|
|
// "All": [
|
|
// "v1.21.0_containerd.1.4.4",
|
|
// "v1.21.9_containerd.1.5.9",
|
|
// "v1.21.10_containerd.1.4.12",
|
|
// "v1.21.10_containerd.1.4.13",
|
|
// "v1.21.10_containerd.1.5.9",
|
|
// "v1.21.10_containerd.1.5.10",
|
|
// "v1.21.11_containerd.1.4.13",
|
|
// "v1.21.14_containerd.1.5.16"
|
|
// ]
|
|
// }
|
|
// }
|
|
|
|
}
|