mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-19 15:06:34 +00:00
25 lines
530 B
Go
25 lines
530 B
Go
|
package docker
|
||
|
|
||
|
import (
|
||
|
"github.com/drone/drone/engine/runner"
|
||
|
"golang.org/x/net/context"
|
||
|
)
|
||
|
|
||
|
const key = "docker"
|
||
|
|
||
|
// Setter defines a context that enables setting values.
|
||
|
type Setter interface {
|
||
|
Set(string, interface{})
|
||
|
}
|
||
|
|
||
|
// FromContext returns the Engine associated with this context.
|
||
|
func FromContext(c context.Context) runner.Engine {
|
||
|
return c.Value(key).(runner.Engine)
|
||
|
}
|
||
|
|
||
|
// ToContext adds the Engine to this context if it supports the
|
||
|
// Setter interface.
|
||
|
func ToContext(c Setter, d runner.Engine) {
|
||
|
c.Set(key, d)
|
||
|
}
|