fix workspace issues

This commit is contained in:
Brad Rydzewski 2020-01-17 13:12:55 -08:00
parent b8bb780285
commit 4706608ba0
1 changed files with 31 additions and 3 deletions

View File

@ -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 {