mirror of https://github.com/databricks/cli.git
Fixed seg fault when specifying environment key for tasks (#1443)
## Changes Fixed seg fault when specifying environment key for tasks
This commit is contained in:
parent
09aa3cb9e9
commit
3f8036f2df
|
@ -150,6 +150,10 @@ func uploadArtifact(ctx context.Context, b *bundle.Bundle, a *config.Artifact, u
|
|||
|
||||
for i := range job.Environments {
|
||||
env := &job.Environments[i]
|
||||
if env.Spec == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for j := range env.Spec.Dependencies {
|
||||
lib := env.Spec.Dependencies[j]
|
||||
if isArtifactMatchLibrary(f, lib, b) {
|
||||
|
|
|
@ -30,6 +30,10 @@ func FindAllEnvironments(b *bundle.Bundle) map[string]([]jobs.JobEnvironment) {
|
|||
|
||||
func isEnvsWithLocalLibraries(envs []jobs.JobEnvironment) bool {
|
||||
for _, e := range envs {
|
||||
if e.Spec == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, l := range e.Spec.Dependencies {
|
||||
if IsEnvironmentDependencyLocal(l) {
|
||||
return true
|
||||
|
|
|
@ -62,6 +62,10 @@ func validateTaskLibraries(libs []compute.Library, b *bundle.Bundle) error {
|
|||
|
||||
func validateEnvironments(envs []jobs.JobEnvironment, b *bundle.Bundle) error {
|
||||
for _, env := range envs {
|
||||
if env.Spec == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, dep := range env.Spec.Dependencies {
|
||||
matches, err := filepath.Glob(filepath.Join(b.RootPath, dep))
|
||||
if err != nil {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package config_tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/databricks/cli/bundle"
|
||||
"github.com/databricks/cli/bundle/libraries"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -10,3 +13,11 @@ func TestEnvironmentKeySupported(t *testing.T) {
|
|||
_, diags := loadTargetWithDiags("./python_wheel/environment_key", "default")
|
||||
require.Empty(t, diags)
|
||||
}
|
||||
|
||||
func TestEnvironmentKeyProvidedAndNoPanic(t *testing.T) {
|
||||
b, diags := loadTargetWithDiags("./environment_key_only", "default")
|
||||
require.Empty(t, diags)
|
||||
|
||||
diags = bundle.Apply(context.Background(), b, libraries.ValidateLocalLibrariesExist())
|
||||
require.Empty(t, diags)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
bundle:
|
||||
name: environment_key_only
|
||||
|
||||
resources:
|
||||
jobs:
|
||||
test_job:
|
||||
name: "My Wheel Job"
|
||||
tasks:
|
||||
- task_key: TestTask
|
||||
existing_cluster_id: "0717-132531-5opeqon1"
|
||||
python_wheel_task:
|
||||
package_name: "my_test_code"
|
||||
entry_point: "run"
|
||||
environment_key: "test_env"
|
||||
environments:
|
||||
- environment_key: "test_env"
|
Loading…
Reference in New Issue