-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the v2 SDK removing the `Session` and `ConfigProvider` types. In their place a new package `external` was created to provide external configuration loading. Such as Environment and Shared config. This change also flattens the SDK's `request`, `client`, `metadata`, and `credentials` packages into `aws. * Add external config loading, Remove Session, flatten packages. (#8) Updates the SDK adding an external package. This package is responsible for loading external configuration data such as environment and shared config files. In addition this would be the customers initial interface into the SDK loading the SDKs config. Removes session package from the SDK. This update removes the Session type and all of its loading logic. This is all replaced with the external package. The aws.Config type is updated to satisfy the ConfigProvider interface. Flattens the client, metadata, request, and credentials packages into aws. * Renames additional parameters of Credentials (#9) Renames Credentials: * Valid -> HasKeys * ProviderName -> Source * StaticProvider -> StaticCredentialsProvider * Add CA Bundle injection * Add EC2 Metadata region provider util * Add shared config loading tests. * Correct the load order of ec2 role creds config resolver (#12) Corrects the external config loading of credentials so that the EC2 role provider is set first as a fallback. Any other credentials set will override it. * Remove ConfigProvider switching to aws.Config (#13) Removing the ConfigProvider interface replacing all usage with `aws.Config`
- Loading branch information
Showing
692 changed files
with
54,073 additions
and
49,769 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package aws | ||
|
||
import ( | ||
"net/http" | ||
) | ||
|
||
// Metadata wraps immutable data from the Client structure. | ||
type Metadata struct { | ||
ServiceName string | ||
APIVersion string | ||
|
||
Endpoint string | ||
SigningName string | ||
SigningRegion string | ||
|
||
JSONVersion string | ||
TargetPrefix string | ||
} | ||
|
||
// A Client implements the base client request and response handling | ||
// used by all service clients. | ||
type Client struct { | ||
Metadata Metadata | ||
|
||
Config Config | ||
|
||
Region string | ||
CredentialsLoader *CredentialsLoader | ||
EndpointResolver EndpointResolver | ||
Handlers Handlers | ||
Retryer Retryer | ||
|
||
// TODO replace with value not pointer | ||
LogLevel *LogLevelType | ||
Logger Logger | ||
|
||
HTTPClient *http.Client | ||
} | ||
|
||
// NewClient will return a pointer to a new initialized service client. | ||
func NewClient(cfg Config, metadata Metadata) *Client { | ||
svc := &Client{ | ||
Metadata: metadata, | ||
|
||
// TODO remove config when request reqfactored | ||
Config: cfg, | ||
|
||
Region: StringValue(cfg.Region), | ||
CredentialsLoader: cfg.CredentialsLoader, | ||
EndpointResolver: cfg.EndpointResolver, | ||
Handlers: cfg.Handlers.Copy(), | ||
Retryer: cfg.Retryer, | ||
|
||
LogLevel: cfg.LogLevel, | ||
Logger: cfg.Logger, | ||
} | ||
|
||
retryer := cfg.Retryer | ||
if retryer == nil { | ||
// TODO need better way of specifing default num retries | ||
retryer = DefaultRetryer{NumMaxRetries: 3} | ||
} | ||
svc.Retryer = retryer | ||
|
||
svc.AddDebugHandlers() | ||
|
||
return svc | ||
} | ||
|
||
// NewRequest returns a new Request pointer for the service API | ||
// operation and parameters. | ||
func (c *Client) NewRequest(operation *Operation, params interface{}, data interface{}) *Request { | ||
return New(c.Config, c.Metadata, c.Handlers, c.Retryer, operation, params, data) | ||
} | ||
|
||
// AddDebugHandlers injects debug logging handlers into the service to log request | ||
// debug information. | ||
func (c *Client) AddDebugHandlers() { | ||
if !c.Config.LogLevel.AtLeast(LogDebug) { | ||
return | ||
} | ||
|
||
c.Handlers.Send.PushFrontNamed(NamedHandler{Name: "awssdk.client.LogRequest", Fn: logRequest}) | ||
c.Handlers.Send.PushBackNamed(NamedHandler{Name: "awssdk.client.LogResponse", Fn: logResponse}) | ||
} |
Oops, something went wrong.