Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var loadMeta = function () {
console.log(chalk.green('Loading required JSON metadata files'));
var files = {
parameters: readFile(options.input+'/parameters.json'),
contents: readFile(options.input+'/contents.json'),
};
rsvp.hash(files).then(function(files) {
for(var key in files) {
if (files.hasOwnProperty(key)) { //ignore prototype
try {
var file = JSON.parse(files[key]);
if (validateJSON(key, file)) {
meta[key] = file;
} else {
mainProcess.exit(1);
}
} catch (error) {
console.log(chalk.red('Error parsing required file: '+key+'.json (invalid JSON)'));
if (options.verbose === true) {
console.log(chalk.red(error));
}
mainProcess.exit(1);
}
model(params) {
return hash({ workload: this.get('store').find('workload', params.workload_id), }).then((hash) => EmberObject.create(hash));
},
model(params) {
const nspace = this.optionalParams().nspace;
return hash({
...this.repo.status({
items: this.repo.findAllByDatacenter({
ns: nspace,
dc: this.modelFor('dc').dc.Name,
}),
}),
nspace: nspace,
token: this.settings.findBySlug('token'),
searchProperties: this.queryParams.searchproperty.empty[0],
});
}
model() {
const model = this.modelFor('groups.group');
return RSVP.hash({
group: model,
membership: get(model, 'userMembership')
});
},
let newAlert;
if ( id ) {
newAlert = globalStore.find('projectAlertRule', id)
.then( ( alert ) => {
const cloned = alert.cloneForNew() ;
return this.loadProjectRule(cloned);
});
} else {
newAlert = this.getNewProjectAlert(projectId);
}
const opt = { filter: { projectId } };
return hash({
pods: store.find('pod', null, opt),
workloads: store.find('workload', null, opt),
notifiers: globalStore.find('notifier', null, { filter: { clusterId } }),
alertRule: newAlert,
alertGroup: globalStore.find('projectAlertGroup', groupId),
}).then(({
pods, workloads, notifiers, alertRule, alertGroup
}) => {
return {
pods,
workloads,
notifiers,
alertRule,
alertGroup,
mode: 'new',
level: 'rule',
prepare: function(/*context*/) {
var self = this;
var promises = {
data: this._getData(),
scm: this._getScmData()
};
return RSVP.hash(promises)
.then(function(results) {
var data = results.data;
data.scm = results.scm;
self.log('generated revision data for revision: `' + data.revisionKey + '`', { verbose: true });
return data;
})
.then(function(data) {
return { revisionData: data };
})
.catch(this._errorMessage.bind(this));
},
} = store.metrics;
const offset = COMPARE_MODE_MAPPING[compareMode] || 1;
const metricIds = [primaryMetricId, ...relatedMetricIds];
const baselineStart = moment(currentStart).subtract(offset, 'week').valueOf();
const baselineEnd = moment(currentEnd).subtract(offset, 'week').valueOf();
if (!metricIds.length) { return; }
const promiseHash = metricIds.reduce((hash, id) => {
const url = `/timeseries/compare/${id}/${currentStart}/${currentEnd}/${baselineStart}/${baselineEnd}?dimension=All&granularity=${granularity}&filters=${encodeURIComponent(filters)}`;
hash[id] = fetch(url).then(checkStatus);
return hash;
}, {});
return hash(promiseHash)
.then((metrics) => {
const filteredMetrics = _.pickBy(metrics, filterMetric);
metricIds.forEach((id, index) => {
const filter = filteredMetrics[id];
if (filter) {
filter.color = colors[index % colors.length];
}
});
return filteredMetrics;
})
.then(res => dispatch(loadRelatedMetricsData(res)))
.catch(() => {});
};
}
didReceiveArgument(argument) {
if (argument === this.awaited) { return; }
this.setProperties({
awaited: argument,
isPending: true,
isSettled: false,
isResolved: false,
isRejected: false,
resolvedValue: UNINITIALIZED(),
rejectReason: UNINITIALIZED()
});
let target = isHash(argument) ? RSVP.hash(argument) : argument;
Promise.resolve(target).then(
bind(this, this.didResolve, argument),
bind(this, this.didReject, argument)
);
},
model() {
let globalStore = get(this, 'globalStore');
return hash({
machineTemplates: globalStore.findAll('machinetemplate'),
machineDrivers: globalStore.find('machinedriver', null, {filter: {active: true}}),
}).then((hash) => {
return EmberObject.create({
machineTemplates: hash.machineTemplates,
machineDrivers: hash.machineDrivers,
});
});
},
});
_findCategoriesAndTopics(filter) {
return hash({
wrappedCategoriesList: PreloadStore.getAndRemove("categories_list"),
topicsList: PreloadStore.getAndRemove(`topic_list_${filter}`)
}).then(response => {
let { wrappedCategoriesList, topicsList } = response;
let categoriesList =
wrappedCategoriesList && wrappedCategoriesList.category_list;
if (categoriesList && topicsList) {
if (topicsList.topic_list && topicsList.topic_list.top_tags) {
Site.currentProp("top_tags", topicsList.topic_list.top_tags);
}
return EmberObject.create({
categories: CategoryList.categoriesFrom(
this.store,
wrappedCategoriesList