Skip to content

Commit

Permalink
feat: use lunchpail needs to install minio
Browse files Browse the repository at this point in the history
Signed-off-by: aavarghese <avarghese@us.ibm.com>
  • Loading branch information
aavarghese committed Oct 12, 2024
1 parent 3ffac8e commit a1a866f
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 97 deletions.
22 changes: 0 additions & 22 deletions pkg/be/local/shell/install_darwin.go

This file was deleted.

44 changes: 0 additions & 44 deletions pkg/be/local/shell/install_linux.go

This file was deleted.

27 changes: 0 additions & 27 deletions pkg/be/local/shell/workdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ package shell

import (
base64 "encoding/base64"
"errors"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"

"lunchpail.io/pkg/ir/hlir"
"lunchpail.io/pkg/ir/llir"
"lunchpail.io/pkg/lunchpail"
)

func PrepareWorkdirForComponent(c llir.ShellComponent, verbose bool) (string, string, error) {
Expand All @@ -32,37 +29,13 @@ func PrepareWorkdirForComponent(c llir.ShellComponent, verbose bool) (string, st

command := c.Application.Spec.Command

// hmm, hacky attempts to get intrinsic prereqs
switch c.C() {
case lunchpail.MinioComponent:
if err := ensureMinio(); err != nil {
return "", "", err
}
}

return workdir, command, nil
}

func saveCodeToWorkdir(workdir string, code hlir.Code) error {
return os.WriteFile(filepath.Join(workdir, code.Name), []byte(code.Source), 0700)
}

func ensureMinio() error {
if err := setenvForMinio(); err != nil {
return err
}

if _, err := exec.LookPath("minio"); err != nil {
if errors.Is(err, exec.ErrNotFound) {
return installMinio()
} else if err != nil {
return err
}
}

return nil
}

func writeBlobsToWorkdir(c llir.ShellComponent, workdir string, verbose bool) error {
for idx, dataset := range c.Application.Spec.Datasets {
if dataset.Blob.Content != "" {
Expand Down
3 changes: 1 addition & 2 deletions pkg/fe/transformer/api/minio/transpile.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ func transpile(runname string, ir llir.LLIR) (hlir.Application, error) {
app.Spec.Expose = []string{fmt.Sprintf("%d:%d", ir.Queue.Port, ir.Queue.Port)}
app.Spec.Command = fmt.Sprintf("$LUNCHPAIL_EXE component minio server --port %d", ir.Queue.Port)

/*app.Spec.Needs = []hlir.Needs{
{Name: "minio", Version: "latest"}}*/
app.Spec.Needs = []hlir.Needs{{Name: "minio", Version: "latest"}}
prefixIncludingBucket := api.QueuePrefixPath(ir.Queue, runname)
A := strings.Split(prefixIncludingBucket, "/")
prefixExcludingBucket := filepath.Join(A[1:]...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/runtime/needs/install_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func installMinio(ctx context.Context, version string, verbose bool) error {
}

//Todo: versions other than latest
cmd := exec.CommandContext(ctx, "/bin/sh", "-c", "apt update; apt -y install wget; wget https://dl.min.io/server/minio/release/linux-amd64/minio")
cmd := exec.CommandContext(ctx, "wget", "https://dl.min.io/server/minio/release/linux-amd64/minio")
cmd.Dir = dir
if verbose {
cmd.Stdout = os.Stdout
Expand Down
1 change: 0 additions & 1 deletion pkg/runtime/needs/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
func InstallMinio(ctx context.Context, version string, opts Options) error {
if _, err := exec.LookPath("minio"); err != nil {
if errors.Is(err, exec.ErrNotFound) {
//Todo: use context?
return installMinio(ctx, version, opts.Verbose)
}
return err
Expand Down

0 comments on commit a1a866f

Please sign in to comment.