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 delay: 4
debug: false debug: true
events: [service, node] events: [service, node]
docker: docker:
socketPath: /var/run/docker.sock socketPath: /var/run/docker.sock

View File

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

View File

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

View File

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