Skip to content

Commit a8dd015

Browse files
authored
feat: add new_resource_manager_client_options hook to manager template (#684)
Issue #, if available: aws-controllers-k8s/community#2237 Description of changes: In order to support some S3-compatible APIs (e.g. LocalStack on a local dev cluster) it may be necessary to force the S3 client to use "path-style" URLs (e.g. http://host/bucket/key). This PR adds a hook injection point in `newResourceManager` to allow service controllers to pass custom options to the AWS SDK client constructor. This will let the S3 controller set `UsePathStyle` based on the value set in its controller config. I've also added changes to the Helm chart to support configuring this option in the S3 controller. Associated PRs: - [s3-controller#214](aws-controllers-k8s/s3-controller#214) uses this hook to control `UsePathStyle`. - [runtime#233](aws-controllers-k8s/runtime#233) adds a new config option used by the `s3-controller` to set `UsePathStyle`. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent c55e822 commit a8dd015

5 files changed

Lines changed: 16 additions & 2 deletions

File tree

pkg/generate/ack/release.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232
"helm/templates/_helpers.tpl.tpl",
3333
"helm/Chart.yaml.tpl",
3434
"helm/values.yaml.tpl",
35-
"helm/values.schema.json",
35+
"helm/values.schema.json.tpl",
3636
"helm/templates/NOTES.txt.tpl",
3737
"helm/templates/role-reader.yaml.tpl",
3838
"helm/templates/role-writer.yaml.tpl",

templates/helm/templates/deployment.yaml.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ spec:
5858
{{ "{{- if .Values.aws.allow_unsafe_aws_endpoint_urls }}" }}
5959
- --allow-unsafe-aws-endpoint-urls
6060
{{ "{{- end }}" }}
61+
{{- if eq .ControllerName "s3" }}
62+
{{ "{{- if .Values.aws.endpoint_use_path_style }}" }}
63+
- --aws-endpoint-use-path-style
64+
{{ "{{- end }}" }}
65+
{{- end }}
6166
{{ "{{- if .Values.log.enable_development_logging }}" }}
6267
- --enable-development-logging
6368
{{ "{{- end }}" }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@
181181
"type": "boolean",
182182
"default": false
183183
},
184+
{{- if eq .ControllerName "s3" }}
185+
"endpoint_use_path_style": {
186+
"type": "boolean",
187+
"default": false
188+
},
189+
{{- end }}
184190
"credentials": {
185191
"description": "AWS credentials information",
186192
"properties": {

templates/helm/values.yaml.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ aws:
9292
endpoint_url: ""
9393
identity_endpoint_url: ""
9494
allow_unsafe_aws_endpoint_urls: false
95+
{{- if eq .ControllerName "s3" }}
96+
endpoint_use_path_style: false
97+
{{- end }}
9598
credentials:
9699
# If specified, Secret with shared credentials file to use.
97100
secretName: ""

templates/pkg/resource/manager.go.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ func newResourceManager(
435435
rr: rr,
436436
awsAccountID: id,
437437
awsRegion: region,
438-
sdkapi: svcsdk.NewFromConfig(clientcfg),
438+
sdkapi: svcsdk.NewFromConfig(clientcfg{{- if $hookCode := Hook .CRD "new_resource_manager_client_options" }}, {{ $hookCode }}{{ end }}),
439439
}, nil
440440
}
441441

0 commit comments

Comments
 (0)