mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-02-21 10:01:55 +00:00
Auto-merge for PR #622 via VersionBot
Allow services (and their images) to expose udp ports besides tcp
This commit is contained in:
commit
159aec0360
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file
|
||||
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## v7.4.1 - 2018-04-11
|
||||
|
||||
* Allow services (and their images) to expose udp ports besides tcp #622 [Pablo Carranza Velez]
|
||||
|
||||
## v7.4.0 - 2018-04-11
|
||||
|
||||
* Add ability to use self-signed CAs passed via `config.json`. #602 [Heds Simons]
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "resin-supervisor",
|
||||
"description": "This is resin.io's Supervisor, a program that runs on IoT devices and has the task of running user Apps (which are Docker containers), and updating them as Resin's API informs it to.",
|
||||
"version": "7.4.0",
|
||||
"version": "7.4.1",
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -10,7 +10,7 @@
|
||||
"scripts": {
|
||||
"start": "./entry.sh",
|
||||
"build": "webpack",
|
||||
"lint": "resin-lint src/",
|
||||
"lint": "resin-lint src/ test/",
|
||||
"versionist": "versionist",
|
||||
"test": "npm run lint && mocha -r coffee-script/register test/**/*"
|
||||
},
|
||||
|
@ -367,14 +367,15 @@ module.exports = class Service
|
||||
return @labels
|
||||
|
||||
extendAndSanitiseExposedPorts: (imageInfo) =>
|
||||
@expose = _.clone(@expose)
|
||||
@expose = _.map(@expose, String)
|
||||
@expose = _.map @expose, (p) ->
|
||||
p = new String(p)
|
||||
if /^[0-9]*$/.test(p)
|
||||
p += '/tcp'
|
||||
return p
|
||||
if imageInfo?.Config?.ExposedPorts?
|
||||
for own k, v of imageInfo.Config.ExposedPorts
|
||||
port = k.match(/^([0-9]*)\/tcp$/)?[1]
|
||||
if port? and !_.find(@expose, port)
|
||||
for own port, _v of imageInfo.Config.ExposedPorts
|
||||
if !_.find(@expose, port)
|
||||
@expose.push(port)
|
||||
|
||||
return @expose
|
||||
|
||||
extendAndSanitiseVolumes: (imageInfo) =>
|
||||
@ -553,7 +554,7 @@ module.exports = class Service
|
||||
portBindings["#{containerPort}/#{protocol}"] = [ { HostIp: host, HostPort: hostPort } ]
|
||||
if @expose?
|
||||
for port in @expose
|
||||
exposedPorts[port + '/tcp'] = {}
|
||||
exposedPorts[port] = {}
|
||||
return { exposedPorts, portBindings }
|
||||
|
||||
getBindsAndVolumes: =>
|
||||
|
@ -1,10 +1,112 @@
|
||||
{ expect } = require 'chai'
|
||||
ComposeService = require '../../src/compose/service'
|
||||
Service = require '../../src/compose/service'
|
||||
|
||||
describe 'compose/service.cofee', ->
|
||||
|
||||
it 'extends environment variables properly', ->
|
||||
extendEnvVarsOpts = {
|
||||
uuid: '1234'
|
||||
appName: 'awesomeApp'
|
||||
commit: 'abcdef'
|
||||
name: 'awesomeDevice'
|
||||
version: 'v1.0.0'
|
||||
deviceType: 'raspberry-pi'
|
||||
osVersion: 'Resin OS 2.0.2'
|
||||
}
|
||||
service = {
|
||||
appId: '23'
|
||||
releaseId: 2
|
||||
serviceId: 3
|
||||
imageId: 4
|
||||
serviceName: 'serviceName'
|
||||
environment:
|
||||
FOO: 'bar'
|
||||
A_VARIABLE: 'ITS_VALUE'
|
||||
}
|
||||
s = new Service(service, extendEnvVarsOpts)
|
||||
|
||||
expect(s.environment).to.deep.equal({
|
||||
FOO: 'bar'
|
||||
A_VARIABLE: 'ITS_VALUE'
|
||||
RESIN_APP_ID: '23'
|
||||
RESIN_APP_NAME: 'awesomeApp'
|
||||
RESIN_DEVICE_UUID: '1234'
|
||||
RESIN_DEVICE_NAME_AT_INIT: 'awesomeDevice'
|
||||
RESIN_DEVICE_TYPE: 'raspberry-pi'
|
||||
RESIN_HOST_OS_VERSION: 'Resin OS 2.0.2'
|
||||
RESIN_SERVICE_NAME: 'serviceName'
|
||||
RESIN_SUPERVISOR_VERSION: 'v1.0.0'
|
||||
RESIN_APP_LOCK_PATH: '/tmp/resin/resin-updates.lock'
|
||||
RESIN_SERVICE_KILL_ME_PATH: '/tmp/resin/resin-kill-me'
|
||||
RESIN: '1'
|
||||
USER: 'root'
|
||||
})
|
||||
|
||||
it 'returns the correct default bind mounts', ->
|
||||
s = new Service({
|
||||
appId: '1234'
|
||||
serviceName: 'foo'
|
||||
releaseId: 2
|
||||
serviceId: 3
|
||||
imageId: 4
|
||||
})
|
||||
binds = s.defaultBinds()
|
||||
expect(binds).to.deep.equal([
|
||||
'/tmp/resin-supervisor/services/1234/foo:/tmp/resin'
|
||||
])
|
||||
|
||||
it 'produces the correct port bindings and exposed ports', ->
|
||||
s = new Service({
|
||||
appId: '1234'
|
||||
serviceName: 'foo'
|
||||
releaseId: 2
|
||||
serviceId: 3
|
||||
imageId: 4
|
||||
expose: [
|
||||
1000,
|
||||
'243/udp'
|
||||
],
|
||||
ports: [
|
||||
'2344'
|
||||
'2345:2354'
|
||||
'2346:2367/udp'
|
||||
]
|
||||
}, {
|
||||
imageInfo: Config: {
|
||||
ExposedPorts: {
|
||||
'53/tcp': {}
|
||||
'53/udp': {}
|
||||
'2354/tcp': {}
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(s.portBindings).to.deep.equal({
|
||||
'2344/tcp': [{
|
||||
HostIp: '',
|
||||
HostPort: '2344'
|
||||
}],
|
||||
'2354/tcp': [{
|
||||
HostIp: '',
|
||||
HostPort: '2345'
|
||||
}],
|
||||
'2367/udp': [{
|
||||
HostIp: '',
|
||||
HostPort: '2346'
|
||||
}]
|
||||
})
|
||||
expect(s.exposedPorts).to.deep.equal({
|
||||
'1000/tcp': {}
|
||||
'243/udp': {}
|
||||
'2344/tcp': {}
|
||||
'2354/tcp': {}
|
||||
'2367/udp': {}
|
||||
'53/tcp': {}
|
||||
'53/udp': {}
|
||||
})
|
||||
|
||||
describe 'parseMemoryNumber()', ->
|
||||
makeComposeServiceWithLimit = (memLimit) ->
|
||||
new ComposeService(
|
||||
new Service(
|
||||
appId: 123456
|
||||
serviceId: 123456
|
||||
serviceName: 'foobar'
|
||||
|
Loading…
x
Reference in New Issue
Block a user