Expose apps.getByContainerId

This commit is contained in:
Girish Ramakrishnan
2019-03-06 11:15:12 -08:00
parent bfea97f14e
commit 916ca87db4

View File

@@ -8,6 +8,7 @@ exports = module.exports = {
removeRestrictedFields: removeRestrictedFields,
get: get,
getByContainerId: getByContainerId,
getByIpAddress: getByIpAddress,
getAll: getAll,
getAllByUser: getAllByUser,
@@ -447,28 +448,35 @@ function get(appId, callback) {
});
}
function getByIpAddress(ip, callback) {
assert.strictEqual(typeof ip, 'string');
function getByContainerId(containerId, callback) {
assert.strictEqual(typeof containerId, 'string');
assert.strictEqual(typeof callback, 'function');
getDomainObjectMap(function (error, domainObjectMap) {
if (error) return callback(error);
docker.getContainerIdByIp(ip, function (error, containerId) {
appdb.getByContainerId(containerId, function (error, app) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, 'No such app'));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
appdb.getByContainerId(containerId, function (error, app) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new AppsError(AppsError.NOT_FOUND, 'No such app'));
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
postProcess(app, domainObjectMap);
postProcess(app, domainObjectMap);
callback(null, app);
});
callback(null, app);
});
});
}
function getByIpAddress(ip, callback) {
assert.strictEqual(typeof ip, 'string');
assert.strictEqual(typeof callback, 'function');
docker.getContainerIdByIp(ip, function (error, containerId) {
if (error) return callback(new AppsError(AppsError.INTERNAL_ERROR, error));
getByContainerId(containerId, callback);
});
}
function getAll(callback) {
assert.strictEqual(typeof callback, 'function');