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 fs from 'fs'; | ||||
| import os from 'os'; | ||||
| import ipc from 'ipc'; | ||||
| var ipc = require('electron').ipcMain; | ||||
| import path from 'path'; | ||||
| import child_process from 'child_process'; | ||||
| 
 | ||||
|  | @ -57,7 +57,7 @@ app.on('ready', function () { | |||
|     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 () { | ||||
|     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 { | ||||
|  |  | |||
|  | @ -39,7 +39,9 @@ var ContainerSettingsPorts = React.createClass({ | |||
|     // collision with ports for current container
 | ||||
|     const otherContainers = _.filter(_.values(containerStore.getState().containers), c => c.Name !== this.props.container.Name); | ||||
|     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) => { | ||||
|       prev[pair.port] = pair.name; | ||||
|       return prev; | ||||
|  | @ -76,17 +78,18 @@ var ContainerSettingsPorts = React.createClass({ | |||
|     this.setState({ports: ports}); | ||||
|   }, | ||||
|   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] = [{ | ||||
|         HostPort: value.port | ||||
|       }]; | ||||
|       exposedPorts[key] = {}; | ||||
|       return res; | ||||
|     }, {}); | ||||
|     containerActions.update(this.props.container.Name, { | ||||
|       NetworkSettings: { | ||||
|         Ports: bindings | ||||
|       } | ||||
|     }); | ||||
| 
 | ||||
|     let hostConfig = _.extend(this.props.container.HostConfig, {PortBindings: portBindings}); | ||||
| 
 | ||||
|     containerActions.update(this.props.container.Name, {ExposedPorts: exposedPorts, HostConfig: hostConfig}); | ||||
|   }, | ||||
|   render: function () { | ||||
|     if (!this.props.container) { | ||||
|  |  | |||
|  | @ -31,6 +31,7 @@ var ContainerSettingsVolumes = React.createClass({ | |||
|       _.each(mounts, m => { | ||||
|         if (m.Destination === dockerVol) { | ||||
|           m.Source = util.windowsToLinuxPath(directory); | ||||
|           m.Driver = null; | ||||
|         } | ||||
|       }); | ||||
| 
 | ||||
|  | @ -38,7 +39,9 @@ var ContainerSettingsVolumes = React.createClass({ | |||
|         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) { | ||||
|  | @ -50,10 +53,17 @@ var ContainerSettingsVolumes = React.createClass({ | |||
|     _.each(mounts, m => { | ||||
|       if (m.Destination === dockerVol) { | ||||
|         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) { | ||||
|     metrics.track('Opened Volume Directory', { | ||||
|  |  | |||
|  | @ -83,21 +83,9 @@ export default { | |||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   startContainer (name, containerData) { | ||||
|     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; | ||||
|     } | ||||
| 
 | ||||
|   startContainer (name) { | ||||
|     let container = this.client.getContainer(name); | ||||
|     container.start(startopts, (error) => { | ||||
|     container.start((error) => { | ||||
|       if (error) { | ||||
|         containerServerActions.error({name, error}); | ||||
|         return; | ||||
|  | @ -126,6 +114,10 @@ export default { | |||
|         return; | ||||
|       } | ||||
| 
 | ||||
|       if (!containerData.HostConfig || (containerData.HostConfig && !containerData.HostConfig.PortBindings)) { | ||||
|         containerData.PublishAllPorts = true; | ||||
|       } | ||||
| 
 | ||||
|       containerData.Cmd = image.Config.Cmd || image.Config.Entrypoint || 'bash'; | ||||
|       let existing = this.client.getContainer(name); | ||||
|       existing.kill(() => { | ||||
|  | @ -136,7 +128,7 @@ export default { | |||
|               return; | ||||
|             } | ||||
|             metrics.track('Container Finished Creating'); | ||||
|             this.startContainer(name, containerData); | ||||
|             this.startContainer(name); | ||||
|             delete this.placeholders[name]; | ||||
|             localStorage.setItem('placeholders', JSON.stringify(this.placeholders)); | ||||
|           }); | ||||
|  | @ -250,22 +242,6 @@ export default { | |||
|       } | ||||
| 
 | ||||
|       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); | ||||
|       this.createContainer(name, fullData); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue