Skip to content

Commit

Permalink
fix: handling varfiles with helm sources
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Ruck <[email protected]>
  • Loading branch information
Manuel Ruck committed Jun 5, 2024
1 parent 98a5504 commit be50da1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions core/src/config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,24 +552,27 @@ export async function loadVarfile({
path,
defaultPath,
optional = false,
configFilePath,
}: {
// project root (when resolving project config) or module root (when resolving module config)
configRoot: string
path: string | undefined
defaultPath: string | undefined
optional?: boolean
configFilePath?: string
}): Promise<PrimitiveMap> {
if (!path && !defaultPath) {
throw new ParameterError({
message: `Neither a path nor a defaultPath was provided. Config root: ${configRoot}`,
})
}
const resolvedPath = resolve(configRoot, <string>(path || defaultPath))
const configFileDir = configFilePath ? dirname(configFilePath) : configRoot
const resolvedPath = resolve(configFileDir, <string>(path || defaultPath))
const exists = await pathExists(resolvedPath)

if (!exists && path && path !== defaultPath && !optional) {
throw new ConfigurationError({
message: `Could not find varfile at path '${path}'. Absolute path: ${resolvedPath}`,
message: `Could not find varfile at path '${path}'. Absolute path: ${resolvedPath}, ${configRoot}, ${defaultPath}`,
})
}

Expand Down
1 change: 1 addition & 0 deletions core/src/graph/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ async function processActionConfig({
basePath: config.internal.basePath,
variables: config.variables,
varfiles: config.varfiles,
configFilePath: config.internal.configFilePath,
})

// override the variables if there's any matching variables in variable overrides
Expand Down
3 changes: 3 additions & 0 deletions core/src/graph/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ export const mergeVariables = profileAsync(async function mergeVariables({
basePath,
variables,
varfiles,
configFilePath,
}: {
basePath: string
variables?: DeepPrimitiveMap
varfiles?: Varfile[]
configFilePath?: string
}) {
const varsByFile = await Promise.all(
(varfiles || []).map((varfile) => {
Expand All @@ -163,6 +165,7 @@ export const mergeVariables = profileAsync(async function mergeVariables({
path,
defaultPath: undefined,
optional,
configFilePath,
})
})
)
Expand Down
1 change: 1 addition & 0 deletions core/src/tasks/resolve-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export class ResolveActionTask<T extends Action> extends BaseActionTask<T, Resol
basePath: action.sourcePath(),
variables: config.variables,
varfiles: config.varfiles,
configFilePath: action.getConfig().internal.configFilePath,
}),
context: new ActionSpecContext({
garden: this.garden,
Expand Down

0 comments on commit be50da1

Please sign in to comment.