aws / aws-sdk-go-v2

AWS SDK for the Go programming language.
https://aws.github.io/aws-sdk-go-v2/docs/
Apache License 2.0
2.68k stars 651 forks source link

fix LoadDefaultConfig optFns #2703

Closed kentokento closed 4 months ago

kentokento commented 5 months ago

I want to use config.LoadOptionsFunc as below

    // var opts []func(*config.LoadOptions) error
    var opts []config.LoadOptionsFunc // now this will result in an error
    if c.AccessKey != "" && c.SecretKey != "" {
        opts = append(opts, config.WithCredentialsProvider(
            &credentials.StaticCredentialsProvider{
                Value: aws.Credentials{
                    AccessKeyID:     c.AccessKey,
                    SecretAccessKey: c.SecretKey,
                },
            },
        ))
    }

    if c.Profile != "" {
        opts = append(opts, config.WithSharedConfigProfile(c.Profile))
    }
    if c.Filename != "" {
        opts = append(opts, config.WithSharedConfigFiles([]string{c.Filename}))
    }
    return config.LoadDefaultConfig(context.TODO(), opts...)
lucix-aws commented 4 months ago

We can't do this, it's an API break. See previous discussion in #2193.