示例#1
0
文件: report.go 项目: kjplatz/vic
// Takes the output from groupbyrepo, plus exception data from a file, and produces a human-parsable report
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)
	}

	// Parse the data into useful types
	repos, err := parser.ParseManifestByRepo(input)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to parse input json: %v\n", err)
		os.Exit(1)
	}

	// Load the exception file into useful types
	exceptions, err := loadAndParseExceptions()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error loading exceptions file: %v\n", err)
		os.Exit(1)
	}

	// Write the report to stdout
	sort.Sort(parser.SortedManifestByRepo(repos))
	printOutput(os.Stdout, repos, exceptions)
}
示例#2
0
// 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))
}
示例#3
0
文件: gettags.go 项目: kjplatz/vic
// 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)
	}
}