mirror of
https://github.com/fleetdm/fleet
synced 2026-05-10 02:30:56 +00:00
#22073 Changes: - Added the ability to use labels to assign configuration profiles on the profiles page.
45 lines
865 B
JavaScript
45 lines
865 B
JavaScript
module.exports = {
|
|
|
|
|
|
friendlyName: 'Get labels',
|
|
|
|
|
|
description: 'Builds and returns an array of labels on the Fleet instance.',
|
|
|
|
|
|
exits: {
|
|
success: {
|
|
outputType: [{}],
|
|
}
|
|
},
|
|
|
|
|
|
fn: async function () {
|
|
|
|
|
|
let labelsOnThisInstance = [];
|
|
|
|
let labelsResponseData = await sails.helpers.http.get.with({
|
|
url: '/api/v1/fleet/labels',
|
|
baseUrl: sails.config.custom.fleetBaseUrl,
|
|
headers: {
|
|
Authorization: `Bearer ${sails.config.custom.fleetApiToken}`
|
|
}
|
|
})
|
|
.timeout(120000)
|
|
.retry(['requestFailed', {name: 'TimeoutError'}]);
|
|
|
|
for(let label of labelsResponseData.labels) {
|
|
labelsOnThisInstance.push({
|
|
name: label.name,
|
|
value: label.id
|
|
});
|
|
}
|
|
labelsOnThisInstance = _.sortBy(labelsOnThisInstance, 'name');
|
|
// All done.
|
|
return labelsOnThisInstance;
|
|
|
|
}
|
|
|
|
|
|
};
|