This commit is contained in:
Fabian Jakobs 2024-09-04 14:08:11 +02:00
parent 694413b115
commit 4cd9b17625
No known key found for this signature in database
3 changed files with 21 additions and 3 deletions

View File

@ -9,6 +9,6 @@ import (
const envDatabricksRuntimeVersion = "DATABRICKS_RUNTIME_VERSION"
func RunsOnDatabricks(ctx context.Context) bool {
_, ok := env.Lookup(ctx, envDatabricksRuntimeVersion)
return ok
value, ok := env.Lookup(ctx, envDatabricksRuntimeVersion)
return value != "" && ok
}

View File

@ -0,0 +1,18 @@
package runtime
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRunsOnDatabricks(t *testing.T) {
ctx := context.Background()
t.Setenv("DATABRICKS_RUNTIME_VERSION", "")
assert.False(t, RunsOnDatabricks(ctx))
t.Setenv("DATABRICKS_RUNTIME_VERSION", "14.3")
assert.True(t, RunsOnDatabricks(ctx))
}

View File

@ -115,7 +115,7 @@ func shouldUseImportNotebook(ctx context.Context, path string, content []byte) b
if err != nil {
log.Debugf(ctx, "Error detecting notebook: %v", err)
}
return isNotebook && err != nil
return isNotebook && err == nil
}
return false