Welcome to mirror list, hosted at ThFree Co, Russian Federation.

test_utils.go « featureflag « metadata « internal - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2443c58268edc06831070fc4d6135fdc462128ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package featureflag

import (
	"context"

	"google.golang.org/grpc/metadata"
)

// EnableFeatureFlag is used in tests to enablea a feature flag in the context metadata
func EnableFeatureFlag(ctx context.Context, flag string) context.Context {

	md, ok := metadata.FromIncomingContext(ctx)
	if !ok {
		md = metadata.New(map[string]string{HeaderKey(flag): "true"})
	} else {
		md.Set(HeaderKey(flag), "true")
	}

	return metadata.NewOutgoingContext(context.Background(), md)
}