MCPcopy
hub / github.com/cortexlabs/cortex / checkOnlyCortexResources

Function checkOnlyCortexResources

pkg/lib/configreader/interface.go:123–150  ·  view source on GitHub ↗
(obj interface{})

Source from the content-addressed store, hash-verified

121}
122
123func checkOnlyCortexResources(obj interface{}) error {
124 if objStr, ok := obj.(string); ok {
125 if _, ok := yaml.ExtractAtSymbolText(objStr); !ok {
126 return ErrorCortexResourceOnlyAllowed(objStr)
127 }
128 }
129
130 if objSlice, ok := cast.InterfaceToInterfaceSlice(obj); ok {
131 for i, objItem := range objSlice {
132 if err := checkOnlyCortexResources(objItem); err != nil {
133 return errors.Wrap(err, s.Index(i))
134 }
135 }
136 }
137
138 if objMap, ok := cast.InterfaceToInterfaceInterfaceMap(obj); ok {
139 for k, v := range objMap {
140 if err := checkOnlyCortexResources(k); err != nil {
141 return err
142 }
143 if err := checkOnlyCortexResources(v); err != nil {
144 return errors.Wrap(err, s.UserStrStripped(k))
145 }
146 }
147 }
148
149 return nil
150}
151
152// FlattenAllStrValues assumes that the order for maps is deterministic
153func FlattenAllStrValues(obj interface{}) ([]string, error) {

Callers 5

validateInterfaceFunction · 0.85
validateInterfaceMapFunction · 0.85
ValidateStringValFunction · 0.85
validateInterfaceMapListFunction · 0.85
validateStringListFunction · 0.85

Calls 4

WrapFunction · 0.92

Tested by

no test coverage detected