// Takes json output from gettags and groups it by repository. Output is in json format and can be further parsed by report func main() { // Read json data from stdin (designed to support piping between binaries) input, err := parser.ReadFromStdin() if err != nil { fmt.Fprint(os.Stderr, err) flag.Usage() os.Exit(1) } // Parse the data into useful types m, err := parser.ParseManifest(input) if err != nil { fmt.Fprintf(os.Stderr, "Error parsing input json: %v", err) flag.Usage() os.Exit(1) } // Group the data into a slice of repo->dependencies values := groupByRepo(m) // Format the output to stdout output, err := json.MarshalIndent(values, "", " ") fmt.Println(string(output)) }
// Take the vendor manifest file and uses the Github APIs to retrieve the tag data for each Revision // Outputted data can be consumed by other parsers, or can be input to groupbyrepo func main() { // Load the json from stdin (designed to support piping between binaries) input, err := parser.ReadFromStdin() if err != nil { fmt.Fprint(os.Stderr, err) flag.Usage() os.Exit(1) } client = &http.Client{} // Parse the data into useful types m, err := parser.ParseManifest(input) if err != nil { fmt.Fprintf(os.Stderr, "Failed to parse input json: %v\n", err) os.Exit(1) } // Find the tag for each repository. This is done serially. var foundTag *parser.ManifestEntry if err == nil { for i, me := range m.Dependencies { foundTag, err = findTag(&me) if err != nil { break } m.Dependencies[i] = *foundTag } } // Output the original manifest data with new fields added (see ManifestEntry) if err == nil { output, _ := json.MarshalIndent(m, "", " ") fmt.Println(string(output)) } else { fmt.Fprintf(os.Stderr, "%v\n", err) } }