in gcs-fetcher/cmd/gcs-uploader/main.go [43:86]
func main() {
flag.Parse()
if *help {
fmt.Println("Incrementally uploads source files to Google Cloud Storage")
flag.PrintDefaults()
return
}
if *location == "" {
log.Fatalln("Must specify --location")
}
bucket, object, generation, err := common.ParseBucketObject(*location)
if err != nil {
log.Fatalf("parsing location from %q: %v", *location, err)
}
if generation != 0 {
log.Fatalln("cannot specify manifest file generation")
}
ctx := context.Background()
client, err := storage.NewClient(ctx, option.WithUserAgent(userAgent))
if err != nil {
log.Fatalf("Failed to create new GCS client: %v", err)
}
u := uploader.New(ctx, realGCS{client}, realOS{}, bucket, object, *workerCount)
filepath.Walk(*dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
u.Do(ctx, path, info)
return nil
})
if err := u.Done(ctx); err != nil {
log.Fatalf("Failed to upload: %v", err)
}
}