Created
November 30, 2022 12:38
-
-
Save alanshaw/f69003c5d7a7d8d3becb49084c561104 to your computer and use it in GitHub Desktop.
Extract the gateway peer IDs from the bifrost infra repo
This file contains hidden or 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
import fs from 'fs' | |
import path from 'path' | |
const dir = path.join('ansible', 'inventories', 'bifrost', 'host_vars') | |
const regex = /ipfs_config_identity_peerid: "(.*)"/ig | |
async function main () { | |
const peers = [] | |
for (const f of fs.readdirSync(dir)) { | |
if (!(f.startsWith('ipfs-bank') && f.endsWith('ipfs.gateway.dwebops.net.yml'))) continue | |
const data = fs.readFileSync(path.join(dir, f), 'utf8') | |
const matches = regex.exec(data) | |
if (!matches) continue | |
peers.push({ name: f.split('.')[0], peer: matches[1] }) | |
} | |
peers.sort((a, b) => a.name < b.name ? 1 : 0) | |
console.log(JSON.stringify(peers, null, 2)) | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment