Skip to content

Commit

Permalink
fix(container): error when getting status ahead of building
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Mar 12, 2019
1 parent afeade9 commit 6c4b0b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
9 changes: 4 additions & 5 deletions garden-service/src/plugins/container/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@ export const containerHelpers = {

if (module.spec.image && hasDockerfile) {
const { versionString } = module.version
const parsedImage = containerHelpers.parseImageId(module.spec.image || module.name)
const parsedImage = containerHelpers.parseImageId(module.spec.image)
return containerHelpers.unparseImageId({ ...parsedImage, tag: versionString })
} else if (!module.spec.image && hasDockerfile) {
const { versionString } = module.version
return containerHelpers.unparseImageId({ repository: module.name, tag: versionString })
} else if (module.spec.image && !hasDockerfile) {
return module.spec.image
} else {
throw new ConfigurationError(
`Module ${module.name} neither specifies image nor provides Dockerfile`,
{ module },
)
const { versionString } = module.version
const parsedImage = containerHelpers.parseImageId(module.name)
return containerHelpers.unparseImageId({ ...parsedImage, tag: versionString })
}
},

Expand Down
16 changes: 3 additions & 13 deletions garden-service/test/src/plugins/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,7 @@ describe("plugins.container", () => {
expect(await containerHelpers.getLocalImageId(module)).to.equal("some/image:1.1")
})

it("should return configured image with local version if module has Dockerfile and name has no tag", async () => {
const config = cloneDeep(baseConfig)
config.spec.image = "some/image"
const module = await getTestModule(config)

td.replace(containerHelpers, "hasDockerfile", async () => true)

expect(await containerHelpers.getLocalImageId(module)).to.equal("some/image:1234")
})

it("should return module name with local version if there is no configured name", async () => {
it("should return module name with local version if there is a Dockerfile and no configured name", async () => {
const config = cloneDeep(baseConfig)
const module = await getTestModule(config)

Expand All @@ -116,13 +106,13 @@ describe("plugins.container", () => {
expect(await containerHelpers.getLocalImageId(module)).to.equal("test:1234")
})

it("should throw if there is no Dockerfile and no image specified", async () => {
it("should return module name with local version if there is no Dockerfile and no configured name", async () => {
const config = cloneDeep(baseConfig)
const module = await getTestModule(config)

td.replace(containerHelpers, "hasDockerfile", async () => false)

await expectError(() => containerHelpers.getLocalImageId(module), "configuration")
expect(await containerHelpers.getLocalImageId(module)).to.equal("test:1234")
})
})

Expand Down

0 comments on commit 6c4b0b4

Please sign in to comment.