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