MCPcopy Create free account
hub / github.com/apache/mesos / foreach

Function foreach

src/slave/csi_server.cpp:168–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166 hashmap<string, CSIPluginInfo> pluginConfigs;
167
168 foreach (const string& entry, entries.get()) {
169 const string path = path::join(pluginConfigDir, entry);
170
171 // Ignore directory entries.
172 if (os::stat::isdir(path)) {
173 continue;
174 }
175
176 Try<string> read = os::read(path);
177 if (read.isError()) {
178 // In case of an error we log and skip to the next entry.
179 LOG(ERROR) << "Failed to read CSI plugin configuration file '"
180 << path << "': " << read.error();
181
182 continue;
183 }
184
185 Try<JSON::Object> json = JSON::parse<JSON::Object>(read.get());
186 if (json.isError()) {
187 return Error("JSON parse of '" + path + "' failed: " + json.error());
188 }
189
190 Try<CSIPluginInfo> parse = ::protobuf::parse<CSIPluginInfo>(json.get());
191 if (parse.isError()) {
192 return Error("Protobuf parse of '" + path + "' failed: " + parse.error());
193 }
194
195 const CSIPluginInfo& csiPluginConfig = parse.get();
196 const string& type = csiPluginConfig.type();
197
198 if (pluginConfigs.contains(type)) {
199 LOG(ERROR) << "Multiple configurations for a CSI plugin are not allowed. "
200 << "Skipping configuration file '" << path << "' since CSI "
201 << "plugin '" << type << "' already exists";
202 continue;
203 }
204
205 if (name.isNone() || name.get() == type) {
206 pluginConfigs[type] = csiPluginConfig;
207
208 if (name.isSome()) {
209 break;
210 }
211 }
212 }
213
214 if (pluginConfigs.empty()) {
215 return Error(

Callers

nothing calls this directly

Calls 12

typeMethod · 0.80
insertMethod · 0.80
readFunction · 0.70
errorMethod · 0.65
joinFunction · 0.50
isdirFunction · 0.50
ErrorFunction · 0.50
isErrorMethod · 0.45
getMethod · 0.45
containsMethod · 0.45
isNoneMethod · 0.45
isSomeMethod · 0.45

Tested by

no test coverage detected