示例#1
0
func (f Focker) RunStager(writer io.Writer, appDir string) error {
	prepareStagingFilesystem(utils.CloudfockerHome())
	stagingAppDir := prepareStagingApp(appDir, utils.CloudfockerHome()+"/staging")
	runConfig := config.NewStageRunConfig(stagingAppDir)
	cli, Stdout, stdoutpipe := docker.GetNewClient()
	docker.RunConfiguredContainer(cli, Stdout, stdoutpipe, writer, runConfig)
	f.DeleteContainer(writer, runConfig.ContainerName)
	return stager.ValidateStagedApp(utils.CloudfockerHome())
}
示例#2
0
			Expect(contents, err).Should(ContainElement(md5BuildpackName))
			md5Buildpack, err := os.Open(md5BuildpackDir.Name() + "/" + md5BuildpackName)
			buildpackContents, err := md5Buildpack.Readdirnames(0)
			Expect(buildpackContents, err).Should(ContainElement("testfile"))
			os.RemoveAll(buildpackDir)
			os.RemoveAll("/tmp/buildpacks")
		})
	})

	Describe("Validating a staged application", func() {
		Context("with something that looks like a staged application", func() {
			It("should not return an error", func() {
				cfhome, _ := ioutil.TempDir(os.TempDir(), "stager-test-staged")
				os.MkdirAll(cfhome+"/droplet/app", 0755)
				ioutil.WriteFile(cfhome+"/droplet"+"/staging_info.yml", []byte("test-staging-info"), 0644)
				err := stager.ValidateStagedApp(cfhome)
				Expect(err).ShouldNot(HaveOccurred())
				os.RemoveAll(cfhome)
			})
		})
		Context("without something that looks like a staged application", func() {
			Context("because we have no droplet", func() {
				It("should return an error about a missing droplet", func() {
					cfhome, _ := ioutil.TempDir(os.TempDir(), "stager-test-staged")
					err := stager.ValidateStagedApp(cfhome)
					Expect(err).Should(MatchError("Staging failed - have you added a buildpack for this type of application?"))
					os.RemoveAll(cfhome)
				})
			})
			Context("because we have no staging_info.yml", func() {
				It("should return an error about missing staging info", func() {