(ctx context.Context)
| 112 | } |
| 113 | |
| 114 | func (s *Source) newClient(ctx context.Context) error { |
| 115 | var loadOpts []func(*config.LoadOptions) error |
| 116 | if s.Config.AwsProfile != nil && *s.Config.AwsProfile != "" { |
| 117 | loadOpts = append(loadOpts, config.WithSharedConfigProfile(*s.Config.AwsProfile)) |
| 118 | } |
| 119 | |
| 120 | region := s.Config.AwsRegion |
| 121 | if region == "" { |
| 122 | region = "us-east-1" |
| 123 | } |
| 124 | |
| 125 | loadOpts = append(loadOpts, config.WithRegion(region)) |
| 126 | |
| 127 | if c := defaultCreds(); c != nil { |
| 128 | loadOpts = append(loadOpts, config.WithCredentialsProvider(c)) |
| 129 | } |
| 130 | |
| 131 | cfg, err := config.LoadDefaultConfig(ctx, loadOpts...) |
| 132 | if err != nil { |
| 133 | return fmt.Errorf("failed to load aws config: %w", err) |
| 134 | } |
| 135 | |
| 136 | var clientOpts []func(*kinesis.Options) |
| 137 | if s.Config.AwsEndpoint != "" { |
| 138 | clientOpts = append(clientOpts, func(o *kinesis.Options) { |
| 139 | o.BaseEndpoint = aws.String(s.Config.AwsEndpoint) |
| 140 | }) |
| 141 | } |
| 142 | |
| 143 | s.kClient = kinesis.NewFromConfig(cfg, clientOpts...) |
| 144 | |
| 145 | return nil |
| 146 | } |
no test coverage detected