func main()

in main.go [33:73]


func main() {
	var credFile string
	var raw bool
	flagSet := flag.NewFlagSet("docker-credential-file-gen", flag.ExitOnError)
	flagSet.StringVar(&credFile, "output", ".docker-config.json", "resulting docker credential file path")
	flagSet.BoolVar(&raw, "raw", false, "skip logging and write the output directly to file")
	flagSet.Usage = func() {
		fmt.Fprintf(flagSet.Output(), "usage: %s [-output output]\n\n", flagSet.Name())
		fmt.Fprintf(flagSet.Output(), "generates a json formatted with all the the docker registry credentials found in the credential store\n\n")
		fmt.Fprintf(flagSet.Output(), "available configuration options:\n\n")
		flagSet.PrintDefaults()
	}

	loggerFlags := log.Lshortfile | log.Lmsgprefix
	errLogger := log.New(os.Stderr, "ERROR ", loggerFlags)

	if err := flagSet.Parse(os.Args[1:]); err != nil {
		errLogger.Println(err)
		os.Exit(1)
	}

	out := io.Writer(os.Stdout)
	if raw {
		out = io.Discard
	}
	logger := log.New(out, "INFO ", loggerFlags)
	logger.Println("loading docker configuration file from system")
	cfgFile := config.LoadDefaultConfigFile(os.Stderr)

	credentials, err := dockerconfig.LoadCredentials(cfgFile)
	if err != nil {
		errLogger.Println(err)
		os.Exit(2)
	}

	logger.Printf("generating docker configuration file: %s\n", credFile)
	if err := writeFile(credFile, credentials); err != nil {
		errLogger.Println(err)
		os.Exit(3)
	}
}