Hability to filter by protocol, tcp
gitea/docker-discover/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2021-02-22 11:22:35 +01:00
parent c84fafb975
commit 7a91807723
4 changed files with 22 additions and 6 deletions

View File

@ -1,5 +1,5 @@
delay: 4
debug: false
debug: true
events: [service, node]
docker:
socketPath: /var/run/docker.sock

View File

@ -57,9 +57,14 @@ async function updateProxy() {
let match = name.match(/^(.+)_main$/);
if (match) name = match[1];
let port = ports[0];
let protocol = port.Protocol;
services.push({
name,
port: ports[0].PublishedPort
port: port.PublishedPort,
protocol,
tcp: protocol == 'tcp'
});
}
services = services.sort(sortFn);

View File

@ -2,8 +2,10 @@
# Auto-generated backends
{{#each services}}
{{#if tcp}}
backend {{name}}
{{#each ../nodes}}
server {{name}}:{{../port}} {{address}}:{{../port}} check
{{/each}}
{{/if}}
{{/each}}

View File

@ -4,21 +4,30 @@
"Spec": {"Name": "foo"},
"Endpoint": {
"Ports": [
{"PublishedPort": 10001}
{
"PublishedPort": 10001,
"Protocol": "tcp"
}
]
}
}, {
"Spec": {"Name": "bar_main"},
"Endpoint": {
"Ports": [
{"PublishedPort": 10003}
{
"PublishedPort": 10003,
"Protocol": "tcp"
}
]
}
}, {
"Spec": {"Name": "bar_foo"},
"Endpoint": {
"Ports": [
{"PublishedPort": 10003}
{
"PublishedPort": 10003,
"Protocol": "udp"
}
]
}
}, {
@ -40,4 +49,4 @@
"Status": {"Addr": "10.0.0.3"}
}
]
}
}