Ejemplo n.º 1
0
func prepareStagingFilesystem(cloudfockerHome string) {
	if err := utils.CreateAndCleanAppDirs(cloudfockerHome); err != nil {
		log.Fatalf(" %s", err)
	}
	if err := buildpack.AtLeastOneBuildpackIn(cloudfockerHome + "/buildpacks"); err != nil {
		log.Fatalf(" %s", err)
	}
	if err := utils.CopyFockerBinaryToOwnDir(cloudfockerHome); err != nil {
		log.Fatalf(" %s", err)
	}
}
Ejemplo n.º 2
0
			parentDir, _ := ioutil.TempDir(os.TempDir(), "utils-test-subdirs")
			os.Mkdir(parentDir+"/dir1", 0755)
			os.Mkdir(parentDir+"/dir2", 0755)
			ioutil.WriteFile(parentDir+"/testfile", []byte("test"), 0644)
			dirs, err := utils.SubDirs(parentDir)
			Expect(err).ShouldNot(HaveOccurred())
			Expect(dirs).Should(ContainElement("dir1"))
			Expect(dirs).Should(ContainElement("dir2"))
			Expect(dirs).ShouldNot(ContainElement("testfile"))
			os.RemoveAll(parentDir)
		})
	})
	Describe("Copying the focker binary to its own directory", func() {
		It("should create a focker subdirectory with the fock binary inside it", func() {
			cloudfockerHome, _ := ioutil.TempDir(os.TempDir(), "utils-test-cp-focker")
			err := utils.CopyFockerBinaryToOwnDir(cloudfockerHome)
			Expect(err).ShouldNot(HaveOccurred())
			fockerOwnDirFile, err := os.Open(cloudfockerHome + "/focker")
			fockerOwnDirContents, err := fockerOwnDirFile.Readdirnames(0)
			Expect(fockerOwnDirContents, err).Should(ContainElement("fock"))
			info, _ := os.Stat(cloudfockerHome + "/focker/fock")
			mode := info.Mode()
			Expect(mode).To(Equal(os.FileMode(0755)))
			os.RemoveAll(cloudfockerHome)
		})
	})
	Describe("Adding the soldier run script to a directory", func() {
		It("should create a script called cloudfocker-start.sh with expected contents", func() {
			appDir, _ := ioutil.TempDir(os.TempDir(), "utils-test-soldier")
			utils.AddSoldierRunScript(appDir)
			written, _ := ioutil.ReadFile(appDir + "/cloudfocker-start-1c4352a23e52040ddb1857d7675fe3cc.sh")