aboutsummaryrefslogtreecommitdiff
path: root/docker/tag-config/index.mjs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2019-12-04 18:04:30 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2019-12-04 18:04:30 +0100
commitfcc2328a3bf49eb5310413058cc9ebaf8e7819f8 (patch)
treec6faabae8badd96455453b72472ac08a2fe0b1c2 /docker/tag-config/index.mjs
parent0b3eb8ec1b3ba3691410744f6397437c9832e74d (diff)
downloadinfrastructure-fcc2328a3bf49eb5310413058cc9ebaf8e7819f8.tar.gz
infrastructure-fcc2328a3bf49eb5310413058cc9ebaf8e7819f8.zip
WIP netiquette
Diffstat (limited to 'docker/tag-config/index.mjs')
-rw-r--r--docker/tag-config/index.mjs56
1 files changed, 0 insertions, 56 deletions
diff --git a/docker/tag-config/index.mjs b/docker/tag-config/index.mjs
deleted file mode 100644
index a5b51fc..0000000
--- a/docker/tag-config/index.mjs
+++ /dev/null
@@ -1,56 +0,0 @@
-'use strict'
-import consul from 'consul'
-import { exec } from './src/io/run.mjs'
-import { readFile } from './src/io/files.mjs'
-
-import ctlg_consul from './src/catalog/consul.mjs'
-import inj_iptables from './src/injector/iptables.mjs'
-
-const get_args = () => process
- .argv
- .slice(2)
- .map(a => a.split('='))
- .reduce((dict, tuple) => {
- dict[tuple[0]] = tuple.length > 1 ? tuple[1] : null
- return dict
- }, {})
-
-/**
- * If we have multiple catalogs
- * we cache the results of the other ones
- */
-function* notifications_aggregator(injectors) {
- const states = []
- for(let idx = 0; true; idx++) {
- yield async (tag_list) => {
- states[idx] = tag_list
- await Promise.all(
- injectors.map(notify =>
- notify(states.reduce((acc, tag) => [...acc, ...tag], []))))
- }
- }
-}
-
-const main = async () => {
- try {
- const args = get_args()
-
- // Initialize all injectors
- const injectors = [
- await inj_iptables(args.ipt_base, readFile, exec, console.log)
- ]
-
- // Initialize all catalogs and map them to the injectors
- const aggr = notifications_aggregator(injectors)
- const catalogs = [
- await ctlg_consul(args.node, consul(), console.log, aggr.next().value)
- ]
-
- console.log("[main] initialized")
- } catch(e) {
- console.error("initialization failed", e)
- process.exit(1)
- }
-}
-
-main()