Skip to content

Commit

Permalink
fix(conftest): ensure policy path is valid POSIX on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
eysi09 committed Mar 30, 2020
1 parent 9939014 commit ee12c80
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 34 deletions.
44 changes: 12 additions & 32 deletions garden-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions garden-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
"recursive-readdir": "^2.2.2",
"request": "^2.88.2",
"request-promise": "^4.2.5",
"slash": "^3.0.0",
"source-map-support": "^0.5.16",
"split": "^1.0.1",
"split2": "^3.1.1",
Expand Down
4 changes: 3 additions & 1 deletion garden-service/src/plugins/conftest/conftest-kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import Bluebird from "bluebird"
import slash from "slash"
import { createGardenPlugin } from "../../types/plugin/plugin"
import { ConftestProvider } from "./conftest"
import { relative, resolve } from "path"
Expand Down Expand Up @@ -65,7 +66,8 @@ export const gardenPlugin = createGardenPlugin({
? [".rendered.yaml"]
: module.include || ["*.yaml", "**/*.yaml", "*.yml", "**/*.yml"]

const policyPath = relative(module.path, resolve(ctx.projectRoot, provider.config.policyPath))
// Make sure the policy path is valid POSIX on Windows
const policyPath = slash(relative(module.path, resolve(ctx.projectRoot, provider.config.policyPath)))

return {
kind: "Module",
Expand Down
4 changes: 3 additions & 1 deletion garden-service/src/plugins/conftest/conftest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { baseBuildSpecSchema } from "../../config/module"
import { matchGlobs, listDirectory } from "../../util/fs"
import { PluginError } from "../../exceptions"
import { getModuleTypeUrl, getGitHubUrl, getProviderUrl } from "../../docs/common"
import slash from "slash"

export interface ConftestProviderConfig extends ProviderConfig {
policyPath: string
Expand Down Expand Up @@ -135,7 +136,8 @@ export const gardenPlugin = createGardenPlugin({
const provider = ctx.provider as ConftestProvider

const defaultPolicyPath = relative(module.path, resolve(ctx.projectRoot, provider.config.policyPath))
const policyPath = resolve(module.path, module.spec.policyPath || defaultPolicyPath)
// Make sure the policy path is valid POSIX on Windows
const policyPath = slash(resolve(module.path, module.spec.policyPath || defaultPolicyPath))
const namespace = module.spec.namespace || provider.config.namespace

const buildPath = module.spec.sourceModule
Expand Down

0 comments on commit ee12c80

Please sign in to comment.