func Setup() { flag.Parse() var err error wd, err := os.Getwd() if err != nil { log.Fatalf("os.Getwd: %s", err) } TempDir, err = ioutil.TempDir(wd, "kebab_testing_") if err != nil { log.Fatalf("ioutil.TempDir failed: %s", err) } stdlog := log.New(os.Stderr, "RecoverableBucketLog: ", 0) PromptLog = &bucket.PromptLogger{Logger: stdlog} if *s3conf != "" { s3b, err := bucket.NewS3BucketFromFile(*s3conf) if err != nil { log.Fatalf("bucket.NewS3BucketFromFile: %s", err) } tmp := fmt.Sprintf("kebab_testing_%x", RandomBytes(4)) TempS3, err = s3b.Descend(tmp) if err != nil { log.Fatalf("Descend(%q): %s", tmp, err) } SkipS3 = false } }
func openBucket(bucketPath string) (bucket.Bucket, error) { file, err := os.Open(bucketPath) if err != nil { return nil, err } fi, err := file.Stat() if err != nil { return nil, err } if fi.IsDir() { return bucket.NewFileBucket(bucketPath) } else { b, err := bucket.NewS3BucketFromFile(bucketPath) if err != nil { return nil, fmt.Errorf("bucket.NewS3BucketFromFile: %s", err) } return b, nil } }