13
13
RE_VAR = re .compile (r'^[_a-zA-Z][_0-9a-zA-Z]{0,40}$' )
14
14
RE_TOKEN = re .compile (r'^[0-9a-f]{32}$' )
15
15
RE_NUMBER = re .compile (r'^([1-9][0-9]*)?$' )
16
+ RE_WHITE_SPACE = re .compile (r'\s+' )
16
17
17
18
TL = (tuple , list )
18
19
COMPOSE_KEYS = set (('environment' , 'image' ))
45
46
(isinstance (v , int ) and v > 0 ) or
46
47
(isinstance (v , str ) and RE_NUMBER .match (v ))
47
48
),
49
+ 'NETWORK' : lambda v : (
50
+ isinstance (v , str ) and str and RE_WHITE_SPACE .match (str ) is None
51
+ ),
48
52
}
49
53
50
54
_SOCAT = {
76
80
'image' : 'ghcr.io/infrasonar/speedtest-agent'
77
81
}
78
82
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
+
79
97
_AGENTS = {
80
98
'docker' : _DOCKER_AGENT ,
81
99
'speedtest' : _SPEEDTEST_AGENT ,
100
+ 'discovery' : _DISCOVERY_AGENT ,
82
101
}
83
102
84
103
@@ -102,8 +121,8 @@ async def _init(cls):
102
121
# Overwrite API_URI when using development environment
103
122
if USE_DEVELOPMENT :
104
123
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
107
126
108
127
@classmethod
109
128
async def get_log (cls , name : str , start : int = 0 ):
0 commit comments