Skip to content

Commit

Permalink
fix: cli matrix filter
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-tang-sw committed Sep 17, 2021
1 parent a07f120 commit 9a92ea0
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions cli/drone/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"io"
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -318,7 +317,7 @@ func execWithAxis(c *cli.Context, axis matrix.Axis) error {
file = ".drone.yml"
}

metadata := metadataFromContext(c)
metadata := metadataFromContext(c, axis)
environ := metadata.Environ()
secrets := []compiler.Secret{}
for k, v := range metadata.EnvironDrone() {
Expand All @@ -332,12 +331,6 @@ func execWithAxis(c *cli.Context, axis matrix.Axis) error {
})
}

if len(axis) != 0 {
for k, v := range axis {
environ[k] = v
}
}

droneEnv := make(map[string]string)
for _, env := range c.StringSlice("env") {
envs := strings.SplitN(env, "=", 2)
Expand Down Expand Up @@ -434,7 +427,7 @@ func execWithAxis(c *cli.Context, axis matrix.Axis) error {
}

// return the metadata from the cli context.
func metadataFromContext(c *cli.Context) frontend.Metadata {
func metadataFromContext(c *cli.Context, axis matrix.Axis) frontend.Metadata {
return frontend.Metadata{
Repo: frontend.Repo{
Name: c.String("repo-name"),
Expand Down Expand Up @@ -488,7 +481,7 @@ func metadataFromContext(c *cli.Context) frontend.Metadata {
},
Job: frontend.Job{
Number: c.Int("job-number"),
Matrix: availableEnvironment(),
Matrix: axis,
},
Sys: frontend.System{
Name: c.String("system-name"),
Expand All @@ -498,17 +491,6 @@ func metadataFromContext(c *cli.Context) frontend.Metadata {
}
}

func availableEnvironment() map[string]string {
result := make(map[string]string, 0)

for _, env := range os.Environ() {
pair := strings.SplitN(env, "=", 2)
result[pair[0]] = pair[1]
}

return result
}

func convertPathForWindows(path string) string {
base := filepath.VolumeName(path)
if len(base) == 2 {
Expand Down

0 comments on commit 9a92ea0

Please sign in to comment.