mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
ed6fd3d95b
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
22 lines
386 B
Go
22 lines
386 B
Go
package session
|
|
|
|
import "context"
|
|
|
|
type contextKeyT string
|
|
|
|
var contextKey = contextKeyT("buildkit/session-id")
|
|
|
|
func NewContext(ctx context.Context, id string) context.Context {
|
|
if id != "" {
|
|
return context.WithValue(ctx, contextKey, id)
|
|
}
|
|
return ctx
|
|
}
|
|
|
|
func FromContext(ctx context.Context) string {
|
|
v := ctx.Value(contextKey)
|
|
if v == nil {
|
|
return ""
|
|
}
|
|
return v.(string)
|
|
}
|