Skip to content

Commit b8ca344

Browse files
committed
With discovery
1 parent bbbbef9 commit b8ca344

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

lib/state.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
RE_VAR = re.compile(r'^[_a-zA-Z][_0-9a-zA-Z]{0,40}$')
1414
RE_TOKEN = re.compile(r'^[0-9a-f]{32}$')
1515
RE_NUMBER = re.compile(r'^([1-9][0-9]*)?$')
16+
RE_WHITE_SPACE = re.compile(r'\s+')
1617

1718
TL = (tuple, list)
1819
COMPOSE_KEYS = set(('environment', 'image'))
@@ -45,6 +46,9 @@
4546
(isinstance(v, int) and v > 0) or
4647
(isinstance(v, str) and RE_NUMBER.match(v))
4748
),
49+
'NETWORK': lambda v: (
50+
isinstance(v, str) and str and RE_WHITE_SPACE.match(str) is None
51+
),
4852
}
4953

5054
_SOCAT = {
@@ -76,9 +80,24 @@
7680
'image': 'ghcr.io/infrasonar/speedtest-agent'
7781
}
7882

83+
_DISCOVERY_AGENT = {
84+
'environment': {
85+
'TOKEN': '${AGENT_TOKEN}',
86+
'API_URI': 'https://api.infrasonar.com',
87+
'DAEMON': '1',
88+
'CONFIG_PATH': '/data/discovery',
89+
},
90+
'image': 'ghcr.io/infrasonar/discovery-agent',
91+
'volumes': [
92+
'/var/run/docker.sock:/var/run/docker.sock',
93+
'./data:/data/'
94+
]
95+
}
96+
7997
_AGENTS = {
8098
'docker': _DOCKER_AGENT,
8199
'speedtest': _SPEEDTEST_AGENT,
100+
'discovery': _DISCOVERY_AGENT,
82101
}
83102

84103

@@ -102,8 +121,8 @@ async def _init(cls):
102121
# Overwrite API_URI when using development environment
103122
if USE_DEVELOPMENT:
104123
api_url = 'https://devapi.infrasonar.com'
105-
_SPEEDTEST_AGENT['environment']['API_URI'] = api_url
106-
_DOCKER_AGENT['environment']['API_URI'] = api_url
124+
for agent in _AGENTS.values():
125+
agent['environment']['API_URI'] = api_url
107126

108127
@classmethod
109128
async def get_log(cls, name: str, start: int = 0):

lib/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
__version__ = '1.0.4'
1+
__version__ = '1.0.5-alpha0'
22

33
IS_RELEASE_VERSION = '-' not in __version__

0 commit comments

Comments
 (0)