Files
mtusi2026lab6/scripts/preflight-openobserve-images.ts

7 lines
1.7 KiB
TypeScript

import{validateGrafanaRuleIntervals}from'./lib/grafana-scheduler';
const images=[['docker.io/library/mtuci-vp6-openobserve-cache:v1.1.2','sha256:26618f379c86b253c0d91624c487dd14b71293699845ecbc8457c94dca14819f'],['docker.io/library/mtuci-vp6-collector-cache:0.163.2','sha256:a65df9129a5b3f99ee4434c5e53aee1965ff0129eda6a2da75ea917165b7fa6b']];
if(process.argv.includes('--grafana')){validateGrafanaRuleIntervals((Bun.YAML.parse(await Bun.file(new URL('../config/grafana/provisioning/alerting/rules.yaml',import.meta.url)).text()) as {groups:{interval:string}[]}).groups,10);const root=new URL('../.local/grafana-plugins/openobserve/',import.meta.url);for(const [name,hash]of Object.entries({'plugin.json':'8bec0fc6e3069122c970decc8f62b002cce63441fe8592a1b17349becbea844f','module.js':'7c43a8842a97f722e2de0ff2ff4512d84e5cd91a7d75594b10c2677c7d63fe0c','gpx_openobserve_linux_amd64':'dc91fdfaf25708cb2573c4e533754cb5cc5ecd02d43beb7ee21bee06fbc09c50'})){if(new Bun.CryptoHasher('sha256').update(await Bun.file(new URL(name,root)).arrayBuffer()).digest('hex')!==hash)throw new Error('Required verified plugin bytes missing/mismatched: '+name)}}
if(process.argv.includes('--grafana'))images.push(['docker.io/library/mtuci-vp6-grafana-cache:13.3.1','sha256:1c88285f1dd391a62232c010e6c224846e6a73bdc583b3365be2eba614b7919e']);
for(const [image,expected]of images){const r=Bun.spawnSync(['docker','image','inspect',image,'--format','{{.Id}}|{{.Architecture}}|{{.Os}}'],{stdout:'pipe',stderr:'pipe'});if(r.exitCode!==0||new TextDecoder().decode(r.stdout).trim()!==expected+'|amd64|linux')throw new Error('Required verified cached image missing/mismatched; no automatic pull: '+image);}
console.log(JSON.stringify({verifiedCachedImages:images.length,pulled:false}));