internaloption
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package internaloption contains options used internally by Google client code.
Index¶
- func AllowHardBoundTokens(protocol ...string) option.ClientOption
- func AllowNonDefaultServiceAccount(nd bool) option.ClientOption
- func AuthCreds(ctx context.Context, opts []option.ClientOption) (*auth.Credentials, error)
- func EnableAsyncRefreshDryRun(errHandler func()) option.ClientOption
- func EnableDirectPath(dp bool) option.ClientOption
- func EnableDirectPathXds() option.ClientOption
- func EnableJwtWithScope() option.ClientOption
- func EnableNewAuthLibrary() option.ClientOption
- func GetLogger(opts []option.ClientOption) *slog.Logger
- func SkipDialSettingsValidation() option.ClientOption
- func WithCredentials(creds *google.Credentials) option.ClientOption
- func WithDefaultAudience(audience string) option.ClientOption
- func WithDefaultEndpoint(url string) option.ClientOptiondeprecated
- func WithDefaultEndpointTemplate(url string) option.ClientOption
- func WithDefaultMTLSEndpoint(url string) option.ClientOption
- func WithDefaultScopes(scope ...string) option.ClientOption
- func WithDefaultUniverseDomain(ud string) option.ClientOption
- type EmbeddableAdapter
Examples¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcAllowHardBoundTokens¶added inv0.221.0
func AllowHardBoundTokens(protocol ...string)option.ClientOption
AllowHardBoundTokens returns a ClientOption that allows libraries to request a hard-bound token.Obtaining hard-bound tokens requires the connection to be established using either ApplicationLayer Transport Security (ALTS) or mutual TLS (mTLS) with S2A. For more information on ALTS,see:https://cloud.google.com/docs/security/encryption-in-transit/application-layer-transport-security
The AllowHardBoundTokens option accepts the following values (or a combination thereof):
- "MTLS_S2A": Allows obtaining hard-bound tokens when the connection uses mutual TLS with S2A.
- "ALTS": Allows obtaining hard-bound tokens when the connection uses ALTS.
For example, to allow obtaining hard-bound tokens with either MTLS_S2A or ALTS, you wouldprovide both values (e.g., {"MTLS_S2A","ALTS"}). If no value is provided, hard-bound tokenswill not be requested.
It should only be used internally by generated clients.This is an EXPERIMENTAL API and may be changed or removed in the future.
funcAllowNonDefaultServiceAccount¶added inv0.55.0
func AllowNonDefaultServiceAccount(ndbool)option.ClientOption
AllowNonDefaultServiceAccount returns a ClientOption that overrides the defaultrequirement for using the default service account for DirectPath.
It should only be used internally by generated clients.This is an EXPERIMENTAL API and may be changed or removed in the future.
funcAuthCreds¶added inv0.210.0
func AuthCreds(ctxcontext.Context, opts []option.ClientOption) (*auth.Credentials,error)
AuthCreds returnscloud.google.com/go/auth.Credentials using the followingoptions provided viaoption.ClientOption, including legacy oauth2/googleoptions, in this order:
- option.WithoutAuthentication
- option.WithAuthCredentials
- WithCredentials (internal use only)
- option.WithCredentials
- option.WithTokenSource
If there are no applicable credentials options, then it passes thefollowing options tocloud.google.com/go/auth/credentials.DetectDefault andreturns the result:
- option.WithAudiences
- option.WithCredentialsFile
- option.WithCredentialsJSON
- option.WithScopes
- WithDefaultScopes (internal use only)
- EnableJwtWithScope (internal use only)
This function should only be used internally by generated clients. This is anEXPERIMENTAL API and may be changed or removed in the future.
funcEnableAsyncRefreshDryRun¶added inv0.210.0
func EnableAsyncRefreshDryRun(errHandler func())option.ClientOption
EnableAsyncRefreshDryRun returns a ClientOption that specifies if libraries in thismodule should asynchronously refresh auth token in parallel to sync refresh.
This option can be used to determine whether refreshing the token asymnchronouslyprior to its actual expiry works without any issues in a particular environment.
errHandler function will be called when there is an error while refreshingthe token asynchronously.
This is an EXPERIMENTAL option and will be removed in the future.TODO(b/372244283): Remove after b/358175516 has been fixed
funcEnableDirectPath¶added inv0.35.0
func EnableDirectPath(dpbool)option.ClientOption
EnableDirectPath returns a ClientOption that overrides the defaultattempt to use DirectPath.
It should only be used internally by generated clients.This is an EXPERIMENTAL API and may be changed or removed in the future.
funcEnableDirectPathXds¶added inv0.119.0
func EnableDirectPathXds()option.ClientOption
EnableDirectPathXds returns a ClientOption that overrides the defaultDirectPath type. It is only valid when DirectPath is enabled.
It should only be used internally by generated clients.This is an EXPERIMENTAL API and may be changed or removed in the future.
funcEnableJwtWithScope¶added inv0.49.0
func EnableJwtWithScope()option.ClientOption
EnableJwtWithScope returns a ClientOption that specifies if scope can be usedwith self-signed JWT.
EnableJwtWithScope is ignored when option.WithUniverseDomain is setto a value other than the Google Default Universe (GDU) of "googleapis.com".For non-GDU domains, token exchange is impossible and services mustsupport self-signed JWTs with scopes.
funcEnableNewAuthLibrary¶added inv0.142.0
func EnableNewAuthLibrary()option.ClientOption
EnableNewAuthLibrary returns a ClientOption that specifies if libraries in thismodule to delegate auth to our new library. This option will be removed inthe future once all clients have been moved to the new auth layer.
funcGetLogger¶added inv0.206.0
func GetLogger(opts []option.ClientOption) *slog.Logger
GetLogger is a helper for client libraries to extract theslog.Logger fromthe provided options or return a default logger if one is not found.
It should only be used internally by generated clients. This is an EXPERIMENTAL APIand may be changed or removed in the future.
funcSkipDialSettingsValidation¶added inv0.30.0
func SkipDialSettingsValidation()option.ClientOption
SkipDialSettingsValidation bypasses validation on ClientOptions.
It should only be used internally.
funcWithCredentials¶added inv0.56.0
func WithCredentials(creds *google.Credentials)option.ClientOption
WithCredentials returns a client option to specify credentials which will be used to authenticate API calls.This credential takes precedence over all other credential options.
funcWithDefaultAudience¶added inv0.36.0
func WithDefaultAudience(audiencestring)option.ClientOption
WithDefaultAudience returns a ClientOption that specifies a default audienceto be used as the audience field ("aud") for the JWT token authentication.
It should only be used internally by generated clients.
funcWithDefaultEndpointdeprecated
func WithDefaultEndpoint(urlstring)option.ClientOption
WithDefaultEndpoint is an option that indicates the default endpoint.
It should only be used internally by generated clients.
This is similar to WithEndpoint, but allows us to determine whether the user has overridden the default endpoint.
Deprecated: WithDefaultEndpoint does not support setting the universe domain.Use WithDefaultEndpointTemplate and WithDefaultUniverseDomain to compose thedefault endpoint instead.
funcWithDefaultEndpointTemplate¶added inv0.155.0
func WithDefaultEndpointTemplate(urlstring)option.ClientOption
WithDefaultEndpointTemplate provides a template for creating the endpointusing a universe domain. See also WithDefaultUniverseDomain andoption.WithUniverseDomain. The placeholder UNIVERSE_DOMAIN should be usedinstead of a concrete universe domain such as "googleapis.com".
Example: WithDefaultEndpointTemplate("https://logging.UNIVERSE_DOMAIN/")
It should only be used internally by generated clients.
funcWithDefaultMTLSEndpoint¶added inv0.29.0
func WithDefaultMTLSEndpoint(urlstring)option.ClientOption
WithDefaultMTLSEndpoint is an option that indicates the default mTLS endpoint.
It should only be used internally by generated clients.
funcWithDefaultScopes¶added inv0.36.0
func WithDefaultScopes(scope ...string)option.ClientOption
WithDefaultScopes returns a ClientOption that overrides the default OAuth2scopes to be used for a service.
It should only be used internally by generated clients.
funcWithDefaultUniverseDomain¶added inv0.153.0
func WithDefaultUniverseDomain(udstring)option.ClientOption
WithDefaultUniverseDomain returns a ClientOption that sets the default universe domain.
It should only be used internally by generated clients.
This is similar to the public WithUniverse, but allows us to determine whether the user hasoverridden the default universe.
Types¶
typeEmbeddableAdapter¶added inv0.106.0
type EmbeddableAdapter struct{}EmbeddableAdapter is a no-op option.ClientOption that allow libraries tocreate their own client options by embedding this type into their ownclient-specific option wrapper. See example for usage.
Example¶
package mainimport ("context""fmt""google.golang.org/api/option""google.golang.org/api/option/internaloption")type config struct {i int}type clientSpecificOption interface {option.ClientOptionApplyOpt(*config)}func WithFavoriteNumber(i int) option.ClientOption {return &withFavoriteNumber{i: i}}type withFavoriteNumber struct {internaloption.EmbeddableAdapteri int}func (w *withFavoriteNumber) ApplyOpt(c *config) {c.i = w.i}type Foo struct {i int}func NewFoo(ctx context.Context, opts ...option.ClientOption) (*Foo, error) {var conf configfor _, opt := range opts {if fooOpt, ok := opt.(clientSpecificOption); ok {fooOpt.ApplyOpt(&conf)}}// Pass options to internals for dialing. All client-specific options will// be no-ops.return &Foo{i: conf.i}, nil}func (f *Foo) Number() int { return f.i }func main() {f, err := NewFoo(context.Background(), WithFavoriteNumber(42))if err != nil {// TODO: handle error}fmt.Println(f.Number())}Output:42
func (*EmbeddableAdapter)Apply¶added inv0.106.0
func (*EmbeddableAdapter) Apply(_ *internal.DialSettings)