mirror of https://github.com/docker/docs.git
Merge pull request #1319 from docker/fix-api
Updated API calls for 1.22 and electron IPC update
This commit is contained in:
commit
14bdaf25db
|
|
@ -2,7 +2,7 @@ import app from 'app';
|
||||||
import BrowserWindow from 'browser-window';
|
import BrowserWindow from 'browser-window';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import ipc from 'ipc';
|
var ipc = require('electron').ipcMain;
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import child_process from 'child_process';
|
import child_process from 'child_process';
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ app.on('ready', function () {
|
||||||
mainWindow.openDevTools({detach: true});
|
mainWindow.openDevTools({detach: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow.loadUrl(path.normalize('file://' + path.join(__dirname, 'index.html')));
|
mainWindow.loadURL(path.normalize('file://' + path.join(__dirname, 'index.html')));
|
||||||
|
|
||||||
app.on('activate-with-no-open-windows', function () {
|
app.on('activate-with-no-open-windows', function () {
|
||||||
if (mainWindow) {
|
if (mainWindow) {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,13 @@ var ContainerHomeFolder = React.createClass({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
containerActions.update(this.props.container.Name, {Mounts: mounts});
|
let binds = mounts.map(m => {
|
||||||
|
return m.Source + ':' + m.Destination;
|
||||||
|
});
|
||||||
|
|
||||||
|
let hostConfig = _.extend(this.props.container.HostConfig, {Binds: binds});
|
||||||
|
|
||||||
|
containerActions.update(this.props.container.Name, {Mounts: mounts, HostConfig: hostConfig});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,9 @@ var ContainerSettingsPorts = React.createClass({
|
||||||
// collision with ports for current container
|
// collision with ports for current container
|
||||||
const otherContainers = _.filter(_.values(containerStore.getState().containers), c => c.Name !== this.props.container.Name);
|
const otherContainers = _.filter(_.values(containerStore.getState().containers), c => c.Name !== this.props.container.Name);
|
||||||
const otherPorts = _.flatten(otherContainers.map(container => {
|
const otherPorts = _.flatten(otherContainers.map(container => {
|
||||||
return _.values(container.NetworkSettings.Ports).map(hosts => hosts.map(host => {return {port: host.HostPort, name: container.Name}}));
|
return _.values(container.NetworkSettings.Ports).map(hosts => hosts.map(host => {
|
||||||
|
return {port: host.HostPort, name: container.Name}
|
||||||
|
}));
|
||||||
})).reduce((prev, pair) => {
|
})).reduce((prev, pair) => {
|
||||||
prev[pair.port] = pair.name;
|
prev[pair.port] = pair.name;
|
||||||
return prev;
|
return prev;
|
||||||
|
|
@ -76,17 +78,18 @@ var ContainerSettingsPorts = React.createClass({
|
||||||
this.setState({ports: ports});
|
this.setState({ports: ports});
|
||||||
},
|
},
|
||||||
handleSave: function () {
|
handleSave: function () {
|
||||||
let bindings = _.reduce(this.state.ports, (res, value, key) => {
|
let exposedPorts = {};
|
||||||
|
let portBindings = _.reduce(this.state.ports, (res, value, key) => {
|
||||||
res[key + '/' + value.portType] = [{
|
res[key + '/' + value.portType] = [{
|
||||||
HostPort: value.port
|
HostPort: value.port
|
||||||
}];
|
}];
|
||||||
|
exposedPorts[key] = {};
|
||||||
return res;
|
return res;
|
||||||
}, {});
|
}, {});
|
||||||
containerActions.update(this.props.container.Name, {
|
|
||||||
NetworkSettings: {
|
let hostConfig = _.extend(this.props.container.HostConfig, {PortBindings: portBindings});
|
||||||
Ports: bindings
|
|
||||||
}
|
containerActions.update(this.props.container.Name, {ExposedPorts: exposedPorts, HostConfig: hostConfig});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
if (!this.props.container) {
|
if (!this.props.container) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ var ContainerSettingsVolumes = React.createClass({
|
||||||
_.each(mounts, m => {
|
_.each(mounts, m => {
|
||||||
if (m.Destination === dockerVol) {
|
if (m.Destination === dockerVol) {
|
||||||
m.Source = util.windowsToLinuxPath(directory);
|
m.Source = util.windowsToLinuxPath(directory);
|
||||||
|
m.Driver = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -38,7 +39,9 @@ var ContainerSettingsVolumes = React.createClass({
|
||||||
return m.Source + ':' + m.Destination;
|
return m.Source + ':' + m.Destination;
|
||||||
});
|
});
|
||||||
|
|
||||||
containerActions.update(this.props.container.Name, {Binds: binds, Mounts: mounts});
|
let hostConfig = _.extend(this.props.container.HostConfig, {Binds: binds});
|
||||||
|
|
||||||
|
containerActions.update(this.props.container.Name, {Mounts: mounts, HostConfig: hostConfig});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleRemoveVolumeClick: function (dockerVol) {
|
handleRemoveVolumeClick: function (dockerVol) {
|
||||||
|
|
@ -50,10 +53,17 @@ var ContainerSettingsVolumes = React.createClass({
|
||||||
_.each(mounts, m => {
|
_.each(mounts, m => {
|
||||||
if (m.Destination === dockerVol) {
|
if (m.Destination === dockerVol) {
|
||||||
m.Source = null;
|
m.Source = null;
|
||||||
|
m.Driver = 'local';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
containerActions.update(this.props.container.Name, {Mounts: mounts});
|
let binds = mounts.map(m => {
|
||||||
|
return m.Source + ':' + m.Destination;
|
||||||
|
});
|
||||||
|
|
||||||
|
let hostConfig = _.extend(this.props.container.HostConfig, {Binds: binds});
|
||||||
|
|
||||||
|
containerActions.update(this.props.container.Name, {Mounts: mounts, HostConfig: hostConfig});
|
||||||
},
|
},
|
||||||
handleOpenVolumeClick: function (path) {
|
handleOpenVolumeClick: function (path) {
|
||||||
metrics.track('Opened Volume Directory', {
|
metrics.track('Opened Volume Directory', {
|
||||||
|
|
|
||||||
|
|
@ -83,21 +83,9 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
startContainer (name, containerData) {
|
startContainer (name) {
|
||||||
let startopts = {
|
|
||||||
Binds: containerData.Binds || []
|
|
||||||
};
|
|
||||||
|
|
||||||
if (containerData.NetworkSettings && containerData.NetworkSettings.Ports) {
|
|
||||||
startopts.PortBindings = containerData.NetworkSettings.Ports;
|
|
||||||
} else if (containerData.HostConfig && containerData.HostConfig.PortBindings) {
|
|
||||||
startopts.PortBindings = containerData.HostConfig.PortBindings;
|
|
||||||
} else {
|
|
||||||
startopts.PublishAllPorts = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
let container = this.client.getContainer(name);
|
let container = this.client.getContainer(name);
|
||||||
container.start(startopts, (error) => {
|
container.start((error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
containerServerActions.error({name, error});
|
containerServerActions.error({name, error});
|
||||||
return;
|
return;
|
||||||
|
|
@ -126,6 +114,10 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!containerData.HostConfig || (containerData.HostConfig && !containerData.HostConfig.PortBindings)) {
|
||||||
|
containerData.PublishAllPorts = true;
|
||||||
|
}
|
||||||
|
|
||||||
containerData.Cmd = image.Config.Cmd || image.Config.Entrypoint || 'bash';
|
containerData.Cmd = image.Config.Cmd || image.Config.Entrypoint || 'bash';
|
||||||
let existing = this.client.getContainer(name);
|
let existing = this.client.getContainer(name);
|
||||||
existing.kill(() => {
|
existing.kill(() => {
|
||||||
|
|
@ -136,7 +128,7 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
metrics.track('Container Finished Creating');
|
metrics.track('Container Finished Creating');
|
||||||
this.startContainer(name, containerData);
|
this.startContainer(name);
|
||||||
delete this.placeholders[name];
|
delete this.placeholders[name];
|
||||||
localStorage.setItem('placeholders', JSON.stringify(this.placeholders));
|
localStorage.setItem('placeholders', JSON.stringify(this.placeholders));
|
||||||
});
|
});
|
||||||
|
|
@ -250,22 +242,6 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Mounts = data.Mounts || existingData.Mounts;
|
data.Mounts = data.Mounts || existingData.Mounts;
|
||||||
data.Binds = data.Mounts.map(m => m.Source + ':' + m.Destination);
|
|
||||||
|
|
||||||
// Preserve Ports
|
|
||||||
let networking = _.extend(existingData.NetworkSettings, data.NetworkSettings);
|
|
||||||
if (networking && networking.Ports) {
|
|
||||||
let exposed = _.reduce(networking.Ports, (res, value, key) => {
|
|
||||||
res[key] = {};
|
|
||||||
return res;
|
|
||||||
}, {});
|
|
||||||
data = _.extend(data, {
|
|
||||||
HostConfig: {
|
|
||||||
PortBindings: networking.Ports
|
|
||||||
},
|
|
||||||
ExposedPorts: exposed
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var fullData = _.extend(existingData, data);
|
var fullData = _.extend(existingData, data);
|
||||||
this.createContainer(name, fullData);
|
this.createContainer(name, fullData);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue