1// Copyright 2020 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 protoc-gen-go_gapic. DO NOT EDIT. 16 17// Package osconfig is an auto-generated package for the 18// Cloud OS Config API. 19// 20// OS management tools that can be used for patch management, patch 21// compliance, and configuration management on VM instances. 22// 23// NOTE: This package is in beta. It is not stable, and may be subject to changes. 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. 35package osconfig // import "cloud.google.com/go/osconfig/apiv1beta" 36 37import ( 38 "context" 39 "runtime" 40 "strings" 41 "unicode" 42 43 "google.golang.org/api/option" 44 "google.golang.org/grpc/metadata" 45) 46 47// For more information on implementing a client constructor hook, see 48// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. 49type clientHookParams struct{} 50type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) 51 52const versionClient = "20200416" 53 54func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { 55 out, _ := metadata.FromOutgoingContext(ctx) 56 out = out.Copy() 57 for _, md := range mds { 58 for k, v := range md { 59 out[k] = append(out[k], v...) 60 } 61 } 62 return metadata.NewOutgoingContext(ctx, out) 63} 64 65// DefaultAuthScopes reports the default set of authentication scopes to use with this package. 66func DefaultAuthScopes() []string { 67 return []string{ 68 "https://www.googleapis.com/auth/cloud-platform", 69 } 70} 71 72// versionGo returns the Go runtime version. The returned string 73// has no whitespace, suitable for reporting in header. 74func versionGo() string { 75 const develPrefix = "devel +" 76 77 s := runtime.Version() 78 if strings.HasPrefix(s, develPrefix) { 79 s = s[len(develPrefix):] 80 if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { 81 s = s[:p] 82 } 83 return s 84 } 85 86 notSemverRune := func(r rune) bool { 87 return !strings.ContainsRune("0123456789.", r) 88 } 89 90 if strings.HasPrefix(s, "go1") { 91 s = s[2:] 92 var prerelease string 93 if p := strings.IndexFunc(s, notSemverRune); p >= 0 { 94 s, prerelease = s[:p], s[p:] 95 } 96 if strings.HasSuffix(s, ".") { 97 s += "0" 98 } else if strings.Count(s, ".") < 2 { 99 s += ".0" 100 } 101 if prerelease != "" { 102 s += "-" + prerelease 103 } 104 return s 105 } 106 return "UNKNOWN" 107} 108