mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-16 18:01:34 +00:00
refactor: docker engine with options
This commit is contained in:
parent
4eb5213294
commit
14a345504f
3 changed files with 45 additions and 18 deletions
30
engine/options.go
Normal file
30
engine/options.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package engine
|
||||
|
||||
import "github.com/docker/docker/client"
|
||||
|
||||
// An Option configures a mutex.
|
||||
type Option interface {
|
||||
Apply(*Docker)
|
||||
}
|
||||
|
||||
// OptionFunc is a function that configure a value.
|
||||
type OptionFunc func(*Docker)
|
||||
|
||||
// Apply calls f(option)
|
||||
func (f OptionFunc) Apply(docker *Docker) {
|
||||
f(docker)
|
||||
}
|
||||
|
||||
// WithClient set custom client
|
||||
func WithClient(c client.APIClient) Option {
|
||||
return OptionFunc(func(q *Docker) {
|
||||
q.client = c
|
||||
})
|
||||
}
|
||||
|
||||
// WithHidePull set custom client
|
||||
func WithHidePull(v bool) Option {
|
||||
return OptionFunc(func(q *Docker) {
|
||||
q.hidePull = v
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue