Skip to content

Instantly share code, notes, and snippets.

@Epictek
Created January 11, 2023 11:20
Show Gist options
  • Save Epictek/f694d68d55981c3f666bcd8afa3dd53f to your computer and use it in GitHub Desktop.
Save Epictek/f694d68d55981c3f666bcd8afa3dd53f to your computer and use it in GitHub Desktop.
Clean mender artifacts, run in browser dev tools whilst logged in to mender
function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
var page = 0;
var pageContents = [];
while (true){
await delay(200);
var data = await fetch(`https://hosted.mender.io/api/management/v1/deployments/deployments/releases/list?page=${page}&per_page=10&sort=modified:desc`);
var pageContent = await data.json();
console.log(pageContent.length)
if (pageContent.length == 0) {
break;
}
pageContents.push.apply(pageContents, pageContent)
page = page + 1;
console.log(page)
}
console.log(pageContents)
pageContents.forEach(async d => {
d.Artifacts.forEach(async (a) => {
await delay(500);
if (!a.device_types_compatible.includes("raspberrypi-armv8")){
var response = await fetch(`https://hosted.mender.io/api/management/v1/deployments/artifacts/${a.id}`, {
"method": "DELETE"
});
console.log("deleted artifact" + a.name)
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment