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

Function NewReplicationController

pkg/entity/replicationcontroller.go:22–56  ·  view source on GitHub ↗

NewReplicationController creates a new Entity for the provided kube.ReplicationController. Must be valid.

(kubeRC *kube.ReplicationController, defaults kube.ObjectMeta, source string, objects ...deploy.KubeObject)

Source from the content-addressed store, hash-verified

20
21// NewReplicationController creates a new Entity for the provided kube.ReplicationController. Must be valid.
22func 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.
59func (c *ReplicationController) Deployment() (*deploy.Deployment, error) {

Callers 8

TestRCNilFunction · 0.85
TestRCInvalidFunction · 0.85
TestRCNoPodFunction · 0.85
TestRCInvalidPodFunction · 0.85
TestRCValidPodImagesFunction · 0.85
TestRCValidPodDeploymentFunction · 0.85
TestRCBadObjectsFunction · 0.85
testNewRCFunction · 0.85

Calls 5

newBaseFunction · 0.85
copyRCFunction · 0.85
NewPodFromPodSpecFunction · 0.85
validateRCFunction · 0.85
setDefaultsMethod · 0.80

Tested by 8

TestRCNilFunction · 0.68
TestRCInvalidFunction · 0.68
TestRCNoPodFunction · 0.68
TestRCInvalidPodFunction · 0.68
TestRCValidPodImagesFunction · 0.68
TestRCValidPodDeploymentFunction · 0.68
TestRCBadObjectsFunction · 0.68
testNewRCFunction · 0.68