Exemplo n.º 1
0
func (u *s3upload) uploadToBucket(bucket s3.Bucket, sourcePath string) error {
	logData := lager.Data{
		"source_path": sourcePath,
		"target_path": u.targetPath,
		"bucket":      u.bucketName,
	}

	u.logInfo("upload", "starting", logData)

	err := bucket.Upload(sourcePath, u.targetPath)
	if err != nil {
		u.logError("upload", err, logData)
		return err
	}

	u.logInfo("upload", "done", logData)

	return nil
}
Exemplo n.º 2
0
			bucket = s3.NewBucket(
				bucketName,
				expectedEndpoint,
				expectedKey,
				expectedSecret,
				logger,
				s3.InjectCommandFactory(cmdFactory),
			)

			err := os.Setenv(expectedEnvKey, expectedEnvVar)
			Expect(err).ToNot(HaveOccurred())
		})

		JustBeforeEach(func() {
			uploadErr = bucket.Upload(expectedSourcePath, targetPath)
		})

		It("creates a command with the right arguments", func() {
			expectedCommand := fmt.Sprintf(
				"aws s3 cp %s %s --endpoint-url %s",
				expectedSourcePath,
				expectedBucketPath,
				expectedEndpoint,
			)
			Expect(generatedCmd).To(Equal(expectedCommand))
		})

		It("executes the generated command", func() {
			Expect(cmd.CombinedOutputInvoked).To(Equal(1))
		})