Skip to content

Commit

Permalink
Merge pull request #782 from mesosphere/fix/DCOS-10184-service-port-h…
Browse files Browse the repository at this point in the history
…andling

DCOS-10184: Fix service port handling
  • Loading branch information
Poltergeist committed Oct 6, 2016
2 parents 26f6773 + 1f228b4 commit ff76119
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/js/components/AppConfigEditFormComponent.jsx
Expand Up @@ -194,7 +194,8 @@ var AppConfigEditFormComponent = React.createClass({
getOptionalPortsComponent: function () {
var state = this.state;

if (state.fields.dockerNetwork === ContainerConstants.NETWORK.BRIDGE) {
if (state.fields.dockerNetwork === ContainerConstants.NETWORK.BRIDGE ||
state.fields.dockerNetwork === ContainerConstants.NETWORK.USER) {
return (
<OptionalDockerPortMappingsComponent
errorIndices={state.errorIndices}
Expand Down
3 changes: 3 additions & 0 deletions src/js/components/ContainerSettingsComponent.jsx
Expand Up @@ -143,6 +143,9 @@ var ContainerSettingsComponent = React.createClass({
<option value={ContainerConstants.NETWORK.BRIDGE}>
Bridged
</option>
<option value={ContainerConstants.NETWORK.USER}>
User
</option>
</select>
</FormGroupComponent>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/js/constants/ContainerConstants.js
Expand Up @@ -3,6 +3,7 @@ import Util from "../helpers/Util";
const ContainerConstants = {
NETWORK: {
BRIDGE: "BRIDGE",
USER: "USER",
HOST: "HOST"
},
PORTMAPPINGS: {
Expand Down
8 changes: 3 additions & 5 deletions src/js/mixins/DuplicableRowsMixin.jsx
Expand Up @@ -79,12 +79,10 @@ var DuplicableRowsMixin = {
},

getDuplicableRowValues: function (fieldId, i) {
var findDOMNode = React.findDOMNode;
var refs = this.refs;
const findDOMNode = React.findDOMNode;
const refs = this.refs;

const row = {
consecutiveKey: this.state.rows[fieldId][i].consecutiveKey
};
const row = Util.deepCopy(this.state.rows[fieldId][i]);

return Object.keys(this.duplicableRowsScheme[fieldId])
.reduce(function (memo, key) {
Expand Down
3 changes: 2 additions & 1 deletion src/js/stores/AppFormStore.js
Expand Up @@ -501,7 +501,8 @@ var AppFormStore = Util.extendObject(EventEmitter.prototype, {
objectPath.get(app, "container.docker.network");

if (dockerNetwork != null &&
dockerNetwork === ContainerConstants.NETWORK.BRIDGE) {
(dockerNetwork === ContainerConstants.NETWORK.BRIDGE ||
dockerNetwork === ContainerConstants.NETWORK.USER)) {
delete app.portDefinitions;
} else if (objectPath.get(app, "container.docker.portMappings") != null) {
delete app.container.docker.portMappings;
Expand Down
14 changes: 13 additions & 1 deletion src/test/scenarios/createApplication.test.js
Expand Up @@ -798,7 +798,8 @@ describe("Create Application", function () {
});

describe("the network field", function () {
it("updates correctly", function (done) {

it("updates to BRIDGE", function (done) {
AppFormStore.once(FormEvents.CHANGE, function () {
expectAsync(function () {
expect(AppFormStore.fields.dockerNetwork)
Expand All @@ -808,6 +809,17 @@ describe("Create Application", function () {

FormActions.update("dockerNetwork", "BRIDGE");
});

it("updates to USER", function (done) {
AppFormStore.once(FormEvents.CHANGE, function () {
expectAsync(function () {
expect(AppFormStore.fields.dockerNetwork)
.to.equal("USER");
}, done);
});

FormActions.update("dockerNetwork", "USER");
});
});

describe("the privileges field", function () {
Expand Down
18 changes: 17 additions & 1 deletion src/test/units/AppFormModelPostProcess.test.js
Expand Up @@ -87,7 +87,7 @@ describe("App Form Model Post Process", function () {
.to.equal(ContainerConstants.NETWORK.HOST);
});

it("sets network mode to HOST when nothing is selected", function () {
it("sets network mode to BRIDGE", function () {
var app = {
container: {
docker: {
Expand All @@ -104,6 +104,22 @@ describe("App Form Model Post Process", function () {
.to.equal(ContainerConstants.NETWORK.BRIDGE);
});

it("sets network mode to USER", function () {
var app = {
container: {
docker: {
image: "group/image",
network: ContainerConstants.NETWORK.USER
},
type: "DOCKER"
}
};
var app2 = Object.assign({}, app);
AppFormModelPostProcess.container(app2);

expect(app2.container.docker.network)
.to.equal(ContainerConstants.NETWORK.USER);
});
});

describe("health checks", function () {
Expand Down

0 comments on commit ff76119

Please sign in to comment.