2023-02-28 10:44:46 +00:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-08-13 07:30:05 +01:00
|
|
|
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
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-08-13 15:41:01 +01:00
|
|
|
// WithHidePull hide pull event.
|
2022-08-13 07:30:05 +01:00
|
|
|
func WithHidePull(v bool) Option {
|
|
|
|
return OptionFunc(func(q *Docker) {
|
|
|
|
q.hidePull = v
|
|
|
|
})
|
|
|
|
}
|