-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (29 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const alfy = require('alfy');
const alfredNotifier = require('alfred-notifier');
const request = require('request');
const parse = require('csv-parse');
const csvFile = alfy.config.get('coower-csvFileUri');
const auth = alfy.config.get('coower-authToken');
alfredNotifier();
var options = {
url: csvFile,
headers: {
'Authorization': 'Basic ' + auth
}
};
function callback(error, response, body) {
if (!error && response.statusCode == 200) {
var projects = body.split('\n');
projects.pop();
var items = projects.filter(function(item) {
return typeof item == 'string' && item.toLowerCase().indexOf(alfy.input.toLowerCase()) > -1;
}).map(x => ({
title: x.split(',')[0],
subtitle: 'Prio: ' + x.split(",")[1] + ', Port: ' + x.split(",")[2],
arg: 'https://eu-west-1.console.aws.amazon.com/ecs/home?region=eu-west-1#/clusters/{ENV}-Prio' + x.split(',')[1].charAt(0).toUpperCase() + x.split(',')[1].slice(1).toLowerCase() + '/services/{ENV}-' + x.split(',')[0] + '/tasks'
}));
alfy.output(items);
}
}
request(options, callback);