Ejemplo n.º 1
0
func writeS3FileToPath(file string, bucket *s3.Bucket, path string) error {
	data, err := bucket.Get(path)
	if err != nil {
		return err
	}
	perms := os.FileMode(0644)

	err = ioutil.WriteFile(file, data, perms)
	if err != nil {
		return err
	}

	return nil
}
Ejemplo n.º 2
0
func writeS3FileToS3(sourceBucket, targetBucket *s3.Bucket, sourceKeyPath, targetKeyPath string) error {
	data, err := sourceBucket.Get(sourceKeyPath)
	if err != nil {
		return err
	}

	contType := mime.TypeByExtension(filepath.Ext(sourceKeyPath))
	Perms := s3.ACL("private")

	if err := targetBucket.Put(targetKeyPath, data, contType, Perms); err != nil {
		return err
	}

	return nil
}
			BeforeEach(func() {
				request.Params.File = "number"
			})

			Context("when a valid version is in the file", func() {
				BeforeEach(func() {
					err := ioutil.WriteFile(filepath.Join(source, "number"), []byte("1.2.3"), 0644)
					Ω(err).ShouldNot(HaveOccurred())
				})

				It("reports the version as the resource's version", func() {
					Ω(response.Version.Number).Should(Equal("1.2.3"))
				})

				It("saves the contents of the file in the configured bucket", func() {
					contents, err := bucket.Get(key)
					Ω(err).ShouldNot(HaveOccurred())

					Ω(string(contents)).Should(Equal("1.2.3"))
				})
			})
		})

		Context("when bumping the version", func() {
			BeforeEach(func() {
				err := bucket.Put(key, []byte("1.2.3"), "text/plain", s3.Private)
				Ω(err).ShouldNot(HaveOccurred())
			})

			for bump, result := range map[string]string{
				"final": "1.2.3",