Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getOldLogs (appId, beforeDate, afterDate, filter, deployment_id) {
const limit = (beforeDate == null && afterDate == null) ? 300 : null;
const before = (beforeDate != null) ? beforeDate.toISOString() : null;
const after = (afterDate != null) ? afterDate.toISOString() : null;
const logsProm = fetchOldLogs({ appId, limit, before, after, filter, deployment_id }).then(sendToApi);
return Bacon.fromPromise(logsProm)
.flatMapLatest((logs) => Bacon.fromArray(logs.reverse()));
};
async function status (params) {
const { alias } = params.options;
const { org_id, app_id: appId } = await AppConfig.getAppData(alias).toPromise();
const instances = await getAllInstances({ id: org_id, appId }).then(sendToApi);
const app = await getApplication({ id: org_id, appId }).then(sendToApi);
Logger.println(computeStatus(instances, app));
Logger.println(displayScalability(app));
}
async function setDedicatedBuildInstance (appId, orgaId, enableSeparateBuild) {
const app = await application.get({ id: orgaId, appId }).then(sendToApi);
const newConfig = { ...app, separateBuild: enableSeparateBuild };
return application.update({ id: orgaId, appId }, newConfig).then(sendToApi);
};
async function setScalability (appId, orgaId, scalabilityParameters) {
Logger.info('Scaling the app: ' + appId);
const app = await application.get({ id: orgaId, appId }).then(sendToApi);
const instance = _.cloneDeep(app.instance);
instance.minFlavor = instance.minFlavor.name;
instance.maxFlavor = instance.maxFlavor.name;
const newConfig = mergeScalabilityParameters(scalabilityParameters, instance);
return application.update({ id: orgaId, appId }, newConfig).then(sendToApi);
};
async function getByNameProm (name) {
const fullSummary = await getSummary({}).then(sendToApi);
const filteredOrgs = _.filter(fullSummary.organisations, { name });
if (filteredOrgs.length === 0) {
throw new Error('Organisation not found');
}
if (filteredOrgs.length > 1) {
throw new Error('Ambiguous organisation name');
}
return filteredOrgs[0];
}
async function setDedicatedBuildInstance (appId, orgaId, enableSeparateBuild) {
const app = await application.get({ id: orgaId, appId }).then(sendToApi);
const newConfig = { ...app, separateBuild: enableSeparateBuild };
return application.update({ id: orgaId, appId }, newConfig).then(sendToApi);
};
async function setScalability (appId, orgaId, scalabilityParameters) {
Logger.info('Scaling the app: ' + appId);
const app = await application.get({ id: orgaId, appId }).then(sendToApi);
const instance = _.cloneDeep(app.instance);
instance.minFlavor = instance.minFlavor.name;
instance.maxFlavor = instance.maxFlavor.name;
const newConfig = mergeScalabilityParameters(scalabilityParameters, instance);
return application.update({ id: orgaId, appId }, newConfig).then(sendToApi);
};
async function enable (params) {
const [drainId] = params.args;
const { alias } = params.options;
const { app_id: appId } = await AppConfig.getAppData(alias).toPromise();
await updateDrainState({ appId, drainId }, { state: 'ENABLED' }).then(sendToApi);
Logger.println('Your drain has been enabled');
}
async function disable (params) {
const [drainId] = params.args;
const { alias } = params.options;
const { app_id: appId } = await AppConfig.getAppData(alias).toPromise();
await updateDrainState({ appId, drainId }, { state: 'DISABLED' }).then(sendToApi);
Logger.println('Your drain has been disabled');
}
function getCurrent () {
return get({}).then(sendToApi);
};