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

Method rcs

pkg/input/dir/source.go:86–121  ·  view source on GitHub ↗

rcs returns entities for the rcs in the RCFile

(objects []deploy.KubeObject)

Source from the content-addressed store, hash-verified

84
85// rcs returns entities for the rcs in the RCFile
86func (fs FileSource) rcs(objects []deploy.KubeObject) (rcs []entity.Entity, err error) {
87 pattern := fmt.Sprintf("%s/*%s", fs, RCExtension)
88
89 patternExts := withExtensions(pattern)
90 paths, err := multiGlob(patternExts...)
91 if err != nil {
92 return rcs, err
93 }
94
95 for _, filePath := range paths {
96 err = walkPathForObjects(filePath, func(info *resource.Info, err error) error {
97 kubeRC, ok := info.Object.(*kube.ReplicationController)
98 if !ok {
99 return fmt.Errorf("expected type `ReplicationController` but found `%s`", info.Object.GetObjectKind().GroupVersionKind().Kind)
100 }
101
102 rc, err := entity.NewReplicationController(kubeRC, kube.ObjectMeta{}, info.Source, objects...)
103 if err != nil {
104 return err
105 }
106
107 rcs = append(rcs, rc)
108 return nil
109 })
110
111 if checkErrPathDoesNotExist(err) {
112 // it's okay if directory doesn't exit
113 err = nil
114 }
115
116 if err != nil {
117 return
118 }
119 }
120 return
121}
122
123// pods returns Pods for the rcs in the PodFile
124func (fs FileSource) pods(objects []deploy.KubeObject) (pods []entity.Entity, err error) {

Callers 1

EntitiesMethod · 0.95

Calls 4

withExtensionsFunction · 0.85
multiGlobFunction · 0.85
walkPathForObjectsFunction · 0.85
checkErrPathDoesNotExistFunction · 0.85

Tested by

no test coverage detected