func main()

in scripts/find-trace-of-missing-projects/main.go [72:115]


func main() {
	wd, err := os.Getwd()
	if err != nil {
		log.Printf("ERROR can't get current working directory: %s", err)
		os.Exit(1)
	}

	httpClient := &http.Client{}

	inputList := flag.String("list", "missing-project-vsid.lst", "newline-delimited file of vsids to look for")
	scanPath := flag.String("path", wd, "path to search in (non-recursive)")
	plutocoreBase := flag.String("url","http://localhost:8000", "base URL to pluto-core, no trailing /")
	storageId := flag.Int("storageId", 1, "storage ID to import the files onto")
	bearerTokenFile := flag.String("bearer","token.secret", "file that contains the bearer token to use for auth")
	flag.Parse()

	vsidList,err := loadList(inputList)
	if err != nil {
		log.Printf("ERROR Could not load %s: %s", *inputList, err)
		os.Exit(1)
	}

	bearerTokenContent, err := loadBearerToken(bearerTokenFile)
	if err != nil {
		log.Printf("ERROR Could not load bearer token data from %s: %s", *bearerTokenFile, err)
		os.Exit(1)
	}

	for _, vsid := range *vsidList {
		maybePathPtr, err := findFile(vsid, scanPath)
		if err != nil {
			log.Fatalf("ERROR Could not scan for %s: %s", vsid, err)
		}
		if maybePathPtr!=nil {
			log.Printf("Got %s\t%s\n", vsid, *maybePathPtr)
			sendErr := sendToPlutoCore(httpClient, *plutocoreBase, *maybePathPtr, vsid, *storageId, bearerTokenContent)
			if sendErr != nil {
				log.Printf("ERROR Could not send %s to %s as %s: %s", *maybePathPtr, *plutocoreBase, vsid, sendErr)
				os.Exit(2)
			}
		}
	}
	log.Printf("All done")
}