-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #446 from garden-io/service-port
Adds Service port config option to container module
- Loading branch information
Showing
14 changed files
with
124 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { renderSchemaDescription, getDefaultValue } from "../../../src/docs/config" | ||
import { expect } from "chai" | ||
import * as Joi from "joi" | ||
import dedent = require("dedent") | ||
|
||
describe("config", () => { | ||
const serivcePortSchema = Joi.number().default((context) => context.containerPort, "default value") | ||
.example("8080") | ||
.description("description") | ||
|
||
const testDefaultSchema = Joi.number().default(() => "result", "default value") | ||
.description("description") | ||
|
||
const portSchema = Joi.object() | ||
.keys({ | ||
containerPort: Joi.number() | ||
.required() | ||
.description("description"), | ||
servicePort: serivcePortSchema, | ||
}) | ||
.required() | ||
|
||
describe("renderSchemaDescription", () => { | ||
it("should render correct markdown", () => { | ||
const yaml = renderSchemaDescription(portSchema.describe(), { required: true }) | ||
expect(yaml).to.equal(dedent`\n# description | ||
# | ||
# Required. | ||
containerPort: | ||
# description | ||
# | ||
# Example: "8080" | ||
# | ||
# Optional. | ||
servicePort: default value`) | ||
}) | ||
}) | ||
|
||
describe("renderSchemaDescription", () => { | ||
it("should get the default return of the function over the param", () => { | ||
const value = getDefaultValue(testDefaultSchema.describe()) | ||
expect(value).to.eq("result") | ||
}) | ||
|
||
it("should get the default value if a function with context", () => { | ||
const value = getDefaultValue(serivcePortSchema.describe()) | ||
expect(value).to.eq("default value") | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expect } from "chai" | ||
import { validate } from "../../../src/config/common" | ||
import { portSchema } from "../../../src/plugins/container" | ||
|
||
describe("portSchema", () => { | ||
it("should default servicePort to containerPorts value", async () => { | ||
const containerPort = 8080 | ||
const obj = { name: "a", containerPort } | ||
|
||
const value = validate(obj, portSchema) | ||
expect(value["servicePort"]).to.equal(containerPort) | ||
}) | ||
|
||
it("should not default servicePort to containerPorts when configured", async () => { | ||
const containerPort = 8080 | ||
const servicePort = 9090 | ||
const obj = { name: "a", containerPort, servicePort } | ||
|
||
const value = validate(obj, portSchema) | ||
expect(value["servicePort"]).to.equal(servicePort) | ||
}) | ||
}) |