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

Method Attach

pkg/entity/pod.go:114–138  ·  view source on GitHub ↗

Attach appends Images and Containers.

(curEntity Entity)

Source from the content-addressed store, hash-verified

112
113// Attach appends Images and Containers.
114func (c *Pod) Attach(curEntity Entity) error {
115 if err := c.validAttach(curEntity); err != nil {
116 return err
117 }
118
119 for {
120 switch e := curEntity.(type) {
121 case *Image:
122 container, err := newDefaultContainer(e.name(), e.Source())
123 if err != nil {
124 return err
125 }
126
127 err = container.Attach(e)
128 curEntity = container
129 break
130 case *Container:
131 c.containers = append(c.containers, e)
132 sort.Sort(c.containers)
133 return nil
134 default:
135 panic("Unexpected type")
136 }
137 }
138}
139
140func (c *Pod) name() string {
141 return c.pod.ObjectMeta.Name

Callers 2

TestPodAttachImageFunction · 0.95
TestPodAttachContainerFunction · 0.95

Calls 5

newDefaultContainerFunction · 0.85
validAttachMethod · 0.80
nameMethod · 0.65
SourceMethod · 0.65
AttachMethod · 0.65

Tested by 2

TestPodAttachImageFunction · 0.76
TestPodAttachContainerFunction · 0.76