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

Function parseAuthConfig

src/docker/spec.cpp:162–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160
161
162Try<hashmap<string, Config::Auth>> parseAuthConfig(
163 const JSON::Object& _config)
164{
165 // This function handles both old and new docker config format,
166 // e.g., '~/.docker/config.json' or '~/.dockercfg'.
167 Result<JSON::Object> auths = _config.find<JSON::Object>("auths");
168 if (auths.isError()) {
169 return Error("Failed to find 'auths' in docker config file: " +
170 auths.error());
171 }
172
173 const JSON::Object& config = auths.isSome()
174 ? auths.get()
175 : _config;
176
177 hashmap<string, Config::Auth> result;
178
179 foreachpair (const string& key, const JSON::Value& value, config.values) {
180 if (!value.is<JSON::Object>()) {
181 return Error("Invalid JSON object '" + stringify(value) + "'");
182 }
183
184 Try<Config::Auth> auth =
185 protobuf::parse<Config::Auth>(value.as<JSON::Object>());
186
187 if (auth.isError()) {
188 return Error("Protobuf parse failed: " + auth.error());
189 }
190
191 // Assuming no duplicate registry url in docker config file,
192 // if there exists, overwrite it.
193 result[key] = auth.get();
194 }
195
196 return result;
197}
198
199
200Try<hashmap<string, Config::Auth>> parseAuthConfig(const string& s)

Callers 3

createMethod · 0.85
fetchMethod · 0.85
TEST_FFunction · 0.85

Calls 5

errorMethod · 0.65
ErrorFunction · 0.50
isErrorMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected