func printAndOutputReport(output string, data *migrator.MigrationData) {
	fmt.Println("Reports:")
	if len(data.NameConversions) != 0 {
		fp := filepath.Join(output, constants.FileConvertedNames)
		fmt.Printf("- name conversion: %s\n", fp)

		file, err := os.Create(fp)
		if err != nil {
			fmt.Printf("Unable to open report file for writing: %s\n", fp)
		} else {
			for _, n := range data.NameConversions {
				fmt.Fprintf(file, "%s -> %s\n", n.KeyV1.String(), n.KeyV3.String())
			}
		}
		file.Sync()
		file.Close()
	}

	if len(data.NameClashes) != 0 {
		fp := filepath.Join(output, constants.FileNameClashes)
		fmt.Printf("- (errors) name clashes: %s\n", fp)

		file, err := os.Create(fp)
		if err != nil {
			fmt.Printf("Unable to open report file for writing: %s\n", fp)
		} else {
			for _, n := range data.NameClashes {
				fmt.Fprintf(file, "%s and %s -> %s\n", n.KeyV1, n.OtherKeyV1, n.KeyV3)
			}
		}
		file.Sync()
		file.Close()
	}

	if len(data.ConversionErrors) != 0 {
		fp := filepath.Join(output, constants.FileConversionErrors)
		fmt.Printf("- (errors) conversion errors: %s\n", fp)

		file, err := os.Create(fp)
		if err != nil {
			fmt.Printf("Unable to open report file for writing: %s\n", fp)
		} else {
			for _, c := range data.ConversionErrors {
				fmt.Fprintf(file, "%s: %v\n", c.KeyV1, c.Cause)
			}
		}
		file.Sync()
		file.Close()
	}

	if len(data.ConvertedResourceValidationErrors) != 0 {
		fp := filepath.Join(output, constants.FileValidationErrors)
		fmt.Printf("- (errors) v3 validation errors: %s\n", fp)

		file, err := os.Create(fp)
		if err != nil {
			fmt.Printf("Unable to open report file for writing: %s\n", fp)
		} else {
			for _, c := range data.ConvertedResourceValidationErrors {
				fmt.Fprintf(file, "v1 name: %s", c.KeyV1)
				fmt.Fprintf(file, "v3 name: %s", c.KeyV3)
				fmt.Fprintf(file, "error: %s", c.Cause)
				if v3yaml, err := yaml.Marshal(c.ValueV3); err == nil {
					fmt.Fprintf(file, "v3 resource:\n%s", v3yaml)
				}
				fmt.Fprintf(file, "\n\n---\n\n")
			}
		}
		file.Sync()
		file.Close()
	}
}
// printAndOutputReport writes out a set of report files and outputs the
// files to screen.
printAndOutputReport writes out a set of report files and outputs the
files to screen.
// printAndOutputReport writes out a set of report files and outputs the // files to screen .
func printAndOutputReport(output string, data *migrator.MigrationData) {
	fmt.Println("Reports:")
	if len(data.NameConversions) != 0 {
		fp := filepath.Join(output, constants.FileConvertedNames)
		fmt.Printf("- name conversion: %s\n", fp)
		file, err := os.Create(fp)
		if err != nil {
			fmt.Printf("Unable to open report file for writing: %s\n", fp)
		} else {
			for _, n := range data.NameConversions {
				fmt.Fprintf(file, "%s -> %s\n", n.KeyV1.String(), n.KeyV3.String())
			}
		}
		file.Sync()
		file.Close()
	}
	if len(data.NameClashes) != 0 {
		fp := filepath.Join(output, constants.FileNameClashes)
		fmt.Printf("- (errors) name clashes: %s\n", fp)
		file, err := os.Create(fp)
		if err != nil {
			fmt.Printf("Unable to open report file for writing: %s\n", fp)
		} else {
			for _, n := range data.NameClashes {
				fmt.Fprintf(file, "%s and %s -> %s\n", n.KeyV1, n.OtherKeyV1, n.KeyV3)
			}
		}
		file.Sync()
		file.Close()
	}
	if len(data.ConversionErrors) != 0 {
		fp := filepath.Join(output, constants.FileConversionErrors)
		fmt.Printf("- (errors) conversion errors: %s\n", fp)
		file, err := os.Create(fp)
		if err != nil {
			fmt.Printf("Unable to open report file for writing: %s\n", fp)
		} else {
			for _, c := range data.ConversionErrors {
				fmt.Fprintf(file, "%s: %v\n", c.KeyV1, c.Cause)
			}
		}
		file.Sync()
		file.Close()
	}
	if len(data.ConvertedResourceValidationErrors) != 0 {
		fp := filepath.Join(output, constants.FileValidationErrors)
		fmt.Printf("- (errors) v3 validation errors: %s\n", fp)
		file, err := os.Create(fp)
		if err != nil {
			fmt.Printf("Unable to open report file for writing: %s\n", fp)
		} else {
			for _, c := range data.ConvertedResourceValidationErrors {
				fmt.Fprintf(file, "v1 name: %s", c.KeyV1)
				fmt.Fprintf(file, "v3 name: %s", c.KeyV3)
				fmt.Fprintf(file, "error: %s", c.Cause)
				if v3yaml, err := yaml.Marshal(c.ValueV3); err == nil {
					fmt.Fprintf(file, "v3 resource:\n%s", v3yaml)
				}
				fmt.Fprintf(file, "\n\n---\n\n")
			}
		}
		file.Sync()
		file.Close()
	}
}
func printAndOutputReport ( output string , data * migrator . MigrationData ) { fmt . Println ( " " ) if len ( data . NameConversions ) != 0 { fp := filepath . Join ( output , constants . FileConvertedNames ) fmt . Printf ( " \n " , fp ) file , err := os . Create ( fp ) if err != nil { fmt . Printf ( " \n " , fp ) } else { for _ , n := range data . NameConversions { fmt . Fprintf ( file , " \n " , n . KeyV1 . String ( ) , n . KeyV3 . String ( ) ) } } file . Sync ( ) file . Close ( ) } if len ( data . NameClashes ) != 0 { fp := filepath . Join ( output , constants . FileNameClashes ) fmt . Printf ( " \n " , fp ) file , err := os . Create ( fp ) if err != nil { fmt . Printf ( " \n " , fp ) } else { for _ , n := range data . NameClashes { fmt . Fprintf ( file , " \n " , n . KeyV1 , n . OtherKeyV1 , n . KeyV3 ) } } file . Sync ( ) file . Close ( ) } if len ( data . ConversionErrors ) != 0 { fp := filepath . Join ( output , constants . FileConversionErrors ) fmt . Printf ( " \n " , fp ) file , err := os . Create ( fp ) if err != nil { fmt . Printf ( " \n " , fp ) } else { for _ , c := range data . ConversionErrors { fmt . Fprintf ( file , " \n " , c . KeyV1 , c . Cause ) } } file . Sync ( ) file . Close ( ) } if len ( data . ConvertedResourceValidationErrors ) != 0 { fp := filepath . Join ( output , constants . FileValidationErrors ) fmt . Printf ( " \n " , fp ) file , err := os . Create ( fp ) if err != nil { fmt . Printf ( " \n " , fp ) } else { for _ , c := range data . ConvertedResourceValidationErrors { fmt . Fprintf ( file , " " , c . KeyV1 ) fmt . Fprintf ( file , " " , c . KeyV3 ) fmt . Fprintf ( file , " " , c . Cause ) if v3yaml , err := yaml . Marshal ( c . ValueV3 ) ; err == nil { fmt . Fprintf ( file , " \n " , v3yaml ) } fmt . Fprintf ( file , " \n \n \n \n " ) } } file . Sync ( ) file . Close ( ) } }
printAndOutputReport writes out a set of report files and outputs the
files to screen.
printAndOutputReport writes out a set of report files and outputs the files to screen .