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

Method Add

pkg/deploy/deployment.go:42–68  ·  view source on GitHub ↗

Add inserts an object into a deployment. The object must be a valid Kubernetes object or it will fail. There can only be a single object of the same name, namespace, and type. Objects are deep-copied into the Deployment.

(obj KubeObject)

Source from the content-addressed store, hash-verified

40// Add inserts an object into a deployment. The object must be a valid Kubernetes object or it will fail.
41// There can only be a single object of the same name, namespace, and type. Objects are deep-copied into the Deployment.
42func (d *Deployment) Add(obj KubeObject) error {
43 // create objects if doesn't exist
44 if d.objects == nil {
45 d.objects = make(map[string]KubeObject, 1)
46 }
47
48 // generate path using meta and type info
49 path, err := ObjectPath(obj)
50 if err != nil {
51 return fmt.Errorf("could not add object: %v", err)
52 }
53
54 // there can only be one object per path
55 if _, exists := d.objects[path]; exists {
56 return ErrorConflict
57 }
58
59 // create a copy of values
60 copy, err := deepCopy(obj)
61 if err != nil {
62 return err
63 }
64
65 // add object to
66 d.objects[path] = copy
67 return nil
68}
69
70// AddDeployment inserts the contents of one Deployment into another.
71func (d *Deployment) AddDeployment(deployment Deployment) (err error) {

Callers 15

AddDeploymentMethod · 0.95
DeploymentMethod · 0.95
newBaseFunction · 0.95
TestNoDuplicateNamesFunction · 0.45
TestDeploymentObjectsFunction · 0.45
DeploymentFromDocMapFunction · 0.45
DeploymentMethod · 0.45
AddDocumentToIndexMethod · 0.45
TestImageDeploymentFunction · 0.45

Calls 2

ObjectPathFunction · 0.85
deepCopyFunction · 0.85

Tested by 14

TestNoDuplicateNamesFunction · 0.36
TestDeploymentObjectsFunction · 0.36
TestImageDeploymentFunction · 0.36
TestContainerAttachFunction · 0.36
TestPodAttachImageFunction · 0.36
TestPodAttachContainerFunction · 0.36
TestRCValidPodDeploymentFunction · 0.36
TestRCAttachImageFunction · 0.36