From 6a3afbd9a08c8f20ee613d14d47b805c97934fa6 Mon Sep 17 00:00:00 2001 From: Teyyub Ismayilov <71545850+teyyubismayil@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:53:40 +0400 Subject: [PATCH] Replace path separators to slash on windows for local packs (#578) --- CHANGELOG.md | 1 + internal/pkg/cache/pack.go | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acc9223c..d3b76d7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ IMPROVEMENTS: BUG FIXES: * cli: Update references to `hello-world` pack in command help text to `hello_world` [[GH-523](https://github.com/hashicorp/nomad-pack/pull/523)] * docker: Added tzdata to container to fix panics running packs containing periodic jobs with timezones [[GH-564](https://github.com/hashicorp/nomad-pack/pull/564)] +* cli: Replace path separators to slash on windows for local packs [[GH-578](https://github.com/hashicorp/nomad-pack/pull/578)] ## 0.1.2 (June 7, 2024) diff --git a/internal/pkg/cache/pack.go b/internal/pkg/cache/pack.go index 96466067..8a1b611e 100644 --- a/internal/pkg/cache/pack.go +++ b/internal/pkg/cache/pack.go @@ -7,6 +7,8 @@ import ( "os" "path" "path/filepath" + "runtime" + "strings" "github.com/hashicorp/nomad-pack/sdk/pack" ) @@ -46,7 +48,11 @@ func (cfg *PackConfig) Init() { func (cfg *PackConfig) initFromDirectory(packPath string) { // Keep the original user argument so that we can explain how to manage in output cfg.SourcePath = cfg.Name - cfg.Path = packPath + if runtime.GOOS == "windows" { + cfg.Path = strings.ReplaceAll(packPath, "\\", "/") + } else { + cfg.Path = packPath + } cfg.Name = path.Base(cfg.Path) cfg.Registry = DevRegistryName cfg.Ref = DevRef