Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Config loading, replacing the need for a Session. #4

Closed
wants to merge 8 commits into from
Closed

Refactoring Config loading, replacing the need for a Session. #4

wants to merge 8 commits into from

Conversation

jasdel
Copy link
Contributor

@jasdel jasdel commented Oct 12, 2017

Adds an external package to load external configuration data to the SDK. This replaces the loading work performed by the session package. In addition this will remove the need for a session and the SDK can remove this concept.

The new external config loading package is based on modular components that are plugged together to load external configuration, and resolve that configuration into an aws.Config value. This allows customers the flexibility to configure the SDK as they need.

This does not support service specific external configuration. It is not defined how or if this will be supported in the future.

Load default configuration without any customization or options:

cfg, err := external.LoadDefaultAWSConfig()
if err != nil {
    panic(fmt.Sprintf("failed loading config, %v", err)
}

Load default configuration while also providing a shared config profile
in addition to the default shared config and env config.

extCfgs, err := external.Config{
    StaticSharedConfigProfile("test-profile"),
}.AppendFromLoaders(DefaultConfigLoaders)
if err != nil {
    panic(fmt.Sprintf("failed loading config, %v", err)
}

cfg, err := extCfgs.ResolveAWSConfig(DefaultAWSConfigResolvers)
if err != nil {
    panic(fmt.Sprintf("failed loading config, %v", err)
}

TODO:

  • Consider the simple use case of SharedConfig profile as being too verbose, helper maybe?
  • Add tests for external package.
  • Remove Session (Add handlers to aws.Config).
  • Shoudl add additional helpers WithSharedConfigProfile("test-profile"), WithEndpointResolver(StaticEndpoint("abc")), WithRegion("blah"), or is this complicating the loader with AWSConfig specific values.?

@jasdel
Copy link
Contributor Author

jasdel commented Oct 12, 2017

One possible way to solve the shared config usability issue is to update LoadDefaultAWSConfig() and allow it to take a variadic list of external.Config that will seed the external.Configs.

Signature update:

func LoadDefaultAWSConfig(configs ...Config) (aws.Config, error) {}

Updated Usage:

cfg, err := external.LoadDefaultAWSConfig(
    WithSharedConfigProfile("test-profile"),
)
if err != nil {
    panic(fmt.Sprintf("failed loading config, %v", err))
}

@jasdel
Copy link
Contributor Author

jasdel commented Oct 13, 2017

dropping this PR creating PR against feature branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant