コード例 #1
0
ファイル: cleaner.go プロジェクト: cloudfoundry/garden-shed
func (g *retainer) Retain(log lager.Logger, id layercake.ID) {
	g.retainedImagesMu.Lock()
	defer g.retainedImagesMu.Unlock()

	if g.retainedImages == nil {
		g.retainedImages = make(map[string]struct{})
	}

	g.retainedImages[id.GraphID()] = struct{}{}
}
コード例 #2
0
ファイル: cleaner.go プロジェクト: cloudfoundry/garden-shed
func (g *retainer) Check(id layercake.ID) bool {
	g.retainedImagesMu.Lock()
	defer g.retainedImagesMu.Unlock()

	if g.retainedImages == nil {
		return false
	}

	_, ok := g.retainedImages[id.GraphID()]
	return ok
}
コード例 #3
0
ファイル: aufs.go プロジェクト: cloudfoundry/garden-shed
func (a *QuotaedDriver) GetMntPath(id layercake.ID) string {
	return a.makeMntPath(id.GraphID())
}
コード例 #4
0
			ItCanReadWriteTheLayer := func() {
				It("can read and write files", func() {
					p, err := cake.Path(id)
					Expect(err).NotTo(HaveOccurred())
					Expect(ioutil.WriteFile(path.Join(p, "foo"), []byte("hi"), 0700)).To(Succeed())

					p, err = cake.Path(id)
					Expect(err).NotTo(HaveOccurred())
					Expect(path.Join(p, "foo")).To(BeAnExistingFile())
				})

				It("can get back the image", func() {
					img, err := cake.Get(id)
					Expect(err).NotTo(HaveOccurred())
					Expect(img.ID).To(Equal(id.GraphID()))
					Expect(img.Parent).To(Equal(parent.GraphID()))
				})
			}

			Context("when the new layer is a docker image", func() {
				JustBeforeEach(func() {
					id = layercake.DockerImageID("70d8f0edf5c9008eb61c7c52c458e7e0a831649dbb238b93dde0854faae314a8")
					registerImageLayer(cake, &image.Image{
						ID:     id.GraphID(),
						Parent: parent.GraphID(),
					})
				})

				Context("without a parent", func() {
					ItCanReadWriteTheLayer()
コード例 #5
0
ファイル: aufs_test.go プロジェクト: cloudfoundry/garden-shed
					})

					It("should not create the garden-info metadata directories", func() {
						Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Equal(testError))
						Expect(filepath.Join(baseDirectory, "garden-info")).NotTo(BeADirectory())
						Expect(filepath.Join(baseDirectory, "garden-info", "parent-child")).NotTo(BeADirectory())
						Expect(filepath.Join(baseDirectory, "garden-info", "child-parent")).NotTo(BeADirectory())
					})
				})
			})

			Describe("Parent-child relationship", func() {
				Context("when the namespaced layer is duplicated", func() {
					JustBeforeEach(func() {
						Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(Succeed())
						Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(MatchError(fmt.Sprintf("%s already exists", namespacedChildID.GraphID())))
					})

					It("does not add duplicated records in child-parent file", func() {
						childParentInfo := filepath.Join(baseDirectory, "garden-info", "child-parent", namespacedChildID.GraphID())
						Expect(aufsCake.Create(namespacedChildID, parentID, "")).To(HaveOccurred())

						childParentInfoData, err := ioutil.ReadFile(childParentInfo)
						Expect(err).NotTo(HaveOccurred())
						Expect(string(childParentInfoData)).To(Equal(parentID.GraphID() + "\n"))
					})

					It("does not duplicate the namespaced child id in parent-child file", func() {
						parentChildInfo := filepath.Join(baseDirectory, "garden-info", "parent-child", parentID.GraphID())
						Expect(parentChildInfo).To(BeAnExistingFile())