func newFakeBlobStore(ctx context.Context) (blobStore blob.Store, err error) {
	// Create a bucket.
	bucket := gcsfake.NewFakeBucket(timeutil.RealClock(), "some_bucket")

	// And a cryptoer.
	_, crypter, err := wiring.MakeRegistryAndCrypter(ctx, "password", bucket)
	if err != nil {
		err = fmt.Errorf("MakeRegistryAndCrypter: %v", err)
		return
	}

	// And the blob store.
	blobStore, err = wiring.MakeBlobStore(bucket, crypter, util.NewStringSet())
	if err != nil {
		err = fmt.Errorf("MakeBlobStore: %v", err)
		return
	}

	return
}
示例#2
0
func initRegistryAndCrypter(ctx context.Context) {
	var err error
	defer func() {
		if err != nil {
			log.Fatalln(err)
		}
	}()

	bucket := getBucket(ctx)
	password := getPassword()

	gRegistry, gCrypter, err = wiring.MakeRegistryAndCrypter(
		ctx,
		password,
		bucket)

	if err != nil {
		err = fmt.Errorf("MakeRegistryAndCrypter: %v", err)
		return
	}
}