Attach allows Pods, Containers, and Images to be attached.
(e Entity)
| 89 | |
| 90 | // Attach allows Pods, Containers, and Images to be attached. |
| 91 | func (c *ReplicationController) Attach(e Entity) error { |
| 92 | if err := c.validAttach(e); err != nil { |
| 93 | return err |
| 94 | } |
| 95 | |
| 96 | switch e := e.(type) { |
| 97 | case *Pod: |
| 98 | if c.pod != nil { |
| 99 | return ErrorMaxAttached |
| 100 | } |
| 101 | |
| 102 | c.pod = e |
| 103 | return nil |
| 104 | default: |
| 105 | if c.pod != nil { |
| 106 | return c.pod.Attach(e) |
| 107 | } |
| 108 | |
| 109 | meta := kube.ObjectMeta{Name: e.name()} |
| 110 | pod, err := NewDefaultPod(meta, e.Source()) |
| 111 | if err != nil { |
| 112 | return err |
| 113 | } |
| 114 | |
| 115 | err = pod.Attach(e) |
| 116 | if err != nil { |
| 117 | return err |
| 118 | } |
| 119 | |
| 120 | return c.Attach(pod) |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | func (c *ReplicationController) name() string { |
| 125 | return c.rc.ObjectMeta.Name |
nothing calls this directly
no test coverage detected