mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
29
vendor/github.com/moby/buildkit/client/buildid/metadata.go
generated
vendored
Normal file
29
vendor/github.com/moby/buildkit/client/buildid/metadata.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
package buildid
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
var metadataKey = "buildkit-controlapi-buildid"
|
||||
|
||||
func AppendToOutgoingContext(ctx context.Context, id string) context.Context {
|
||||
if id != "" {
|
||||
return metadata.AppendToOutgoingContext(ctx, metadataKey, id)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func FromIncomingContext(ctx context.Context) string {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
|
||||
if ids := md.Get(metadataKey); len(ids) == 1 {
|
||||
return ids[0]
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
Reference in New Issue
Block a user