1
0

context.go 495 B

1234567891011121314151617181920
  1. package context
  2. import (
  3. gocontext "context"
  4. "golang.org/x/net/context"
  5. )
  6. type currentContextKey struct{}
  7. // WithCurrentContext sets the name of the current docker context
  8. func WithCurrentContext(ctx gocontext.Context, contextName string) context.Context {
  9. return context.WithValue(ctx, currentContextKey{}, contextName)
  10. }
  11. // CurrentContext returns the current context name
  12. func CurrentContext(ctx context.Context) string {
  13. cc, _ := ctx.Value(currentContextKey{}).(string)
  14. return cc
  15. }