コード例 #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
ファイル: groupbyrepo.go プロジェクト: kjplatz/vic
// 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)
	}
}