Ejemplo n.º 1
0
func (app *app) setupBlobstore(blobstoreSettings boshsettings.Blobstore, blobManager boshblob.BlobManagerInterface) (boshblob.Blobstore, error) {
	blobstoreProvider := boshblob.NewProvider(
		app.platform.GetFs(),
		app.platform.GetRunner(),
		app.dirProvider.EtcDir(),
		app.digestProvider,
		app.logger,
	)

	blobstore, err := blobstoreProvider.Get(blobstoreSettings.Type, blobstoreSettings.Options)
	if err != nil {
		return nil, bosherr.WrapError(err, "Getting blobstore")
	}

	return boshagentblobstore.NewCascadingBlobstore(blobstore, blobManager, app.logger), nil
}
Ejemplo n.º 2
0
	boshlog "github.com/cloudfoundry/bosh-utils/logger"
)

var _ = Describe("cascadingBlobstore", func() {
	var (
		innerBlobstore     *fakeblob.FakeBlobstore
		blobManager        *fakeblob.FakeBlobManagerInterface
		cascadingBlobstore boshblob.Blobstore
	)

	BeforeEach(func() {
		innerBlobstore = &fakeblob.FakeBlobstore{}
		blobManager = &fakeblob.FakeBlobManagerInterface{}
		logger := boshlog.NewLogger(boshlog.LevelNone)

		cascadingBlobstore = blobstore.NewCascadingBlobstore(innerBlobstore, blobManager, logger)
	})

	Describe("Get", func() {
		Describe("when blobManager returns the file path", func() {
			It("returns the path provided by the blobManager", func() {
				blobManager.GetPathReturns("/path/to-copy/of-blob", nil)

				filename, err := cascadingBlobstore.Get("blobID", boshcrypto.NewDigest("sha1", "fake-checksum"))

				Expect(err).To(BeNil())
				Expect(filename).To(Equal("/path/to-copy/of-blob"))

				Expect(blobManager.GetPathCallCount()).To(Equal(1))
				Expect(blobManager.GetPathArgsForCall(0)).To(Equal("blobID"))