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

Function newBase

pkg/entity/entity.go:45–66  ·  view source on GitHub ↗
(t Type, defaults kube.ObjectMeta, source string, objects []deploy.KubeObject)

Source from the content-addressed store, hash-verified

43}
44
45func newBase(t Type, defaults kube.ObjectMeta, source string, objects []deploy.KubeObject) (base base, err error) {
46 base.defaults = defaults
47
48 deployment := deploy.Deployment{}
49 for _, obj := range objects {
50 if obj == nil {
51 err = ErrorNilObject
52 return
53 }
54 base.setDefaults(obj)
55 err = deployment.Add(obj)
56 if err != nil {
57 err = fmt.Errorf("error adding '%s': %v", source, err)
58 return
59 }
60 }
61
62 base.source = source
63 base.entityType = t
64 base.objects = deployment
65 return
66}
67
68// Objects returns slice of objects attached to Entity
69func (base base) Objects() []deploy.KubeObject {

Callers 13

NewPodFunction · 0.85
NewImageFunction · 0.85
NewReplicationControllerFunction · 0.85
NewAppFunction · 0.85
TestBaseNewFunction · 0.85
TestBaseNilObjectsFunction · 0.85
TestBaseNoDefaultsFunction · 0.85
TestBaseBadObjectFunction · 0.85

Calls 2

AddMethod · 0.95
setDefaultsMethod · 0.80

Tested by 8

TestBaseNewFunction · 0.68
TestBaseNilObjectsFunction · 0.68
TestBaseNoDefaultsFunction · 0.68
TestBaseBadObjectFunction · 0.68