2020-04-29 22:12:58 +02:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-04-29 23:10:06 +02:00
|
|
|
"github.com/docker/api/client"
|
2020-04-29 22:12:58 +02:00
|
|
|
)
|
|
|
|
|
2020-04-29 23:39:54 +02:00
|
|
|
type clientKey struct{}
|
|
|
|
|
2020-05-04 23:00:21 +02:00
|
|
|
// WithClient adds the client to the context
|
2020-04-29 23:39:54 +02:00
|
|
|
func WithClient(ctx context.Context, c *client.Client) (context.Context, error) {
|
|
|
|
return context.WithValue(ctx, clientKey{}, c), nil
|
|
|
|
}
|
|
|
|
|
2020-05-04 23:00:21 +02:00
|
|
|
// Client returns the client from the context
|
2020-04-29 23:39:54 +02:00
|
|
|
func Client(ctx context.Context) *client.Client {
|
|
|
|
c, _ := ctx.Value(clientKey{}).(*client.Client)
|
|
|
|
return c
|
2020-04-29 22:12:58 +02:00
|
|
|
}
|