From 70c3e5954b60ec95c55df6e0695d8847591f4d1f Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Tue, 16 Jul 2019 16:25:50 +0200 Subject: [PATCH] fix(core): rsync error when running from dist build The error was caused by the use of absolute path in .garden-version files. This needs a more complete overhaul and testing to avoid future issues, but does the trick for now. --- garden-service/src/bin/add-version-files.ts | 4 ++++ garden-service/src/build-dir.ts | 2 +- garden-service/src/types/module.ts | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/garden-service/src/bin/add-version-files.ts b/garden-service/src/bin/add-version-files.ts index b1b99fc5f8..b028b358f4 100644 --- a/garden-service/src/bin/add-version-files.ts +++ b/garden-service/src/bin/add-version-files.ts @@ -35,6 +35,10 @@ async function addVersionFiles() { const vcsHandler = new GitHandler(garden.gardenDirPath) const treeVersion = await vcsHandler.getTreeVersion(path, config.include || null) + treeVersion.files = treeVersion.files + .map(f => relative(path, f)) + .filter(f => f !== ".garden-version") + console.log(`${config.name} -> ${relative(STATIC_DIR, versionFilePath)}`) return writeFile(versionFilePath, JSON.stringify(treeVersion, null, 4) + "\n") diff --git a/garden-service/src/build-dir.ts b/garden-service/src/build-dir.ts index d970bab2da..738c909f56 100644 --- a/garden-service/src/build-dir.ts +++ b/garden-service/src/build-dir.ts @@ -38,7 +38,7 @@ export class BuildDir { async syncFromSrc(module: Module, log: LogEntry) { const files = module.version.files - .map(f => relative(module.path, f)) + .map(f => isAbsolute(f) ? relative(module.path, f) : f) await this.sync({ module, diff --git a/garden-service/src/types/module.ts b/garden-service/src/types/module.ts index 5bb0e01eb5..73cf995973 100644 --- a/garden-service/src/types/module.ts +++ b/garden-service/src/types/module.ts @@ -19,6 +19,7 @@ import { joiArray, joiIdentifier, joiIdentifierMap, joi } from "../config/common import { ConfigGraph } from "../config-graph" import * as Bluebird from "bluebird" import { getConfigFilePath } from "../util/fs" +import { relative } from "path" export interface FileCopySpec { source: string @@ -92,10 +93,12 @@ export interface ModuleConfigMap { export async function moduleFromConfig(garden: Garden, graph: ConfigGraph, config: ModuleConfig): Promise { const configPath = await getConfigFilePath(config.path) + const relativeConfigPath = relative(config.path, configPath) const version = await garden.resolveVersion(config.name, config.build.dependencies) // Always include configuration file - if (!version.files.includes(configPath)) { + // TODO: move this logic to resolveVersion() + if (!version.files.includes(configPath) && !version.files.includes(relativeConfigPath)) { version.files.push(configPath) }