Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bundle/config/mutator/configure_wsfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func (m *configureWSFS) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagno
return nil
}

// If running on serverless, use OS file functions directly.
if dbr.RunsOnServerless(ctx) {
return nil
}

// If so, swap out vfs.Path instance of the sync root with one that
// makes all Workspace File System interactions extension aware.
p, err := vfs.NewFilerPath(ctx, root, func(path string) (filer.Filer, error) {
Expand Down
11 changes: 11 additions & 0 deletions bundle/config/mutator/configure_wsfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,14 @@ func TestConfigureWSFS_SwapSyncRoot(t *testing.T) {
assert.Empty(t, diags)
assert.NotEqual(t, originalSyncRoot, b.SyncRoot)
}

func TestConfigureWSFS_SkipsIfRunningOnServerless(t *testing.T) {
b := mockBundleForConfigureWSFS(t, "/Workspace/foo")
originalSyncRoot := b.SyncRoot

ctx := context.Background()
ctx = dbr.MockRuntime(ctx, dbr.Environment{IsDbr: true, Version: "client.1.13"})
diags := bundle.Apply(ctx, b, mutator.ConfigureWSFS())
assert.Empty(t, diags)
assert.Equal(t, originalSyncRoot, b.SyncRoot)
}
11 changes: 10 additions & 1 deletion libs/dbr/context.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package dbr

import "context"
import (
"context"
"strings"
)

// key is a package-local type to use for context keys.
//
Expand Down Expand Up @@ -61,3 +64,9 @@ func RuntimeVersion(ctx context.Context) string {

return v.(Environment).Version
}

// RunsOnServerless returns true if running on serverless compute.
// Serverless runtime versions are prefixed with "client.".
func RunsOnServerless(ctx context.Context) bool {
return strings.HasPrefix(RuntimeVersion(ctx), "client.")
}
7 changes: 7 additions & 0 deletions libs/dbr/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@ func TestContext_RuntimeVersionWithMock(t *testing.T) {
assert.Equal(t, "15.4", RuntimeVersion(MockRuntime(ctx, Environment{IsDbr: true, Version: "15.4"})))
assert.Empty(t, RuntimeVersion(MockRuntime(ctx, Environment{})))
}

func TestContext_RunsOnServerless(t *testing.T) {
ctx := context.Background()
assert.True(t, RunsOnServerless(MockRuntime(ctx, Environment{IsDbr: true, Version: "client.1.13"})))
assert.False(t, RunsOnServerless(MockRuntime(ctx, Environment{IsDbr: true, Version: "15.4"})))
assert.False(t, RunsOnServerless(MockRuntime(ctx, Environment{})))
}