Skip to content

Commit 4288e19

Browse files
committed
Revert "remove Run convenience method from jail interface"
This reverts commit a4951b1.
1 parent a4951b1 commit 4288e19

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

cli/cli.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,8 @@ func Run(config Config, args []string) error {
9494
return fmt.Errorf("failed to create jail: %v", err)
9595
}
9696

97-
// Start the jail
98-
if err := j.Start(); err != nil {
99-
return fmt.Errorf("failed to start jail: %v", err)
100-
}
101-
defer j.Stop()
102-
103-
// Execute the command in the jail
104-
return j.Execute(args, nil)
97+
// Run the command in the jail
98+
return j.Run(args, nil)
10599
}
106100

107101
// setupLogging configures and returns a logger based on the log level

jail

-9.61 MB
Binary file not shown.

jail.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,17 @@ func (j *Jail) Execute(command []string, additionalEnv map[string]string) error
250250
return nil
251251
}
252252

253+
// Run is a convenience method that combines Start() and Execute().
254+
// It starts the jail, executes the command, and automatically cleans up.
255+
func (j *Jail) Run(command []string, additionalEnv map[string]string) error {
256+
if err := j.Start(); err != nil {
257+
return err
258+
}
259+
defer j.Stop()
260+
261+
return j.Execute(command, additionalEnv)
262+
}
263+
253264
// Stop gracefully shuts down the jail and cleans up resources.
254265
func (j *Jail) Stop() error {
255266
if j.cleanedUp {
@@ -281,4 +292,4 @@ func (j *Jail) Stop() error {
281292
j.cleanedUp = true
282293
j.logger.Debug("Jail stopped successfully")
283294
return nil
284-
}
295+
}

0 commit comments

Comments
 (0)