config.go 2.6 KB

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