MCPcopy
hub / github.com/crowdsecurity/crowdsec / newClient

Method newClient

pkg/acquisition/modules/kinesis/config.go:114–146  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

112}
113
114func (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}

Callers 1

ConfigureMethod · 0.95

Calls 2

defaultCredsFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected