Created
January 11, 2023 11:20
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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