diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-07-03 06:11:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-03 06:11:03 -0400 |
commit | 07716133c44c9c9593364029f4b98085d1be3bdd (patch) | |
tree | ca1b03c22f1c40c793fe6fe30c99aee8cd3d7558 /vendor/google.golang.org/grpc/metadata | |
parent | 878a2231f9eae037d15bc27c50cdf3a9418793c7 (diff) | |
parent | 84da70a0f36e7d6fc87919ca4a69b20bc9d43f72 (diff) | |
download | podman-07716133c44c9c9593364029f4b98085d1be3bdd.tar.gz podman-07716133c44c9c9593364029f4b98085d1be3bdd.tar.bz2 podman-07716133c44c9c9593364029f4b98085d1be3bdd.zip |
Merge pull request #10852 from Luap99/cobra
bump cobra to v1.2.1 and update the shell completion scripts
Diffstat (limited to 'vendor/google.golang.org/grpc/metadata')
-rw-r--r-- | vendor/google.golang.org/grpc/metadata/metadata.go | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/vendor/google.golang.org/grpc/metadata/metadata.go b/vendor/google.golang.org/grpc/metadata/metadata.go index cf6d1b947..e4cbea917 100644 --- a/vendor/google.golang.org/grpc/metadata/metadata.go +++ b/vendor/google.golang.org/grpc/metadata/metadata.go @@ -75,13 +75,9 @@ func Pairs(kv ...string) MD { panic(fmt.Sprintf("metadata: Pairs got the odd number of input pairs for metadata: %d", len(kv))) } md := MD{} - var key string - for i, s := range kv { - if i%2 == 0 { - key = strings.ToLower(s) - continue - } - md[key] = append(md[key], s) + for i := 0; i < len(kv); i += 2 { + key := strings.ToLower(kv[i]) + md[key] = append(md[key], kv[i+1]) } return md } @@ -195,12 +191,18 @@ func FromOutgoingContext(ctx context.Context) (MD, bool) { return nil, false } - mds := make([]MD, 0, len(raw.added)+1) - mds = append(mds, raw.md) - for _, vv := range raw.added { - mds = append(mds, Pairs(vv...)) + out := raw.md.Copy() + for _, added := range raw.added { + if len(added)%2 == 1 { + panic(fmt.Sprintf("metadata: FromOutgoingContext got an odd number of input pairs for metadata: %d", len(added))) + } + + for i := 0; i < len(added); i += 2 { + key := strings.ToLower(added[i]) + out[key] = append(out[key], added[i+1]) + } } - return Join(mds...), ok + return out, ok } type rawMD struct { |