NewReplicationController creates a new Entity for the provided kube.ReplicationController. Must be valid.
(kubeRC *kube.ReplicationController, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject)
| 20 | |
| 21 | // NewReplicationController creates a new Entity for the provided kube.ReplicationController. Must be valid. |
| 22 | func NewReplicationController(kubeRC *kube.ReplicationController, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject) (*ReplicationController, error) { |
| 23 | if kubeRC == nil { |
| 24 | return nil, fmt.Errorf("cannot create ReplicationController from nil `%s`", source) |
| 25 | } |
| 26 | |
| 27 | base, err := newBase(EntityReplicationController, defaults, source, objects) |
| 28 | if err != nil { |
| 29 | return nil, err |
| 30 | } |
| 31 | |
| 32 | // deep copy |
| 33 | kubeRC, err = copyRC(kubeRC) |
| 34 | if err != nil { |
| 35 | return nil, err |
| 36 | } |
| 37 | |
| 38 | rc := ReplicationController{base: base} |
| 39 | if kubeRC.Spec.Template != nil { |
| 40 | templateMeta := kubeRC.Spec.Template.ObjectMeta |
| 41 | templateMeta.Name = kubeRC.Name |
| 42 | rc.pod, err = NewPodFromPodSpec(templateMeta, kubeRC.Spec.Template.Spec, defaults, source) |
| 43 | if err != nil { |
| 44 | return nil, err |
| 45 | } |
| 46 | kubeRC.Spec.Template = nil |
| 47 | } |
| 48 | |
| 49 | base.setDefaults(kubeRC) |
| 50 | if err = validateRC(kubeRC); err != nil { |
| 51 | return nil, err |
| 52 | } |
| 53 | rc.rc = kubeRC |
| 54 | |
| 55 | return &rc, nil |
| 56 | } |
| 57 | |
| 58 | // Deployment is created for RC attached with it's Pod. |
| 59 | func (c *ReplicationController) Deployment() (*deploy.Deployment, error) { |