config.go (2603B)
1 package configsources 2 3 import ( 4 "context" 5 6 "github.com/aws/aws-sdk-go-v2/aws" 7 ) 8 9 // EnableEndpointDiscoveryProvider is an interface for retrieving external configuration value 10 // for Enable Endpoint Discovery 11 type EnableEndpointDiscoveryProvider interface { 12 GetEnableEndpointDiscovery(ctx context.Context) (value aws.EndpointDiscoveryEnableState, found bool, err error) 13 } 14 15 // ResolveEnableEndpointDiscovery extracts the first instance of a EnableEndpointDiscoveryProvider from the config slice. 16 // Additionally returns a aws.EndpointDiscoveryEnableState to indicate if the value was found in provided configs, 17 // and error if one is encountered. 18 func ResolveEnableEndpointDiscovery(ctx context.Context, configs []any) (value aws.EndpointDiscoveryEnableState, found bool, err error) { 19 for _, cfg := range configs { 20 if p, ok := cfg.(EnableEndpointDiscoveryProvider); ok { 21 value, found, err = p.GetEnableEndpointDiscovery(ctx) 22 if err != nil || found { 23 break 24 } 25 } 26 } 27 return 28 } 29 30 // UseDualStackEndpointProvider is an interface for retrieving external configuration values for UseDualStackEndpoint 31 type UseDualStackEndpointProvider interface { 32 GetUseDualStackEndpoint(context.Context) (value aws.DualStackEndpointState, found bool, err error) 33 } 34 35 // ResolveUseDualStackEndpoint extracts the first instance of a UseDualStackEndpoint from the config slice. 36 // Additionally returns a boolean to indicate if the value was found in provided configs, and error if one is encountered. 37 func ResolveUseDualStackEndpoint(ctx context.Context, configs []any) (value aws.DualStackEndpointState, found bool, err error) { 38 for _, cfg := range configs { 39 if p, ok := cfg.(UseDualStackEndpointProvider); ok { 40 value, found, err = p.GetUseDualStackEndpoint(ctx) 41 if err != nil || found { 42 break 43 } 44 } 45 } 46 return 47 } 48 49 // UseFIPSEndpointProvider is an interface for retrieving external configuration values for UseFIPSEndpoint 50 type UseFIPSEndpointProvider interface { 51 GetUseFIPSEndpoint(context.Context) (value aws.FIPSEndpointState, found bool, err error) 52 } 53 54 // ResolveUseFIPSEndpoint extracts the first instance of a UseFIPSEndpointProvider from the config slice. 55 // Additionally, returns a boolean to indicate if the value was found in provided configs, and error if one is encountered. 56 func ResolveUseFIPSEndpoint(ctx context.Context, configs []any) (value aws.FIPSEndpointState, found bool, err error) { 57 for _, cfg := range configs { 58 if p, ok := cfg.(UseFIPSEndpointProvider); ok { 59 value, found, err = p.GetUseFIPSEndpoint(ctx) 60 if err != nil || found { 61 break 62 } 63 } 64 } 65 return 66 }