mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-01-03 12:34:11 +00:00
Merge pull request #1691 from quentingllmt/fix/compose_drivers_opts_to_docker
Fix passing driver_opts from compose to docker network creation
This commit is contained in:
commit
3787dfc3dd
@ -130,6 +130,7 @@ export class Network {
|
||||
Name: Network.generateDockerName(this.appId, this.name),
|
||||
Driver: this.config.driver,
|
||||
CheckDuplicate: true,
|
||||
Options: this.config.options,
|
||||
IPAM: {
|
||||
Driver: this.config.ipam.driver,
|
||||
Config: this.config.ipam.config.map((conf) => {
|
||||
|
@ -110,6 +110,62 @@ describe('compose/network', () => {
|
||||
'Network IPAM config entries must have both a subnet and gateway',
|
||||
);
|
||||
});
|
||||
|
||||
it('parses values from a compose object', () => {
|
||||
const network1 = Network.fromComposeObject('default', 12345, {
|
||||
driver: 'bridge',
|
||||
enable_ipv6: true,
|
||||
internal: false,
|
||||
ipam: {
|
||||
driver: 'default',
|
||||
options: {
|
||||
'com.docker.ipam-option': 'abcd',
|
||||
},
|
||||
config: [
|
||||
{
|
||||
subnet: '172.18.0.0/16',
|
||||
gateway: '172.18.0.1',
|
||||
},
|
||||
],
|
||||
},
|
||||
driver_opts: {
|
||||
'com.docker.network-option': 'abcd',
|
||||
},
|
||||
labels: {
|
||||
'com.docker.some-label': 'yes',
|
||||
},
|
||||
});
|
||||
|
||||
const dockerConfig = network1.toDockerConfig();
|
||||
|
||||
expect(dockerConfig.Driver).to.equal('bridge');
|
||||
// Check duplicate forced to be true
|
||||
expect(dockerConfig.CheckDuplicate).to.equal(true);
|
||||
expect(dockerConfig.Internal).to.equal(false);
|
||||
expect(dockerConfig.EnableIPv6).to.equal(true);
|
||||
|
||||
expect(dockerConfig.IPAM).to.deep.equal({
|
||||
Driver: 'default',
|
||||
Options: {
|
||||
'com.docker.ipam-option': 'abcd',
|
||||
},
|
||||
Config: [
|
||||
{
|
||||
Subnet: '172.18.0.0/16',
|
||||
Gateway: '172.18.0.1',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
expect(dockerConfig.Labels).to.deep.equal({
|
||||
'io.balena.supervised': 'true',
|
||||
'com.docker.some-label': 'yes',
|
||||
});
|
||||
|
||||
expect(dockerConfig.Options).to.deep.equal({
|
||||
'com.docker.network-option': 'abcd',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('creating a network from docker engine state', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user