Skip to content

Commit

Permalink
Install buildpack at init time
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Rockwood <[email protected]>
  • Loading branch information
rockwotj committed Jun 26, 2023
1 parent 2627fe2 commit 38824a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/go/rpk/pkg/cli/transform/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func installBuildpack(ctx context.Context, p buildpack.Buildpack, fs afero.Fs) (
if ok {
return p.BinPath()
}
fmt.Printf("latest %s build plugin not found, downloading now...\n", p.Name)
fmt.Printf("latest %s buildpack not found, downloading now...\n", p.Name)
err = p.Download(ctx, fs)
if err != nil {
return "", err
}
fmt.Printf("latest %s build plugin download complete\n", p.Name)
fmt.Printf("latest %s buildpack download complete\n", p.Name)
return p.BinPath()
}
8 changes: 6 additions & 2 deletions src/go/rpk/pkg/cli/transform/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"path/filepath"
"strings"

"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/transform/buildpack"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/transform/project"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/cli/transform/template"
"github.com/redpanda-data/redpanda/src/go/rpk/pkg/config"
Expand Down Expand Up @@ -111,7 +112,7 @@ Will initialize a transform project in the foobar directory.
out.MaybeDie(err, "unable to generate all manifest files: %v", err)
ok, err = out.Confirm("install dependencies?")
if ok && err == nil {
installDeps(cmd.Context(), p)
installDeps(cmd.Context(), fs, p)
}
fmt.Println("deploy your transform using:")
if cwd != path {
Expand Down Expand Up @@ -183,10 +184,12 @@ func executeGenerate(fs afero.Fs, p transformProject) error {
return nil
}

func installDeps(ctx context.Context, p transformProject) error {
func installDeps(ctx context.Context, fs afero.Fs, p transformProject) error {
switch p.Lang {
case project.WasmLangTinygo:
{
_, err := installBuildpack(ctx, buildpack.Tinygo, fs)
out.MaybeDie(err, "unable to install tinygo buildpack: %v", err)
g, err := exec.LookPath("go")
out.MaybeDie(err, "go is not available on $PATH, please download and install it: https://go.dev/doc/install")
c := exec.CommandContext(ctx, g, "mod", "tidy")
Expand All @@ -196,6 +199,7 @@ func installDeps(ctx context.Context, p transformProject) error {
c.Dir = p.Path
out.MaybeDieErr(c.Run())
fmt.Println("go modules are tidy 🧹")

}
}
return fmt.Errorf("Unknown language %q", p.Lang)
Expand Down

0 comments on commit 38824a6

Please sign in to comment.