本文整理匯總了Golang中code/cloudfoundry/org/guardian/rundmc/goci.Bndl類的典型用法代碼示例。如果您正苦於以下問題:Golang Bndl類的具體用法?Golang Bndl怎麽用?Golang Bndl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Bndl類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Apply
func (l Hostname) Apply(bndl goci.Bndl, spec gardener.DesiredContainerSpec) goci.Bndl {
hostname := spec.Hostname
if len(hostname) > 49 {
hostname = hostname[len(hostname)-49:]
}
return bndl.WithHostname(hostname)
}
示例2: Apply
func (b BindMounts) Apply(bndl goci.Bndl, spec gardener.DesiredContainerSpec) goci.Bndl {
var mounts []specs.Mount
for _, m := range spec.BindMounts {
modeOpt := "ro"
if m.Mode == garden.BindMountModeRW {
modeOpt = "rw"
}
mounts = append(mounts, specs.Mount{
Destination: m.DstPath,
Source: m.SrcPath,
Type: "bind",
Options: []string{"bind", modeOpt},
})
}
return bndl.WithMounts(mounts...)
}
示例3: Apply
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)
}
示例4: Apply
func (l Limits) Apply(bndl goci.Bndl, spec gardener.DesiredContainerSpec) goci.Bndl {
limit := uint64(spec.Limits.Memory.LimitInBytes)
bndl = bndl.WithMemoryLimit(specs.LinuxMemory{Limit: &limit, Swap: &limit})
shares := uint64(spec.Limits.CPU.LimitInShares)
bndl = bndl.WithCPUShares(specs.LinuxCPU{Shares: &shares})
pids := int64(spec.Limits.Pid.Max)
return bndl.WithPidLimit(specs.LinuxPids{Limit: pids})
}
示例5:
package goci_test
import (
"code.cloudfoundry.org/guardian/rundmc/goci"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/opencontainers/runtime-spec/specs-go"
)
var _ = Describe("Bundle", func() {
var initialBundle goci.Bndl
var returnedBundle goci.Bndl
BeforeEach(func() {
initialBundle = goci.Bundle()
})
It("specifies the correct version", func() {
Expect(initialBundle.Spec.Version).To(Equal("0.2.0"))
})
Describe("WithHostname", func() {
It("sets the Hostname in the bundle", func() {
returnedBundle := initialBundle.WithHostname("hostname")
Expect(returnedBundle.Hostname()).To(Equal("hostname"))
})
})
Describe("WithCapabilities", func() {
It("adds capabilities to the bundle", func() {
returnedBundle := initialBundle.WithCapabilities("growtulips", "waterspuds")
示例6:
package bundlerules_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/opencontainers/runtime-spec/specs-go"
"code.cloudfoundry.org/garden"
"code.cloudfoundry.org/guardian/gardener"
"code.cloudfoundry.org/guardian/rundmc/bundlerules"
"code.cloudfoundry.org/guardian/rundmc/goci"
)
var _ = Describe("BindMountsRule", func() {
var newBndl goci.Bndl
BeforeEach(func() {
newBndl = bundlerules.BindMounts{}.Apply(goci.Bundle(), gardener.DesiredContainerSpec{
BindMounts: []garden.BindMount{
{
SrcPath: "/path/to/ro/src",
DstPath: "/path/to/ro/dest",
Mode: garden.BindMountModeRO,
},
{
SrcPath: "/path/to/rw/src",
DstPath: "/path/to/rw/dest",
Mode: garden.BindMountModeRW,
},
},
})
示例7:
"encoding/json"
"io"
"io/ioutil"
"os"
"path"
"code.cloudfoundry.org/guardian/rundmc/goci"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/opencontainers/runtime-spec/specs-go"
)
var _ = Describe("Bundle Serialization", func() {
var (
tmp string
bndle goci.Bndl
)
BeforeEach(func() {
var err error
tmp, err = ioutil.TempDir("", "gocitest")
Expect(err).NotTo(HaveOccurred())
bndle = goci.Bndl{
Spec: specs.Spec{
Version: "abcd",
},
}
Expect(bndle.Save(tmp)).To(Succeed())
})
示例8: Apply
func (r Env) Apply(bndl goci.Bndl, spec gardener.DesiredContainerSpec) goci.Bndl {
process := bndl.Process()
process.Env = spec.Env
return bndl.WithProcess(process)
}