func diff()

in astro/terraform/policy_diff.go [78:98]


func diff(differ, file1, file2 string) ([]byte, error) {
	cmd := exec.Command(differ, "-u", file1, file2)
	out, err := cmd.Output()

	// We only want to throw an error here if the exit status was 2 or
	// higher. From the diff man page: "Exit status is 0 if inputs are the
	// same, 1 if different, 2 if trouble."
	if err != nil {
		exitErr, ok := err.(*exec.ExitError)
		if !ok {
			return nil, err
		}

		status, ok := exitErr.Sys().(syscall.WaitStatus)
		if !ok || status.ExitStatus() > 1 {
			return nil, err
		}
	}

	return out, nil
}