Skip to content

Commit

Permalink
Sandbox options
Browse files Browse the repository at this point in the history
  • Loading branch information
minhnhatnoe committed Jun 10, 2023
1 parent 1a18ef9 commit 7e7822f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
4 changes: 3 additions & 1 deletion worker/sandbox/raw/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ func (s *Runner) Settings() *sandbox.Settings {
func (s *Runner) Run(input *sandbox.Input) (*sandbox.Output, error) {
dir := os.TempDir()

log.Printf("[SANDBOX] Running %s %v\n", input.Command, input.Args)
if s.Settings().LogSandbox {
log.Printf("[SANDBOX] Running %s %v\n", input.Command, input.Args)
}

return s.RunFrom(dir, input)
}
Expand Down
15 changes: 0 additions & 15 deletions worker/sandbox/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,6 @@ type Output struct {
ErrorMessage string `json:"error_message,omitempty"`
}

type Settings struct {
IgnoreWarning bool
}

var DefaultSettings = Settings{IgnoreWarning: false}

type Option func(Settings) Settings

func IgnoreWarnings(ignore bool) Option {
return func(o Settings) Settings {
o.IgnoreWarning = ignore
return o
}
}

// CopyTo copies all the files it contains into cwd.
func (input *Input) CopyTo(cwd string) error {
// Copy all the files into "cwd"
Expand Down
24 changes: 24 additions & 0 deletions worker/sandbox/settings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package sandbox

type Settings struct {
LogSandbox bool
IgnoreWarning bool
}

var DefaultSettings = Settings{LogSandbox: true, IgnoreWarning: false}

type Option func(Settings) Settings

func IgnoreWarnings(ignore bool) Option {
return func(o Settings) Settings {
o.IgnoreWarning = ignore
return o
}
}

func EnableSandboxLogs(enable bool) Option {
return func(o Settings) Settings {
o.LogSandbox = enable
return o
}
}

0 comments on commit 7e7822f

Please sign in to comment.