github.com/oam-dev/cluster-gateway@v1.9.0/pkg/util/context/context.go (about) 1 package context 2 3 import "context" 4 5 type contextKeyClusterName string 6 7 var ( 8 key contextKeyClusterName = "" 9 ) 10 11 func WithClusterName(ctx context.Context, clusterName string) context.Context { 12 return context.WithValue(ctx, key, clusterName) 13 } 14 15 func GetClusterName(ctx context.Context) string { 16 return ctx.Value(key).(string) 17 }