Example #1
0
func main() {
	region := flag.String("region", defaultRegion, "AWS region to use")
	bucket := flag.String("bucket", "", "AWS S3 bucket containing the revision")
	revisionPath := flag.String("revision-path", "/", "AWS S3 path in the bucket where revisions are stored")
	installPath := flag.String("install-path", "/var/www", "Path to deploy revisions to")

	flag.Usage = usage
	flag.Parse()

	if flag.NArg() < 1 {
		log.Println("Argument required")
		usage()
		os.Exit(1)
	}

	revision := flag.Arg(0)

	compressedReleasePath, err := downloader.Get(&downloader.S3Config{
		Region:       region,
		Bucket:       bucket,
		RevisionPath: revisionPath,
		Revision:     &revision,
	})
	defer os.Remove(compressedReleasePath)
	if err != nil {
		log.Fatal("Failed to download revision: ", err)
	}

	err = extractor.Extract(installPath, &compressedReleasePath)
	if err != nil {
		log.Fatal("Failed to extract release: ", err)
	}

	log.Println(installPath)
}
Example #2
0
	BeforeEach(func() {
		var err error

		extractionDest, err = ioutil.TempDir("", "extractor")
		Expect(err).NotTo(HaveOccurred())
	})

	AfterEach(func() {
		os.RemoveAll(extractionDest)
	})

	Describe("with bad file that is", func() {
		Context("missing", func() {
			It("returns an error", func() {
				file := "unknown_file"
				err := extractor.Extract(&extractionDest, &file)
				Expect(err).To(HaveOccurred())
			})
		})

		Context("unknown format", func() {
			It("returns an error", func() {
				file := "fixtures/uncompressed_file.txt"
				err := extractor.Extract(&extractionDest, &file)
				Expect(err).To(HaveOccurred())
			})
		})
	})

	Describe("with good file that is", func() {
		Context("a zip archive", func() {