1// Copyright 2019 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// Code generated by gapic-generator. DO NOT EDIT.
16
17// Package debugger is an auto-generated package for the
18// Stackdriver Debugger API.
19//
20//   NOTE: This package is in alpha. It is not stable, and is likely to change.
21//
22// Examines the call stack and variables of a running application without
23// stopping or slowing it down.
24//
25// Use of Context
26//
27// The ctx passed to NewClient is used for authentication requests and
28// for creating the underlying connection, but is not used for subsequent calls.
29// Individual methods on the client use the ctx given to them.
30//
31// To close the open connection, use the Close() method.
32//
33// For information about setting deadlines, reusing contexts, and more
34// please visit godoc.org/cloud.google.com/go.
35//
36// Use the client at cloud.google.com/go/cmd/go-cloud-debug-agent in preference to this.
37package debugger // import "cloud.google.com/go/debugger/apiv2"
38
39import (
40	"context"
41	"runtime"
42	"strings"
43	"unicode"
44
45	"google.golang.org/grpc/metadata"
46)
47
48func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
49	out, _ := metadata.FromOutgoingContext(ctx)
50	out = out.Copy()
51	for _, md := range mds {
52		for k, v := range md {
53			out[k] = append(out[k], v...)
54		}
55	}
56	return metadata.NewOutgoingContext(ctx, out)
57}
58
59// DefaultAuthScopes reports the default set of authentication scopes to use with this package.
60func DefaultAuthScopes() []string {
61	return []string{
62		"https://www.googleapis.com/auth/cloud-platform",
63		"https://www.googleapis.com/auth/cloud_debugger",
64	}
65}
66
67// versionGo returns the Go runtime version. The returned string
68// has no whitespace, suitable for reporting in header.
69func versionGo() string {
70	const develPrefix = "devel +"
71
72	s := runtime.Version()
73	if strings.HasPrefix(s, develPrefix) {
74		s = s[len(develPrefix):]
75		if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 {
76			s = s[:p]
77		}
78		return s
79	}
80
81	notSemverRune := func(r rune) bool {
82		return strings.IndexRune("0123456789.", r) < 0
83	}
84
85	if strings.HasPrefix(s, "go1") {
86		s = s[2:]
87		var prerelease string
88		if p := strings.IndexFunc(s, notSemverRune); p >= 0 {
89			s, prerelease = s[:p], s[p:]
90		}
91		if strings.HasSuffix(s, ".") {
92			s += "0"
93		} else if strings.Count(s, ".") < 2 {
94			s += ".0"
95		}
96		if prerelease != "" {
97			s += "-" + prerelease
98		}
99		return s
100	}
101	return "UNKNOWN"
102}
103
104const versionClient = "20190528"
105