Skip to content

Commit d216ca9

Browse files
committed
fix: add slug to bundler interface
1 parent acdf6f1 commit d216ca9

File tree

7 files changed

+7
-9
lines changed

7 files changed

+7
-9
lines changed

internal/functions/deploy/bundle.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ func NewDockerBundler(fsys afero.Fs) function.EszipBundler {
2525
return &dockerBundler{fsys: fsys}
2626
}
2727

28-
func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap string, staticFiles []string, output io.Writer) error {
28+
func (b *dockerBundler) Bundle(ctx context.Context, slug, entrypoint, importMap string, staticFiles []string, output io.Writer) error {
2929
// Create temp directory to store generated eszip
30-
slug := filepath.Base(filepath.Dir(entrypoint))
3130
fmt.Fprintln(os.Stderr, "Bundling Function:", utils.Bold(slug))
3231
cwd, err := os.Getwd()
3332
if err != nil {

internal/functions/deploy/bundle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestDockerBundle(t *testing.T) {
4343
apitest.MockDockerStart(utils.Docker, imageUrl, containerId)
4444
require.NoError(t, apitest.MockDockerLogsExitCode(utils.Docker, containerId, 1))
4545
// Run test
46-
err = NewDockerBundler(fsys).Bundle(context.Background(), "", "", []string{}, &body)
46+
err = NewDockerBundler(fsys).Bundle(context.Background(), "", "", "", []string{}, &body)
4747
// Check error
4848
assert.ErrorContains(t, err, "error running container: exit 1")
4949
assert.Empty(t, apitest.ListUnmatchedRequests())

pkg/function/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type EdgeRuntimeAPI struct {
1515
}
1616

1717
type EszipBundler interface {
18-
Bundle(ctx context.Context, entrypoint string, importMap string, staticFiles []string, output io.Writer) error
18+
Bundle(ctx context.Context, slug, entrypoint, importMap string, staticFiles []string, output io.Writer) error
1919
}
2020

2121
func NewEdgeRuntimeAPI(project string, client api.ClientWithResponses, opts ...withOption) EdgeRuntimeAPI {

pkg/function/batch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ OUTER:
4747
}
4848
}
4949
var body bytes.Buffer
50-
if err := s.eszip.Bundle(ctx, function.Entrypoint, function.ImportMap, function.StaticFiles, &body); err != nil {
50+
if err := s.eszip.Bundle(ctx, slug, function.Entrypoint, function.ImportMap, function.StaticFiles, &body); err != nil {
5151
return err
5252
}
5353
// Update if function already exists

pkg/function/batch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
type MockBundler struct {
1818
}
1919

20-
func (b *MockBundler) Bundle(ctx context.Context, entrypoint string, importMap string, staticFiles []string, output io.Writer) error {
20+
func (b *MockBundler) Bundle(ctx context.Context, slug, entrypoint, importMap string, staticFiles []string, output io.Writer) error {
2121
return nil
2222
}
2323

pkg/function/bundle.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ func NewNativeBundler(tempDir string, fsys fs.FS) EszipBundler {
2828
// Use a package private variable to allow testing without gosec complaining about G204
2929
var edgeRuntimeBin = "edge-runtime"
3030

31-
func (b *nativeBundler) Bundle(ctx context.Context, entrypoint string, importMap string, staticFiles []string, output io.Writer) error {
32-
slug := filepath.Base(filepath.Dir(entrypoint))
31+
func (b *nativeBundler) Bundle(ctx context.Context, slug, entrypoint, importMap string, staticFiles []string, output io.Writer) error {
3332
outputPath := filepath.Join(b.tempDir, slug+".eszip")
3433
// TODO: make edge runtime write to stdout
3534
args := []string{"bundle", "--entrypoint", entrypoint, "--output", outputPath}

pkg/function/bundle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestBundleFunction(t *testing.T) {
3636
// Setup mock bundler
3737
bundler := nativeBundler{fsys: fsys}
3838
// Run test
39-
err := bundler.Bundle(context.Background(), "hello/index.ts", "", nil, &body)
39+
err := bundler.Bundle(context.Background(), "hello", "hello/index.ts", "", nil, &body)
4040
// Check error
4141
assert.NoError(t, err)
4242
assert.Equal(t, compressedEszipMagicID+";", body.String())

0 commit comments

Comments
 (0)