From 4706608ba016171ca01b22227e704b6ed16b5e06 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Fri, 17 Jan 2020 13:12:55 -0800 Subject: [PATCH] fix workspace issues --- yaml/converter/legacy/internal/config.go | 34 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/yaml/converter/legacy/internal/config.go b/yaml/converter/legacy/internal/config.go index 91e7363..bd5c79a 100644 --- a/yaml/converter/legacy/internal/config.go +++ b/yaml/converter/legacy/internal/config.go @@ -9,6 +9,7 @@ import ( "fmt" "net/url" "os" + "path/filepath" "sort" "strings" @@ -60,9 +61,6 @@ func Convert(d []byte, remote string) ([]byte, error) { pipeline := droneyaml.Pipeline{} pipeline.Name = "default" pipeline.Kind = "pipeline" - if os.Getenv("DRONE_CONVERT_YAML_LEGACY_TO_KUBERNETES") == "true" { - pipeline.Type = "kubernetes" - } pipeline.Workspace.Base = from.Workspace.Base pipeline.Workspace.Path = from.Workspace.Path @@ -79,6 +77,36 @@ func Convert(d []byte, remote string) ([]byte, error) { } } + if os.Getenv("DRONE_CONVERT_YAML_LEGACY_TO_KUBERNETES") == "true" { + pipeline.Type = "kubernetes" + + if from.Workspace.Base != "" && from.Workspace.Path != "" { + pipeline.Workspace.Base = "" + pipeline.Workspace.Path = filepath.Join( + from.Workspace.Base, + from.Workspace.Path, + ) + } else if from.Workspace.Base != "" { + pipeline.Workspace.Base = "" + pipeline.Workspace.Path = filepath.Join( + from.Workspace.Base, + toWorkspacePath(remote), + ) + } else if from.Workspace.Path != "" { + pipeline.Workspace.Base = "" + pipeline.Workspace.Path = filepath.Join( + "/drone", + from.Workspace.Path, + ) + } else { + pipeline.Workspace.Base = "" + pipeline.Workspace.Path = filepath.Join( + "/drone", + toWorkspacePath(remote), + ) + } + } + if len(from.Clone.Containers) != 0 { pipeline.Clone.Disable = true for _, container := range from.Clone.Containers {