mirror of https://github.com/databricks/cli.git
Added support for build command chaining and error on missing wheel (#607)
## Changes Added support for build command chaining and error on missing wheel
This commit is contained in:
parent
8cdf7284f8
commit
12bba17743
|
@ -1,6 +1,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
@ -40,10 +41,19 @@ func (a *Artifact) Build(ctx context.Context) ([]byte, error) {
|
||||||
return nil, fmt.Errorf("no build property defined")
|
return nil, fmt.Errorf("no build property defined")
|
||||||
}
|
}
|
||||||
|
|
||||||
buildParts := strings.Split(a.BuildCommand, " ")
|
out := make([][]byte, 0)
|
||||||
cmd := exec.CommandContext(ctx, buildParts[0], buildParts[1:]...)
|
commands := strings.Split(a.BuildCommand, " && ")
|
||||||
cmd.Dir = a.Path
|
for _, command := range commands {
|
||||||
return cmd.CombinedOutput()
|
buildParts := strings.Split(command, " ")
|
||||||
|
cmd := exec.CommandContext(ctx, buildParts[0], buildParts[1:]...)
|
||||||
|
cmd.Dir = a.Path
|
||||||
|
res, err := cmd.CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
return res, err
|
||||||
|
}
|
||||||
|
out = append(out, res)
|
||||||
|
}
|
||||||
|
return bytes.Join(out, []byte{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *Artifact) NormalisePaths() {
|
func (a *Artifact) NormalisePaths() {
|
||||||
|
|
|
@ -68,6 +68,10 @@ func findArtifactsAndMarkForUpload(ctx context.Context, lib *compute.Library, b
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(matches) == 0 && isLocalLibrary(lib) {
|
||||||
|
return fmt.Errorf("no library found for %s", libPath(lib))
|
||||||
|
}
|
||||||
|
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
af, err := findArtifactFileByLocalPath(match, b)
|
af, err := findArtifactFileByLocalPath(match, b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -105,3 +109,7 @@ func libPath(library *compute.Library) string {
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isLocalLibrary(library *compute.Library) bool {
|
||||||
|
return libPath(library) != ""
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue