MCPcopy
hub / github.com/redspread/spread / NewContainer

Function NewContainer

pkg/entity/container.go:30–57  ·  view source on GitHub ↗

NewContainer creates a new Entity for the provided kube.Container. Container must be valid.

(container kube.Container, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject)

Source from the content-addressed store, hash-verified

28
29// NewContainer creates a new Entity for the provided kube.Container. Container must be valid.
30func NewContainer(container kube.Container, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*Container, error) {
31 err := validateContainer(container)
32 if err != nil {
33 return nil, fmt.Errorf("could not create Container from `%s`: %v", source, err)
34 }
35
36 base, err := newBase(EntityContainer, defaults, source, objects)
37 if err != nil {
38 return nil, err
39 }
40
41 newContainer := Container{base: base}
42 if len(container.Image) != 0 {
43 image, err := image.FromString(container.Image)
44 if err != nil {
45 return nil, err
46 }
47
48 newContainer.image, err = NewImage(image, defaults, source)
49 if err != nil {
50 return nil, err
51 }
52 container.Image = "placeholder"
53 }
54
55 newContainer.container = container
56 return &newContainer, nil
57}
58
59func newDefaultContainer(name, source string) (*Container, error) {
60 kubeContainer := DefaultContainer

Callers 12

NewPodFunction · 0.85
TestContainerAttachFunction · 0.85
TestContainerBadObjectFunction · 0.85
testRandomContainerFunction · 0.85
TestBaseCheckAttachFunction · 0.85
TestPodAttachContainerFunction · 0.85
newDefaultContainerFunction · 0.85
TestRCAttachContainerFunction · 0.85

Calls 3

validateContainerFunction · 0.85
newBaseFunction · 0.85
NewImageFunction · 0.85

Tested by 10

TestContainerAttachFunction · 0.68
TestContainerBadObjectFunction · 0.68
testRandomContainerFunction · 0.68
TestBaseCheckAttachFunction · 0.68
TestPodAttachContainerFunction · 0.68
TestRCAttachContainerFunction · 0.68