Exemplo n.º 1
0
func (r RootFS) Apply(bndl goci.Bndl, spec gardener.DesiredContainerSpec) goci.Bndl {
	var uid, gid int
	if !spec.Privileged {
		uid = r.ContainerRootUID
		gid = r.ContainerRootGID
	}

	r.MkdirChown.MkdirAs(
		spec.RootFSPath, uid, gid, 0755, true,
		".pivot_root",
		"dev", "proc", "sys",
	)

	r.MkdirChown.MkdirAs(
		spec.RootFSPath, uid, gid, 0777, false,
		"tmp",
	)

	return bndl.WithRootFS(spec.RootFSPath)
}
Exemplo n.º 2
0
		})

		It("sets the CWD to / by default", func() {
			returnedBundle := initialBundle.WithProcess(goci.Process("echo", "foo"))
			Expect(returnedBundle.Process()).To(Equal(specs.Process{Args: []string{"echo", "foo"}}))
		})

		It("does not modify the initial bundle", func() {
			returnedBundle := initialBundle.WithProcess(goci.Process("echo", "foo"))
			Expect(returnedBundle).NotTo(Equal(initialBundle))
		})
	})

	Describe("WithRootFS", func() {
		It("sets the rootfs path in the spec", func() {
			returnedBundle := initialBundle.WithRootFS("/foo/bar/baz")
			Expect(returnedBundle.RootFS()).To(Equal("/foo/bar/baz"))
		})
	})

	Describe("WithPrestartHooks", func() {
		It("adds the hook to the runtime spec", func() {
			returnedBundle := initialBundle.WithPrestartHooks(specs.Hook{
				Path: "foo",
				Args: []string{"bar", "baz"},
			})

			Expect(returnedBundle.PrestartHooks()).To(Equal([]specs.Hook{{
				Path: "foo",
				Args: []string{"bar", "baz"},
			}}))