Package: defaults

import "../ibm-cos-sdk-go/aws/defaults"

Overview

Package defaults is a collection of helpers to retrieve the SDK's default configuration and handlers.

Generally this package shouldn't be used directly, but session.Session instead. This package is useful when you need to reset the defaults of a session or service client to the SDK defaults before setting additional parameters.

Type Summary collapse

Function Summary collapse

Type Details

Defaults struct

A Defaults provides a collection of default values for SDK clients.

Structure Fields:

Config *aws.Config
Handlers request.Handlers

Function Details

func Config() *aws.Config

Config returns the default configuration without credentials. To retrieve a config with credentials also included use defaults.Get().Config instead.

Generally you shouldn't need to use this method directly, but is available if you need to reset the configuration of an existing service client or session.



52
53
54
55
56
57
58
59
60
61
// File 'aws/defaults/defaults.go', line 52

func Config() *aws.Config { return aws.NewConfig(). WithCredentials(credentials.AnonymousCredentials). WithRegion(os.Getenv("AWS_REGION")). WithHTTPClient(http.DefaultClient). WithMaxRetries(aws.UseServiceDefaultRetries). WithLogger(aws.NewDefaultLogger()). WithLogLevel(aws.LogOff). WithEndpointResolver(endpoints.DefaultResolver()) }

func CredChain(cfg *aws.Config, handlers request.Handlers) *credentials.Credentials

CredChain returns the default credential chain.

Generally you shouldn't need to use this method directly, but is available if you need to reset the credentials of an existing service client or session's Config.



90
91
92
93
94
95
// File 'aws/defaults/defaults.go', line 90

func CredChain(cfg *aws.Config, handlers request.Handlers) *credentials.Credentials { return credentials.NewCredentials(&credentials.ChainProvider{ VerboseErrors: aws.BoolValue(cfg.CredentialsChainVerboseErrors), Providers: CredProviders(cfg, handlers), }) }

func CredProviders(cfg *aws.Config, handlers request.Handlers) []credentials.Provider

CredProviders returns the slice of providers used in the default credential chain.

For applications that need to use some other provider (for example use different environment variables for legacy reasons) but still fall back on the default chain of providers. This allows that default chain to be automatically updated IBM COS SDK Code – START



105
106
107
108
109
110
111
112
113
// File 'aws/defaults/defaults.go', line 105

func CredProviders(cfg *aws.Config, handlers request.Handlers) []credentials.Provider { return []credentials.Provider{ ibmiam.NewEnvProvider(cfg), ibmiam.NewSharedCredentialsProvider(cfg, "", ""), ibmiam.NewSharedConfigProvider(cfg, "", ""), &credentials.EnvProvider{}, &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, } }

func Get() Defaults

Get returns the SDK's default values with Config and handlers pre-configured.



34
35
36
37
38
39
40
41
42
43
// File 'aws/defaults/defaults.go', line 34

func Get() Defaults { cfg := Config() handlers := Handlers() cfg.Credentials = CredChain(cfg, handlers) return Defaults{ Config: cfg, Handlers: handlers, } }

func Handlers() request.Handlers

Handlers returns the default request handlers.

Generally you shouldn't need to use this method directly, but is available if you need to reset the request handlers of an existing service client or session.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// File 'aws/defaults/defaults.go', line 68

func Handlers() request.Handlers { var handlers request.Handlers handlers.Validate.PushBackNamed(corehandlers.ValidateEndpointHandler) handlers.Validate.AfterEachFn = request.HandlerListStopOnError handlers.Build.PushBackNamed(corehandlers.SDKVersionUserAgentHandler) handlers.Build.PushBackNamed(corehandlers.AddHostExecEnvUserAgentHander) handlers.Build.AfterEachFn = request.HandlerListStopOnError handlers.Sign.PushBackNamed(corehandlers.BuildContentLengthHandler) handlers.Send.PushBackNamed(corehandlers.ValidateReqSigHandler) handlers.Send.PushBackNamed(corehandlers.SendHandler) handlers.AfterRetry.PushBackNamed(corehandlers.AfterRetryHandler) handlers.ValidateResponse.PushBackNamed(corehandlers.ValidateResponseHandler) return handlers }

func SharedConfigFilename() string

SharedConfigFilename returns the SDK's default file path for the shared config file.

Builds the shared config file path based on the OS's platform.

  • Linux/Unix: $HOME/.aws/config

  • Windows: %USERPROFILE%.awsconfig



24
25
26
// File 'aws/defaults/shared_config.go', line 24

func SharedConfigFilename() string { return shareddefaults.SharedConfigFilename() }

func SharedCredentialsFilename() string

SharedCredentialsFilename returns the SDK's default file path for the shared credentials file.

Builds the shared config file path based on the OS's platform.

  • Linux/Unix: $HOME/.aws/credentials

  • Windows: %USERPROFILE%.awscredentials



13
14
15
// File 'aws/defaults/shared_config.go', line 13

func SharedCredentialsFilename() string { return shareddefaults.SharedCredentialsFilename() }