示例#1
0
func NewBuildpackRunner(buildpackDir string) *buildpackrunner.Runner {
	prepareMd5BuildpacksDir(buildpackDir, "/tmp/buildpacks")
	var err error
	dirs := []string{}
	if dirs, err = utils.SubDirs(buildpackDir); err != nil {
		log.Fatalf(" %s", err)
	}
	config := models.NewCircusTailorConfig(dirs)
	return buildpackrunner.New(&config)
}
示例#2
0
func List(writer io.Writer, buildpackDir string) (err error) {
	if buildpacks, err := utils.SubDirs(buildpackDir); err == nil {
		for _, buildpack := range buildpacks {
			fmt.Fprintln(writer, buildpack)
		}
		if len(buildpacks) == 0 {
			fmt.Fprintln(writer, "No buildpacks installed")
		}
	}
	return err
}
示例#3
0
func AtLeastOneBuildpackIn(dir string) error {
	var subDirs []string
	var err error
	if subDirs, err = utils.SubDirs(dir); err != nil {
		return err
	}
	if len(subDirs) == 0 {
		return fmt.Errorf("No buildpacks detected - please add one")
	}
	return nil
}
示例#4
0
func prepareMd5BuildpacksDir(src string, dst string) {
	os.MkdirAll(src, 0755)
	os.MkdirAll(dst, 0755)
	var err error
	dirs := []string{}
	if dirs, err = utils.SubDirs(src); err != nil {
		log.Fatalf(" %s", err)
	}
	for _, dir := range dirs {
		if err := os.Symlink(src+"/"+dir, dst+"/"+md5sum(dir)); err != nil {
			log.Fatalf(" %s", err)
		}
	}
}
示例#5
0
						Expect(dirContents, err).ShouldNot(ContainElement("testfile"))
					} else {
						Expect(dirContents, err).Should(ContainElement("testfile"))
					}
				}
				os.RemoveAll(cloudfockerHome)
			})
		})
	})
	Describe("Finding the subdirectories in a directory", func() {
		It("should return a slice of found subdirectories", func() {
			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"))