package main import ( "encoding/json" "flag" "fmt" "os" "path/filepath" oci "github.com/opencontainers/image-spec/specs-go/v1" ) func main() { os.Exit(run()) } func run() int { flag.Parse() // open and parse the image index json file imageLayout := flag.Arg(0) imageLayoutAbs, err := filepath.Abs(imageLayout) if err != nil { fmt.Println(err) return 1 } layoutFS := os.DirFS(imageLayoutAbs) manifestFile := "manifest_list.new.json" file, err := layoutFS.Open(manifestFile) if err != nil { fmt.Println(err) return 1 } defer file.Close() dec := json.NewDecoder(file) idx := &oci.Index{} if err := dec.Decode(idx); err != nil { fmt.Println(err) return 1 } // search manifest list for all required platforms foundPltfs := map[string]bool{ "linux/amd64": false, "linux/arm64": false, } for _, desc := range idx.Manifests { foundPltfs[fmt.Sprintf("%s/%s", desc.Platform.OS, desc.Platform.Architecture)] = true } for platform, found := range foundPltfs { if !found { fmt.Printf("failed to find required platform: %s\n", platform) os.Exit(1) } } return 0 }