mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-10-31 16:13:45 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			386 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			23 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)
 | |
| }
 | 
