Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ibmcloud be to use local setup rather than k8 kind cluster
Browse files Browse the repository at this point in the history
Signed-off-by: aavarghese <avarghese@us.ibm.com>
aavarghese committed Dec 3, 2024
1 parent 4ee6eab commit de2e363
Showing 31 changed files with 498 additions and 151 deletions.
1 change: 1 addition & 0 deletions cmd/subcommands/component.go
Original file line number Diff line number Diff line change
@@ -17,4 +17,5 @@ func init() {
cmd.AddCommand(component.Minio())
cmd.AddCommand(component.Worker())
cmd.AddCommand(component.WorkStealer())
cmd.AddCommand(component.RunLocally())
}
42 changes: 42 additions & 0 deletions cmd/subcommands/component/run-locally.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package component

import (
"context"

"github.com/spf13/cobra"
"lunchpail.io/cmd/options"
"lunchpail.io/pkg/build"
"lunchpail.io/pkg/runtime"
)

type RunLocallyOptions struct {
Component string
LLIR string
build.LogOptions
}

func AddRunLocallyOptions(cmd *cobra.Command) *RunLocallyOptions {
options := RunLocallyOptions{}
cmd.Flags().StringVarP(&options.Component, "component", "", "", "")
cmd.Flags().StringVar(&options.LLIR, "llir", "", "")
cmd.MarkFlagRequired("component")
cmd.MarkFlagRequired("llir")
return &options
}

func RunLocally() *cobra.Command {
cmd := &cobra.Command{
Use: "run-locally",
Short: "Commands for running a component locally",
Long: "Commands for running a component locally",
}

runOpts := AddRunLocallyOptions(cmd)
options.AddLogOptions(cmd)

cmd.RunE = func(cmd *cobra.Command, args []string) error {
return runtime.RunLocally(context.Background(), runOpts.Component, runOpts.LLIR, runOpts.LogOptions)
}

return cmd
}
2 changes: 1 addition & 1 deletion cmd/subcommands/queue/drain.go
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ func Drain() *cobra.Command {
return err
}

return queue.Drain(ctx, backend, run.ForStep(step), *opts.Log)
return queue.Drain(ctx, backend, run.ForStep(step), opts.Queue, *opts.Log)
}

return cmd
2 changes: 1 addition & 1 deletion cmd/subcommands/queue/ls.go
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ func Ls() *cobra.Command {
return err
}

files, errors, err := queue.Ls(ctx, backend, runContext.ForStep(step), path, *opts.Log)
files, errors, err := queue.Ls(ctx, backend, runContext.ForStep(step), path, opts.Queue, *opts.Log)
if err != nil {
return err
}
2 changes: 1 addition & 1 deletion cmd/subcommands/queue/upload.go
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ func Upload() *cobra.Command {
run = rrun.Name
}

return queue.UploadFiles(ctx, backend, q.RunContext{RunName: run}, []upload.Upload{upload.Upload{LocalPath: args[0], Bucket: args[1]}}, *opts.Log)
return queue.UploadFiles(ctx, backend, q.RunContext{RunName: run}, []upload.Upload{upload.Upload{LocalPath: args[0], Bucket: args[1]}}, opts.Queue, *opts.Log)
}

return cmd
5 changes: 4 additions & 1 deletion pkg/be/backend.go
Original file line number Diff line number Diff line change
@@ -34,8 +34,11 @@ type Backend interface {
InstanceCount(ctx context.Context, c lunchpail.Component, run queue.RunContext) (int, error)

// Queue properties for a given run, plus ensure access to the endpoint from this client
AccessQueue(ctx context.Context, run queue.RunContext, opts build.LogOptions) (endpoint, accessKeyID, secretAccessKey, bucket string, stop func(), err error)
AccessQueue(ctx context.Context, run queue.RunContext, rclone string, opts build.LogOptions) (endpoint, accessKeyID, secretAccessKey, bucket string, stop func(), err error)

// Return a streamer
Streamer(ctx context.Context, run queue.RunContext) streamer.Streamer

// Build any images(s) needed for Up
CreateImage(ctx context.Context, linked llir.LLIR, opts llir.Options, destroy bool) (string, error)
}
Loading

0 comments on commit de2e363

Please sign in to comment.