load_options.go 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114
  1. package config
  2. import (
  3. "context"
  4. "io"
  5. "github.com/aws/aws-sdk-go-v2/aws"
  6. "github.com/aws/aws-sdk-go-v2/credentials/ec2rolecreds"
  7. "github.com/aws/aws-sdk-go-v2/credentials/endpointcreds"
  8. "github.com/aws/aws-sdk-go-v2/credentials/processcreds"
  9. "github.com/aws/aws-sdk-go-v2/credentials/ssocreds"
  10. "github.com/aws/aws-sdk-go-v2/credentials/stscreds"
  11. "github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
  12. smithybearer "github.com/aws/smithy-go/auth/bearer"
  13. "github.com/aws/smithy-go/logging"
  14. "github.com/aws/smithy-go/middleware"
  15. )
  16. // LoadOptionsFunc is a type alias for LoadOptions functional option
  17. type LoadOptionsFunc func(*LoadOptions) error
  18. // LoadOptions are discrete set of options that are valid for loading the
  19. // configuration
  20. type LoadOptions struct {
  21. // Region is the region to send requests to.
  22. Region string
  23. // Credentials object to use when signing requests.
  24. Credentials aws.CredentialsProvider
  25. // Token provider for authentication operations with bearer authentication.
  26. BearerAuthTokenProvider smithybearer.TokenProvider
  27. // HTTPClient the SDK's API clients will use to invoke HTTP requests.
  28. HTTPClient HTTPClient
  29. // EndpointResolver that can be used to provide or override an endpoint for
  30. // the given service and region.
  31. //
  32. // See the `aws.EndpointResolver` documentation on usage.
  33. //
  34. // Deprecated: See EndpointResolverWithOptions
  35. EndpointResolver aws.EndpointResolver
  36. // EndpointResolverWithOptions that can be used to provide or override an
  37. // endpoint for the given service and region.
  38. //
  39. // See the `aws.EndpointResolverWithOptions` documentation on usage.
  40. EndpointResolverWithOptions aws.EndpointResolverWithOptions
  41. // RetryMaxAttempts specifies the maximum number attempts an API client
  42. // will call an operation that fails with a retryable error.
  43. //
  44. // This value will only be used if Retryer option is nil.
  45. RetryMaxAttempts int
  46. // RetryMode specifies the retry model the API client will be created with.
  47. //
  48. // This value will only be used if Retryer option is nil.
  49. RetryMode aws.RetryMode
  50. // Retryer is a function that provides a Retryer implementation. A Retryer
  51. // guides how HTTP requests should be retried in case of recoverable
  52. // failures.
  53. //
  54. // If not nil, RetryMaxAttempts, and RetryMode will be ignored.
  55. Retryer func() aws.Retryer
  56. // APIOptions provides the set of middleware mutations modify how the API
  57. // client requests will be handled. This is useful for adding additional
  58. // tracing data to a request, or changing behavior of the SDK's client.
  59. APIOptions []func(*middleware.Stack) error
  60. // Logger writer interface to write logging messages to.
  61. Logger logging.Logger
  62. // ClientLogMode is used to configure the events that will be sent to the
  63. // configured logger. This can be used to configure the logging of signing,
  64. // retries, request, and responses of the SDK clients.
  65. //
  66. // See the ClientLogMode type documentation for the complete set of logging
  67. // modes and available configuration.
  68. ClientLogMode *aws.ClientLogMode
  69. // SharedConfigProfile is the profile to be used when loading the SharedConfig
  70. SharedConfigProfile string
  71. // SharedConfigFiles is the slice of custom shared config files to use when
  72. // loading the SharedConfig. A non-default profile used within config file
  73. // must have name defined with prefix 'profile '. eg [profile xyz]
  74. // indicates a profile with name 'xyz'. To read more on the format of the
  75. // config file, please refer the documentation at
  76. // https://docs.aws.amazon.com/credref/latest/refdocs/file-format.html#file-format-config
  77. //
  78. // If duplicate profiles are provided within the same, or across multiple
  79. // shared config files, the next parsed profile will override only the
  80. // properties that conflict with the previously defined profile. Note that
  81. // if duplicate profiles are provided within the SharedCredentialsFiles and
  82. // SharedConfigFiles, the properties defined in shared credentials file
  83. // take precedence.
  84. SharedConfigFiles []string
  85. // SharedCredentialsFile is the slice of custom shared credentials files to
  86. // use when loading the SharedConfig. The profile name used within
  87. // credentials file must not prefix 'profile '. eg [xyz] indicates a
  88. // profile with name 'xyz'. Profile declared as [profile xyz] will be
  89. // ignored. To read more on the format of the credentials file, please
  90. // refer the documentation at
  91. // https://docs.aws.amazon.com/credref/latest/refdocs/file-format.html#file-format-creds
  92. //
  93. // If duplicate profiles are provided with a same, or across multiple
  94. // shared credentials files, the next parsed profile will override only
  95. // properties that conflict with the previously defined profile. Note that
  96. // if duplicate profiles are provided within the SharedCredentialsFiles and
  97. // SharedConfigFiles, the properties defined in shared credentials file
  98. // take precedence.
  99. SharedCredentialsFiles []string
  100. // CustomCABundle is CA bundle PEM bytes reader
  101. CustomCABundle io.Reader
  102. // DefaultRegion is the fall back region, used if a region was not resolved
  103. // from other sources
  104. DefaultRegion string
  105. // UseEC2IMDSRegion indicates if SDK should retrieve the region
  106. // from the EC2 Metadata service
  107. UseEC2IMDSRegion *UseEC2IMDSRegion
  108. // CredentialsCacheOptions is a function for setting the
  109. // aws.CredentialsCacheOptions
  110. CredentialsCacheOptions func(*aws.CredentialsCacheOptions)
  111. // BearerAuthTokenCacheOptions is a function for setting the smithy-go
  112. // auth/bearer#TokenCacheOptions
  113. BearerAuthTokenCacheOptions func(*smithybearer.TokenCacheOptions)
  114. // SSOTokenProviderOptions is a function for setting the
  115. // credentials/ssocreds.SSOTokenProviderOptions
  116. SSOTokenProviderOptions func(*ssocreds.SSOTokenProviderOptions)
  117. // ProcessCredentialOptions is a function for setting
  118. // the processcreds.Options
  119. ProcessCredentialOptions func(*processcreds.Options)
  120. // EC2RoleCredentialOptions is a function for setting
  121. // the ec2rolecreds.Options
  122. EC2RoleCredentialOptions func(*ec2rolecreds.Options)
  123. // EndpointCredentialOptions is a function for setting
  124. // the endpointcreds.Options
  125. EndpointCredentialOptions func(*endpointcreds.Options)
  126. // WebIdentityRoleCredentialOptions is a function for setting
  127. // the stscreds.WebIdentityRoleOptions
  128. WebIdentityRoleCredentialOptions func(*stscreds.WebIdentityRoleOptions)
  129. // AssumeRoleCredentialOptions is a function for setting the
  130. // stscreds.AssumeRoleOptions
  131. AssumeRoleCredentialOptions func(*stscreds.AssumeRoleOptions)
  132. // SSOProviderOptions is a function for setting
  133. // the ssocreds.Options
  134. SSOProviderOptions func(options *ssocreds.Options)
  135. // LogConfigurationWarnings when set to true, enables logging
  136. // configuration warnings
  137. LogConfigurationWarnings *bool
  138. // S3UseARNRegion specifies if the S3 service should allow ARNs to direct
  139. // the region, the client's requests are sent to.
  140. S3UseARNRegion *bool
  141. // S3DisableMultiRegionAccessPoints specifies if the S3 service should disable
  142. // the S3 Multi-Region access points feature.
  143. S3DisableMultiRegionAccessPoints *bool
  144. // EnableEndpointDiscovery specifies if endpoint discovery is enable for
  145. // the client.
  146. EnableEndpointDiscovery aws.EndpointDiscoveryEnableState
  147. // Specifies if the EC2 IMDS service client is enabled.
  148. //
  149. // AWS_EC2_METADATA_DISABLED=true
  150. EC2IMDSClientEnableState imds.ClientEnableState
  151. // Specifies the EC2 Instance Metadata Service default endpoint selection
  152. // mode (IPv4 or IPv6)
  153. EC2IMDSEndpointMode imds.EndpointModeState
  154. // Specifies the EC2 Instance Metadata Service endpoint to use. If
  155. // specified it overrides EC2IMDSEndpointMode.
  156. EC2IMDSEndpoint string
  157. // Specifies that SDK clients must resolve a dual-stack endpoint for
  158. // services.
  159. UseDualStackEndpoint aws.DualStackEndpointState
  160. // Specifies that SDK clients must resolve a FIPS endpoint for
  161. // services.
  162. UseFIPSEndpoint aws.FIPSEndpointState
  163. // Specifies the SDK configuration mode for defaults.
  164. DefaultsModeOptions DefaultsModeOptions
  165. // The sdk app ID retrieved from env var or shared config to be added to request user agent header
  166. AppID string
  167. // Specifies whether an operation request could be compressed
  168. DisableRequestCompression *bool
  169. // The inclusive min bytes of a request body that could be compressed
  170. RequestMinCompressSizeBytes *int64
  171. // Whether S3 Express auth is disabled.
  172. S3DisableExpressAuth *bool
  173. }
  174. func (o LoadOptions) getDefaultsMode(ctx context.Context) (aws.DefaultsMode, bool, error) {
  175. if len(o.DefaultsModeOptions.Mode) == 0 {
  176. return "", false, nil
  177. }
  178. return o.DefaultsModeOptions.Mode, true, nil
  179. }
  180. // GetRetryMaxAttempts returns the RetryMaxAttempts if specified in the
  181. // LoadOptions and not 0.
  182. func (o LoadOptions) GetRetryMaxAttempts(ctx context.Context) (int, bool, error) {
  183. if o.RetryMaxAttempts == 0 {
  184. return 0, false, nil
  185. }
  186. return o.RetryMaxAttempts, true, nil
  187. }
  188. // GetRetryMode returns the RetryMode specified in the LoadOptions.
  189. func (o LoadOptions) GetRetryMode(ctx context.Context) (aws.RetryMode, bool, error) {
  190. if len(o.RetryMode) == 0 {
  191. return "", false, nil
  192. }
  193. return o.RetryMode, true, nil
  194. }
  195. func (o LoadOptions) getDefaultsModeIMDSClient(ctx context.Context) (*imds.Client, bool, error) {
  196. if o.DefaultsModeOptions.IMDSClient == nil {
  197. return nil, false, nil
  198. }
  199. return o.DefaultsModeOptions.IMDSClient, true, nil
  200. }
  201. // getRegion returns Region from config's LoadOptions
  202. func (o LoadOptions) getRegion(ctx context.Context) (string, bool, error) {
  203. if len(o.Region) == 0 {
  204. return "", false, nil
  205. }
  206. return o.Region, true, nil
  207. }
  208. // getAppID returns AppID from config's LoadOptions
  209. func (o LoadOptions) getAppID(ctx context.Context) (string, bool, error) {
  210. return o.AppID, len(o.AppID) > 0, nil
  211. }
  212. // getDisableRequestCompression returns DisableRequestCompression from config's LoadOptions
  213. func (o LoadOptions) getDisableRequestCompression(ctx context.Context) (bool, bool, error) {
  214. if o.DisableRequestCompression == nil {
  215. return false, false, nil
  216. }
  217. return *o.DisableRequestCompression, true, nil
  218. }
  219. // getRequestMinCompressSizeBytes returns RequestMinCompressSizeBytes from config's LoadOptions
  220. func (o LoadOptions) getRequestMinCompressSizeBytes(ctx context.Context) (int64, bool, error) {
  221. if o.RequestMinCompressSizeBytes == nil {
  222. return 0, false, nil
  223. }
  224. return *o.RequestMinCompressSizeBytes, true, nil
  225. }
  226. // WithRegion is a helper function to construct functional options
  227. // that sets Region on config's LoadOptions. Setting the region to
  228. // an empty string, will result in the region value being ignored.
  229. // If multiple WithRegion calls are made, the last call overrides
  230. // the previous call values.
  231. func WithRegion(v string) LoadOptionsFunc {
  232. return func(o *LoadOptions) error {
  233. o.Region = v
  234. return nil
  235. }
  236. }
  237. // WithAppID is a helper function to construct functional options
  238. // that sets AppID on config's LoadOptions.
  239. func WithAppID(ID string) LoadOptionsFunc {
  240. return func(o *LoadOptions) error {
  241. o.AppID = ID
  242. return nil
  243. }
  244. }
  245. // WithDisableRequestCompression is a helper function to construct functional options
  246. // that sets DisableRequestCompression on config's LoadOptions.
  247. func WithDisableRequestCompression(DisableRequestCompression *bool) LoadOptionsFunc {
  248. return func(o *LoadOptions) error {
  249. if DisableRequestCompression == nil {
  250. return nil
  251. }
  252. o.DisableRequestCompression = DisableRequestCompression
  253. return nil
  254. }
  255. }
  256. // WithRequestMinCompressSizeBytes is a helper function to construct functional options
  257. // that sets RequestMinCompressSizeBytes on config's LoadOptions.
  258. func WithRequestMinCompressSizeBytes(RequestMinCompressSizeBytes *int64) LoadOptionsFunc {
  259. return func(o *LoadOptions) error {
  260. if RequestMinCompressSizeBytes == nil {
  261. return nil
  262. }
  263. o.RequestMinCompressSizeBytes = RequestMinCompressSizeBytes
  264. return nil
  265. }
  266. }
  267. // getDefaultRegion returns DefaultRegion from config's LoadOptions
  268. func (o LoadOptions) getDefaultRegion(ctx context.Context) (string, bool, error) {
  269. if len(o.DefaultRegion) == 0 {
  270. return "", false, nil
  271. }
  272. return o.DefaultRegion, true, nil
  273. }
  274. // WithDefaultRegion is a helper function to construct functional options
  275. // that sets a DefaultRegion on config's LoadOptions. Setting the default
  276. // region to an empty string, will result in the default region value
  277. // being ignored. If multiple WithDefaultRegion calls are made, the last
  278. // call overrides the previous call values. Note that both WithRegion and
  279. // WithEC2IMDSRegion call takes precedence over WithDefaultRegion call
  280. // when resolving region.
  281. func WithDefaultRegion(v string) LoadOptionsFunc {
  282. return func(o *LoadOptions) error {
  283. o.DefaultRegion = v
  284. return nil
  285. }
  286. }
  287. // getSharedConfigProfile returns SharedConfigProfile from config's LoadOptions
  288. func (o LoadOptions) getSharedConfigProfile(ctx context.Context) (string, bool, error) {
  289. if len(o.SharedConfigProfile) == 0 {
  290. return "", false, nil
  291. }
  292. return o.SharedConfigProfile, true, nil
  293. }
  294. // WithSharedConfigProfile is a helper function to construct functional options
  295. // that sets SharedConfigProfile on config's LoadOptions. Setting the shared
  296. // config profile to an empty string, will result in the shared config profile
  297. // value being ignored.
  298. // If multiple WithSharedConfigProfile calls are made, the last call overrides
  299. // the previous call values.
  300. func WithSharedConfigProfile(v string) LoadOptionsFunc {
  301. return func(o *LoadOptions) error {
  302. o.SharedConfigProfile = v
  303. return nil
  304. }
  305. }
  306. // getSharedConfigFiles returns SharedConfigFiles set on config's LoadOptions
  307. func (o LoadOptions) getSharedConfigFiles(ctx context.Context) ([]string, bool, error) {
  308. if o.SharedConfigFiles == nil {
  309. return nil, false, nil
  310. }
  311. return o.SharedConfigFiles, true, nil
  312. }
  313. // WithSharedConfigFiles is a helper function to construct functional options
  314. // that sets slice of SharedConfigFiles on config's LoadOptions.
  315. // Setting the shared config files to an nil string slice, will result in the
  316. // shared config files value being ignored.
  317. // If multiple WithSharedConfigFiles calls are made, the last call overrides
  318. // the previous call values.
  319. func WithSharedConfigFiles(v []string) LoadOptionsFunc {
  320. return func(o *LoadOptions) error {
  321. o.SharedConfigFiles = v
  322. return nil
  323. }
  324. }
  325. // getSharedCredentialsFiles returns SharedCredentialsFiles set on config's LoadOptions
  326. func (o LoadOptions) getSharedCredentialsFiles(ctx context.Context) ([]string, bool, error) {
  327. if o.SharedCredentialsFiles == nil {
  328. return nil, false, nil
  329. }
  330. return o.SharedCredentialsFiles, true, nil
  331. }
  332. // WithSharedCredentialsFiles is a helper function to construct functional options
  333. // that sets slice of SharedCredentialsFiles on config's LoadOptions.
  334. // Setting the shared credentials files to an nil string slice, will result in the
  335. // shared credentials files value being ignored.
  336. // If multiple WithSharedCredentialsFiles calls are made, the last call overrides
  337. // the previous call values.
  338. func WithSharedCredentialsFiles(v []string) LoadOptionsFunc {
  339. return func(o *LoadOptions) error {
  340. o.SharedCredentialsFiles = v
  341. return nil
  342. }
  343. }
  344. // getCustomCABundle returns CustomCABundle from LoadOptions
  345. func (o LoadOptions) getCustomCABundle(ctx context.Context) (io.Reader, bool, error) {
  346. if o.CustomCABundle == nil {
  347. return nil, false, nil
  348. }
  349. return o.CustomCABundle, true, nil
  350. }
  351. // WithCustomCABundle is a helper function to construct functional options
  352. // that sets CustomCABundle on config's LoadOptions. Setting the custom CA Bundle
  353. // to nil will result in custom CA Bundle value being ignored.
  354. // If multiple WithCustomCABundle calls are made, the last call overrides the
  355. // previous call values.
  356. func WithCustomCABundle(v io.Reader) LoadOptionsFunc {
  357. return func(o *LoadOptions) error {
  358. o.CustomCABundle = v
  359. return nil
  360. }
  361. }
  362. // UseEC2IMDSRegion provides a regionProvider that retrieves the region
  363. // from the EC2 Metadata service.
  364. type UseEC2IMDSRegion struct {
  365. // If unset will default to generic EC2 IMDS client.
  366. Client *imds.Client
  367. }
  368. // getRegion attempts to retrieve the region from EC2 Metadata service.
  369. func (p *UseEC2IMDSRegion) getRegion(ctx context.Context) (string, bool, error) {
  370. if ctx == nil {
  371. ctx = context.Background()
  372. }
  373. client := p.Client
  374. if client == nil {
  375. client = imds.New(imds.Options{})
  376. }
  377. result, err := client.GetRegion(ctx, nil)
  378. if err != nil {
  379. return "", false, err
  380. }
  381. if len(result.Region) != 0 {
  382. return result.Region, true, nil
  383. }
  384. return "", false, nil
  385. }
  386. // getEC2IMDSRegion returns the value of EC2 IMDS region.
  387. func (o LoadOptions) getEC2IMDSRegion(ctx context.Context) (string, bool, error) {
  388. if o.UseEC2IMDSRegion == nil {
  389. return "", false, nil
  390. }
  391. return o.UseEC2IMDSRegion.getRegion(ctx)
  392. }
  393. // WithEC2IMDSRegion is a helper function to construct functional options
  394. // that enables resolving EC2IMDS region. The function takes
  395. // in a UseEC2IMDSRegion functional option, and can be used to set the
  396. // EC2IMDS client which will be used to resolve EC2IMDSRegion.
  397. // If no functional option is provided, an EC2IMDS client is built and used
  398. // by the resolver. If multiple WithEC2IMDSRegion calls are made, the last
  399. // call overrides the previous call values. Note that the WithRegion calls takes
  400. // precedence over WithEC2IMDSRegion when resolving region.
  401. func WithEC2IMDSRegion(fnOpts ...func(o *UseEC2IMDSRegion)) LoadOptionsFunc {
  402. return func(o *LoadOptions) error {
  403. o.UseEC2IMDSRegion = &UseEC2IMDSRegion{}
  404. for _, fn := range fnOpts {
  405. fn(o.UseEC2IMDSRegion)
  406. }
  407. return nil
  408. }
  409. }
  410. // getCredentialsProvider returns the credentials value
  411. func (o LoadOptions) getCredentialsProvider(ctx context.Context) (aws.CredentialsProvider, bool, error) {
  412. if o.Credentials == nil {
  413. return nil, false, nil
  414. }
  415. return o.Credentials, true, nil
  416. }
  417. // WithCredentialsProvider is a helper function to construct functional options
  418. // that sets Credential provider value on config's LoadOptions. If credentials
  419. // provider is set to nil, the credentials provider value will be ignored.
  420. // If multiple WithCredentialsProvider calls are made, the last call overrides
  421. // the previous call values.
  422. func WithCredentialsProvider(v aws.CredentialsProvider) LoadOptionsFunc {
  423. return func(o *LoadOptions) error {
  424. o.Credentials = v
  425. return nil
  426. }
  427. }
  428. // getCredentialsCacheOptionsProvider returns the wrapped function to set aws.CredentialsCacheOptions
  429. func (o LoadOptions) getCredentialsCacheOptions(ctx context.Context) (func(*aws.CredentialsCacheOptions), bool, error) {
  430. if o.CredentialsCacheOptions == nil {
  431. return nil, false, nil
  432. }
  433. return o.CredentialsCacheOptions, true, nil
  434. }
  435. // WithCredentialsCacheOptions is a helper function to construct functional
  436. // options that sets a function to modify the aws.CredentialsCacheOptions the
  437. // aws.CredentialsCache will be configured with, if the CredentialsCache is used
  438. // by the configuration loader.
  439. //
  440. // If multiple WithCredentialsCacheOptions calls are made, the last call
  441. // overrides the previous call values.
  442. func WithCredentialsCacheOptions(v func(*aws.CredentialsCacheOptions)) LoadOptionsFunc {
  443. return func(o *LoadOptions) error {
  444. o.CredentialsCacheOptions = v
  445. return nil
  446. }
  447. }
  448. // getBearerAuthTokenProvider returns the credentials value
  449. func (o LoadOptions) getBearerAuthTokenProvider(ctx context.Context) (smithybearer.TokenProvider, bool, error) {
  450. if o.BearerAuthTokenProvider == nil {
  451. return nil, false, nil
  452. }
  453. return o.BearerAuthTokenProvider, true, nil
  454. }
  455. // WithBearerAuthTokenProvider is a helper function to construct functional options
  456. // that sets Credential provider value on config's LoadOptions. If credentials
  457. // provider is set to nil, the credentials provider value will be ignored.
  458. // If multiple WithBearerAuthTokenProvider calls are made, the last call overrides
  459. // the previous call values.
  460. func WithBearerAuthTokenProvider(v smithybearer.TokenProvider) LoadOptionsFunc {
  461. return func(o *LoadOptions) error {
  462. o.BearerAuthTokenProvider = v
  463. return nil
  464. }
  465. }
  466. // getBearerAuthTokenCacheOptionsProvider returns the wrapped function to set smithybearer.TokenCacheOptions
  467. func (o LoadOptions) getBearerAuthTokenCacheOptions(ctx context.Context) (func(*smithybearer.TokenCacheOptions), bool, error) {
  468. if o.BearerAuthTokenCacheOptions == nil {
  469. return nil, false, nil
  470. }
  471. return o.BearerAuthTokenCacheOptions, true, nil
  472. }
  473. // WithBearerAuthTokenCacheOptions is a helper function to construct functional options
  474. // that sets a function to modify the TokenCacheOptions the smithy-go
  475. // auth/bearer#TokenCache will be configured with, if the TokenCache is used by
  476. // the configuration loader.
  477. //
  478. // If multiple WithBearerAuthTokenCacheOptions calls are made, the last call overrides
  479. // the previous call values.
  480. func WithBearerAuthTokenCacheOptions(v func(*smithybearer.TokenCacheOptions)) LoadOptionsFunc {
  481. return func(o *LoadOptions) error {
  482. o.BearerAuthTokenCacheOptions = v
  483. return nil
  484. }
  485. }
  486. // getSSOTokenProviderOptionsProvider returns the wrapped function to set smithybearer.TokenCacheOptions
  487. func (o LoadOptions) getSSOTokenProviderOptions(ctx context.Context) (func(*ssocreds.SSOTokenProviderOptions), bool, error) {
  488. if o.SSOTokenProviderOptions == nil {
  489. return nil, false, nil
  490. }
  491. return o.SSOTokenProviderOptions, true, nil
  492. }
  493. // WithSSOTokenProviderOptions is a helper function to construct functional
  494. // options that sets a function to modify the SSOtokenProviderOptions the SDK's
  495. // credentials/ssocreds#SSOProvider will be configured with, if the
  496. // SSOTokenProvider is used by the configuration loader.
  497. //
  498. // If multiple WithSSOTokenProviderOptions calls are made, the last call overrides
  499. // the previous call values.
  500. func WithSSOTokenProviderOptions(v func(*ssocreds.SSOTokenProviderOptions)) LoadOptionsFunc {
  501. return func(o *LoadOptions) error {
  502. o.SSOTokenProviderOptions = v
  503. return nil
  504. }
  505. }
  506. // getProcessCredentialOptions returns the wrapped function to set processcreds.Options
  507. func (o LoadOptions) getProcessCredentialOptions(ctx context.Context) (func(*processcreds.Options), bool, error) {
  508. if o.ProcessCredentialOptions == nil {
  509. return nil, false, nil
  510. }
  511. return o.ProcessCredentialOptions, true, nil
  512. }
  513. // WithProcessCredentialOptions is a helper function to construct functional options
  514. // that sets a function to use processcreds.Options on config's LoadOptions.
  515. // If process credential options is set to nil, the process credential value will
  516. // be ignored. If multiple WithProcessCredentialOptions calls are made, the last call
  517. // overrides the previous call values.
  518. func WithProcessCredentialOptions(v func(*processcreds.Options)) LoadOptionsFunc {
  519. return func(o *LoadOptions) error {
  520. o.ProcessCredentialOptions = v
  521. return nil
  522. }
  523. }
  524. // getEC2RoleCredentialOptions returns the wrapped function to set the ec2rolecreds.Options
  525. func (o LoadOptions) getEC2RoleCredentialOptions(ctx context.Context) (func(*ec2rolecreds.Options), bool, error) {
  526. if o.EC2RoleCredentialOptions == nil {
  527. return nil, false, nil
  528. }
  529. return o.EC2RoleCredentialOptions, true, nil
  530. }
  531. // WithEC2RoleCredentialOptions is a helper function to construct functional options
  532. // that sets a function to use ec2rolecreds.Options on config's LoadOptions. If
  533. // EC2 role credential options is set to nil, the EC2 role credential options value
  534. // will be ignored. If multiple WithEC2RoleCredentialOptions calls are made,
  535. // the last call overrides the previous call values.
  536. func WithEC2RoleCredentialOptions(v func(*ec2rolecreds.Options)) LoadOptionsFunc {
  537. return func(o *LoadOptions) error {
  538. o.EC2RoleCredentialOptions = v
  539. return nil
  540. }
  541. }
  542. // getEndpointCredentialOptions returns the wrapped function to set endpointcreds.Options
  543. func (o LoadOptions) getEndpointCredentialOptions(context.Context) (func(*endpointcreds.Options), bool, error) {
  544. if o.EndpointCredentialOptions == nil {
  545. return nil, false, nil
  546. }
  547. return o.EndpointCredentialOptions, true, nil
  548. }
  549. // WithEndpointCredentialOptions is a helper function to construct functional options
  550. // that sets a function to use endpointcreds.Options on config's LoadOptions. If
  551. // endpoint credential options is set to nil, the endpoint credential options
  552. // value will be ignored. If multiple WithEndpointCredentialOptions calls are made,
  553. // the last call overrides the previous call values.
  554. func WithEndpointCredentialOptions(v func(*endpointcreds.Options)) LoadOptionsFunc {
  555. return func(o *LoadOptions) error {
  556. o.EndpointCredentialOptions = v
  557. return nil
  558. }
  559. }
  560. // getWebIdentityRoleCredentialOptions returns the wrapped function
  561. func (o LoadOptions) getWebIdentityRoleCredentialOptions(context.Context) (func(*stscreds.WebIdentityRoleOptions), bool, error) {
  562. if o.WebIdentityRoleCredentialOptions == nil {
  563. return nil, false, nil
  564. }
  565. return o.WebIdentityRoleCredentialOptions, true, nil
  566. }
  567. // WithWebIdentityRoleCredentialOptions is a helper function to construct
  568. // functional options that sets a function to use stscreds.WebIdentityRoleOptions
  569. // on config's LoadOptions. If web identity role credentials options is set to nil,
  570. // the web identity role credentials value will be ignored. If multiple
  571. // WithWebIdentityRoleCredentialOptions calls are made, the last call
  572. // overrides the previous call values.
  573. func WithWebIdentityRoleCredentialOptions(v func(*stscreds.WebIdentityRoleOptions)) LoadOptionsFunc {
  574. return func(o *LoadOptions) error {
  575. o.WebIdentityRoleCredentialOptions = v
  576. return nil
  577. }
  578. }
  579. // getAssumeRoleCredentialOptions returns AssumeRoleCredentialOptions from LoadOptions
  580. func (o LoadOptions) getAssumeRoleCredentialOptions(context.Context) (func(options *stscreds.AssumeRoleOptions), bool, error) {
  581. if o.AssumeRoleCredentialOptions == nil {
  582. return nil, false, nil
  583. }
  584. return o.AssumeRoleCredentialOptions, true, nil
  585. }
  586. // WithAssumeRoleCredentialOptions is a helper function to construct
  587. // functional options that sets a function to use stscreds.AssumeRoleOptions
  588. // on config's LoadOptions. If assume role credentials options is set to nil,
  589. // the assume role credentials value will be ignored. If multiple
  590. // WithAssumeRoleCredentialOptions calls are made, the last call overrides
  591. // the previous call values.
  592. func WithAssumeRoleCredentialOptions(v func(*stscreds.AssumeRoleOptions)) LoadOptionsFunc {
  593. return func(o *LoadOptions) error {
  594. o.AssumeRoleCredentialOptions = v
  595. return nil
  596. }
  597. }
  598. func (o LoadOptions) getHTTPClient(ctx context.Context) (HTTPClient, bool, error) {
  599. if o.HTTPClient == nil {
  600. return nil, false, nil
  601. }
  602. return o.HTTPClient, true, nil
  603. }
  604. // WithHTTPClient is a helper function to construct functional options
  605. // that sets HTTPClient on LoadOptions. If HTTPClient is set to nil,
  606. // the HTTPClient value will be ignored.
  607. // If multiple WithHTTPClient calls are made, the last call overrides
  608. // the previous call values.
  609. func WithHTTPClient(v HTTPClient) LoadOptionsFunc {
  610. return func(o *LoadOptions) error {
  611. o.HTTPClient = v
  612. return nil
  613. }
  614. }
  615. func (o LoadOptions) getAPIOptions(ctx context.Context) ([]func(*middleware.Stack) error, bool, error) {
  616. if o.APIOptions == nil {
  617. return nil, false, nil
  618. }
  619. return o.APIOptions, true, nil
  620. }
  621. // WithAPIOptions is a helper function to construct functional options
  622. // that sets APIOptions on LoadOptions. If APIOptions is set to nil, the
  623. // APIOptions value is ignored. If multiple WithAPIOptions calls are
  624. // made, the last call overrides the previous call values.
  625. func WithAPIOptions(v []func(*middleware.Stack) error) LoadOptionsFunc {
  626. return func(o *LoadOptions) error {
  627. if v == nil {
  628. return nil
  629. }
  630. o.APIOptions = append(o.APIOptions, v...)
  631. return nil
  632. }
  633. }
  634. func (o LoadOptions) getRetryMaxAttempts(ctx context.Context) (int, bool, error) {
  635. if o.RetryMaxAttempts == 0 {
  636. return 0, false, nil
  637. }
  638. return o.RetryMaxAttempts, true, nil
  639. }
  640. // WithRetryMaxAttempts is a helper function to construct functional options that sets
  641. // RetryMaxAttempts on LoadOptions. If RetryMaxAttempts is unset, the RetryMaxAttempts value is
  642. // ignored. If multiple WithRetryMaxAttempts calls are made, the last call overrides
  643. // the previous call values.
  644. //
  645. // Will be ignored of LoadOptions.Retryer or WithRetryer are used.
  646. func WithRetryMaxAttempts(v int) LoadOptionsFunc {
  647. return func(o *LoadOptions) error {
  648. o.RetryMaxAttempts = v
  649. return nil
  650. }
  651. }
  652. func (o LoadOptions) getRetryMode(ctx context.Context) (aws.RetryMode, bool, error) {
  653. if o.RetryMode == "" {
  654. return "", false, nil
  655. }
  656. return o.RetryMode, true, nil
  657. }
  658. // WithRetryMode is a helper function to construct functional options that sets
  659. // RetryMode on LoadOptions. If RetryMode is unset, the RetryMode value is
  660. // ignored. If multiple WithRetryMode calls are made, the last call overrides
  661. // the previous call values.
  662. //
  663. // Will be ignored of LoadOptions.Retryer or WithRetryer are used.
  664. func WithRetryMode(v aws.RetryMode) LoadOptionsFunc {
  665. return func(o *LoadOptions) error {
  666. o.RetryMode = v
  667. return nil
  668. }
  669. }
  670. func (o LoadOptions) getRetryer(ctx context.Context) (func() aws.Retryer, bool, error) {
  671. if o.Retryer == nil {
  672. return nil, false, nil
  673. }
  674. return o.Retryer, true, nil
  675. }
  676. // WithRetryer is a helper function to construct functional options
  677. // that sets Retryer on LoadOptions. If Retryer is set to nil, the
  678. // Retryer value is ignored. If multiple WithRetryer calls are
  679. // made, the last call overrides the previous call values.
  680. func WithRetryer(v func() aws.Retryer) LoadOptionsFunc {
  681. return func(o *LoadOptions) error {
  682. o.Retryer = v
  683. return nil
  684. }
  685. }
  686. func (o LoadOptions) getEndpointResolver(ctx context.Context) (aws.EndpointResolver, bool, error) {
  687. if o.EndpointResolver == nil {
  688. return nil, false, nil
  689. }
  690. return o.EndpointResolver, true, nil
  691. }
  692. // WithEndpointResolver is a helper function to construct functional options
  693. // that sets the EndpointResolver on LoadOptions. If the EndpointResolver is set to nil,
  694. // the EndpointResolver value is ignored. If multiple WithEndpointResolver calls
  695. // are made, the last call overrides the previous call values.
  696. //
  697. // Deprecated: See WithEndpointResolverWithOptions
  698. func WithEndpointResolver(v aws.EndpointResolver) LoadOptionsFunc {
  699. return func(o *LoadOptions) error {
  700. o.EndpointResolver = v
  701. return nil
  702. }
  703. }
  704. func (o LoadOptions) getEndpointResolverWithOptions(ctx context.Context) (aws.EndpointResolverWithOptions, bool, error) {
  705. if o.EndpointResolverWithOptions == nil {
  706. return nil, false, nil
  707. }
  708. return o.EndpointResolverWithOptions, true, nil
  709. }
  710. // WithEndpointResolverWithOptions is a helper function to construct functional options
  711. // that sets the EndpointResolverWithOptions on LoadOptions. If the EndpointResolverWithOptions is set to nil,
  712. // the EndpointResolver value is ignored. If multiple WithEndpointResolver calls
  713. // are made, the last call overrides the previous call values.
  714. func WithEndpointResolverWithOptions(v aws.EndpointResolverWithOptions) LoadOptionsFunc {
  715. return func(o *LoadOptions) error {
  716. o.EndpointResolverWithOptions = v
  717. return nil
  718. }
  719. }
  720. func (o LoadOptions) getLogger(ctx context.Context) (logging.Logger, bool, error) {
  721. if o.Logger == nil {
  722. return nil, false, nil
  723. }
  724. return o.Logger, true, nil
  725. }
  726. // WithLogger is a helper function to construct functional options
  727. // that sets Logger on LoadOptions. If Logger is set to nil, the
  728. // Logger value will be ignored. If multiple WithLogger calls are made,
  729. // the last call overrides the previous call values.
  730. func WithLogger(v logging.Logger) LoadOptionsFunc {
  731. return func(o *LoadOptions) error {
  732. o.Logger = v
  733. return nil
  734. }
  735. }
  736. func (o LoadOptions) getClientLogMode(ctx context.Context) (aws.ClientLogMode, bool, error) {
  737. if o.ClientLogMode == nil {
  738. return 0, false, nil
  739. }
  740. return *o.ClientLogMode, true, nil
  741. }
  742. // WithClientLogMode is a helper function to construct functional options
  743. // that sets client log mode on LoadOptions. If client log mode is set to nil,
  744. // the client log mode value will be ignored. If multiple WithClientLogMode calls are made,
  745. // the last call overrides the previous call values.
  746. func WithClientLogMode(v aws.ClientLogMode) LoadOptionsFunc {
  747. return func(o *LoadOptions) error {
  748. o.ClientLogMode = &v
  749. return nil
  750. }
  751. }
  752. func (o LoadOptions) getLogConfigurationWarnings(ctx context.Context) (v bool, found bool, err error) {
  753. if o.LogConfigurationWarnings == nil {
  754. return false, false, nil
  755. }
  756. return *o.LogConfigurationWarnings, true, nil
  757. }
  758. // WithLogConfigurationWarnings is a helper function to construct
  759. // functional options that can be used to set LogConfigurationWarnings
  760. // on LoadOptions.
  761. //
  762. // If multiple WithLogConfigurationWarnings calls are made, the last call
  763. // overrides the previous call values.
  764. func WithLogConfigurationWarnings(v bool) LoadOptionsFunc {
  765. return func(o *LoadOptions) error {
  766. o.LogConfigurationWarnings = &v
  767. return nil
  768. }
  769. }
  770. // GetS3UseARNRegion returns whether to allow ARNs to direct the region
  771. // the S3 client's requests are sent to.
  772. func (o LoadOptions) GetS3UseARNRegion(ctx context.Context) (v bool, found bool, err error) {
  773. if o.S3UseARNRegion == nil {
  774. return false, false, nil
  775. }
  776. return *o.S3UseARNRegion, true, nil
  777. }
  778. // WithS3UseARNRegion is a helper function to construct functional options
  779. // that can be used to set S3UseARNRegion on LoadOptions.
  780. // If multiple WithS3UseARNRegion calls are made, the last call overrides
  781. // the previous call values.
  782. func WithS3UseARNRegion(v bool) LoadOptionsFunc {
  783. return func(o *LoadOptions) error {
  784. o.S3UseARNRegion = &v
  785. return nil
  786. }
  787. }
  788. // GetS3DisableMultiRegionAccessPoints returns whether to disable
  789. // the S3 multi-region access points feature.
  790. func (o LoadOptions) GetS3DisableMultiRegionAccessPoints(ctx context.Context) (v bool, found bool, err error) {
  791. if o.S3DisableMultiRegionAccessPoints == nil {
  792. return false, false, nil
  793. }
  794. return *o.S3DisableMultiRegionAccessPoints, true, nil
  795. }
  796. // WithS3DisableMultiRegionAccessPoints is a helper function to construct functional options
  797. // that can be used to set S3DisableMultiRegionAccessPoints on LoadOptions.
  798. // If multiple WithS3DisableMultiRegionAccessPoints calls are made, the last call overrides
  799. // the previous call values.
  800. func WithS3DisableMultiRegionAccessPoints(v bool) LoadOptionsFunc {
  801. return func(o *LoadOptions) error {
  802. o.S3DisableMultiRegionAccessPoints = &v
  803. return nil
  804. }
  805. }
  806. // GetEnableEndpointDiscovery returns if the EnableEndpointDiscovery flag is set.
  807. func (o LoadOptions) GetEnableEndpointDiscovery(ctx context.Context) (value aws.EndpointDiscoveryEnableState, ok bool, err error) {
  808. if o.EnableEndpointDiscovery == aws.EndpointDiscoveryUnset {
  809. return aws.EndpointDiscoveryUnset, false, nil
  810. }
  811. return o.EnableEndpointDiscovery, true, nil
  812. }
  813. // WithEndpointDiscovery is a helper function to construct functional options
  814. // that can be used to enable endpoint discovery on LoadOptions for supported clients.
  815. // If multiple WithEndpointDiscovery calls are made, the last call overrides
  816. // the previous call values.
  817. func WithEndpointDiscovery(v aws.EndpointDiscoveryEnableState) LoadOptionsFunc {
  818. return func(o *LoadOptions) error {
  819. o.EnableEndpointDiscovery = v
  820. return nil
  821. }
  822. }
  823. // getSSOProviderOptions returns AssumeRoleCredentialOptions from LoadOptions
  824. func (o LoadOptions) getSSOProviderOptions(context.Context) (func(options *ssocreds.Options), bool, error) {
  825. if o.SSOProviderOptions == nil {
  826. return nil, false, nil
  827. }
  828. return o.SSOProviderOptions, true, nil
  829. }
  830. // WithSSOProviderOptions is a helper function to construct
  831. // functional options that sets a function to use ssocreds.Options
  832. // on config's LoadOptions. If the SSO credential provider options is set to nil,
  833. // the sso provider options value will be ignored. If multiple
  834. // WithSSOProviderOptions calls are made, the last call overrides
  835. // the previous call values.
  836. func WithSSOProviderOptions(v func(*ssocreds.Options)) LoadOptionsFunc {
  837. return func(o *LoadOptions) error {
  838. o.SSOProviderOptions = v
  839. return nil
  840. }
  841. }
  842. // GetEC2IMDSClientEnableState implements a EC2IMDSClientEnableState options resolver interface.
  843. func (o LoadOptions) GetEC2IMDSClientEnableState() (imds.ClientEnableState, bool, error) {
  844. if o.EC2IMDSClientEnableState == imds.ClientDefaultEnableState {
  845. return imds.ClientDefaultEnableState, false, nil
  846. }
  847. return o.EC2IMDSClientEnableState, true, nil
  848. }
  849. // GetEC2IMDSEndpointMode implements a EC2IMDSEndpointMode option resolver interface.
  850. func (o LoadOptions) GetEC2IMDSEndpointMode() (imds.EndpointModeState, bool, error) {
  851. if o.EC2IMDSEndpointMode == imds.EndpointModeStateUnset {
  852. return imds.EndpointModeStateUnset, false, nil
  853. }
  854. return o.EC2IMDSEndpointMode, true, nil
  855. }
  856. // GetEC2IMDSEndpoint implements a EC2IMDSEndpoint option resolver interface.
  857. func (o LoadOptions) GetEC2IMDSEndpoint() (string, bool, error) {
  858. if len(o.EC2IMDSEndpoint) == 0 {
  859. return "", false, nil
  860. }
  861. return o.EC2IMDSEndpoint, true, nil
  862. }
  863. // WithEC2IMDSClientEnableState is a helper function to construct functional options that sets the EC2IMDSClientEnableState.
  864. func WithEC2IMDSClientEnableState(v imds.ClientEnableState) LoadOptionsFunc {
  865. return func(o *LoadOptions) error {
  866. o.EC2IMDSClientEnableState = v
  867. return nil
  868. }
  869. }
  870. // WithEC2IMDSEndpointMode is a helper function to construct functional options that sets the EC2IMDSEndpointMode.
  871. func WithEC2IMDSEndpointMode(v imds.EndpointModeState) LoadOptionsFunc {
  872. return func(o *LoadOptions) error {
  873. o.EC2IMDSEndpointMode = v
  874. return nil
  875. }
  876. }
  877. // WithEC2IMDSEndpoint is a helper function to construct functional options that sets the EC2IMDSEndpoint.
  878. func WithEC2IMDSEndpoint(v string) LoadOptionsFunc {
  879. return func(o *LoadOptions) error {
  880. o.EC2IMDSEndpoint = v
  881. return nil
  882. }
  883. }
  884. // WithUseDualStackEndpoint is a helper function to construct
  885. // functional options that can be used to set UseDualStackEndpoint on LoadOptions.
  886. func WithUseDualStackEndpoint(v aws.DualStackEndpointState) LoadOptionsFunc {
  887. return func(o *LoadOptions) error {
  888. o.UseDualStackEndpoint = v
  889. return nil
  890. }
  891. }
  892. // GetUseDualStackEndpoint returns whether the service's dual-stack endpoint should be
  893. // used for requests.
  894. func (o LoadOptions) GetUseDualStackEndpoint(ctx context.Context) (value aws.DualStackEndpointState, found bool, err error) {
  895. if o.UseDualStackEndpoint == aws.DualStackEndpointStateUnset {
  896. return aws.DualStackEndpointStateUnset, false, nil
  897. }
  898. return o.UseDualStackEndpoint, true, nil
  899. }
  900. // WithUseFIPSEndpoint is a helper function to construct
  901. // functional options that can be used to set UseFIPSEndpoint on LoadOptions.
  902. func WithUseFIPSEndpoint(v aws.FIPSEndpointState) LoadOptionsFunc {
  903. return func(o *LoadOptions) error {
  904. o.UseFIPSEndpoint = v
  905. return nil
  906. }
  907. }
  908. // GetUseFIPSEndpoint returns whether the service's FIPS endpoint should be
  909. // used for requests.
  910. func (o LoadOptions) GetUseFIPSEndpoint(ctx context.Context) (value aws.FIPSEndpointState, found bool, err error) {
  911. if o.UseFIPSEndpoint == aws.FIPSEndpointStateUnset {
  912. return aws.FIPSEndpointStateUnset, false, nil
  913. }
  914. return o.UseFIPSEndpoint, true, nil
  915. }
  916. // WithDefaultsMode sets the SDK defaults configuration mode to the value provided.
  917. //
  918. // Zero or more functional options can be provided to provide configuration options for performing
  919. // environment discovery when using aws.DefaultsModeAuto.
  920. func WithDefaultsMode(mode aws.DefaultsMode, optFns ...func(options *DefaultsModeOptions)) LoadOptionsFunc {
  921. do := DefaultsModeOptions{
  922. Mode: mode,
  923. }
  924. for _, fn := range optFns {
  925. fn(&do)
  926. }
  927. return func(options *LoadOptions) error {
  928. options.DefaultsModeOptions = do
  929. return nil
  930. }
  931. }
  932. // GetS3DisableExpressAuth returns the configured value for
  933. // [EnvConfig.S3DisableExpressAuth].
  934. func (o LoadOptions) GetS3DisableExpressAuth() (value, ok bool) {
  935. if o.S3DisableExpressAuth == nil {
  936. return false, false
  937. }
  938. return *o.S3DisableExpressAuth, true
  939. }
  940. // WithS3DisableExpressAuth sets [LoadOptions.S3DisableExpressAuth]
  941. // to the value provided.
  942. func WithS3DisableExpressAuth(v bool) LoadOptionsFunc {
  943. return func(o *LoadOptions) error {
  944. o.S3DisableExpressAuth = &v
  945. return nil
  946. }
  947. }