Repository navigation
fix: chart should render configs required by hsm-adapter #2242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,44 @@ | ||
| {{/* | ||
| The override adds the HSM adapter block to the ConfigMap the contentMap builds. | ||
|
|
||
| It is not a contentMap entry. The backend validates ATALLA_HOST and ATALLA_PORT | ||
| when HSM_ENABLED is true and rejects an empty string for either, so a contentMap | ||
| entry would emit `ATALLA_HOST: ""` in every environment that leaves it unset and | ||
| stop the backend from starting. Here the whole block appears only when | ||
| config.backend.hsm.enabled is true. | ||
|
|
||
| common.utils.merge merges maps deeply, so these keys join the contentMap's | ||
| `data` rather than replacing it. | ||
| */}} | ||
| {{- define "testnet-wallet.backend.ConfigMap" -}} | ||
| {{- $top := first . }} | ||
| {{- $hsm := $top.Values.config.backend.hsm }} | ||
| {{- if $hsm.enabled }} | ||
| {{- if not $hsm.atalla.host }} | ||
| {{- fail "config.backend.hsm.atalla.host is required when config.backend.hsm.enabled is true" }} | ||
| {{- end }} | ||
| {{- if not $hsm.atalla.port }} | ||
| {{- fail "config.backend.hsm.atalla.port is required when config.backend.hsm.enabled is true" }} | ||
| {{- end }} | ||
| data: | ||
| HSM_ENABLED: "true" | ||
| HSM_SERVER_ROLE: {{ $hsm.serverRole | quote }} | ||
| {{- /* ISSUER_GRPC_HOST and MERCHANT_GRPC_HOST are omitted: the backend falls | ||
| back to HSM_GRPC_HOST, and one host serves both roles here. */}} | ||
| HSM_GRPC_HOST: {{ $hsm.grpcHost | quote }} | ||
| ISSUER_GRPC_PORT: {{ $hsm.issuerPort | quote }} | ||
| MERCHANT_GRPC_PORT: {{ $hsm.merchantPort | quote }} | ||
| ATALLA_HOST: {{ $hsm.atalla.host | quote }} | ||
| ATALLA_PORT: {{ $hsm.atalla.port | quote }} | ||
| ATALLA_TIMEOUT_MS: {{ $hsm.atalla.timeoutMs | quote }} | ||
| ATALLA_POOL_SIZE: {{ $hsm.atalla.poolSize | quote }} | ||
| ATALLA_TLS_ENABLED: {{ $hsm.atalla.tls.enabled | quote }} | ||
| {{- if $hsm.atalla.tls.enabled }} | ||
| ATALLA_SKIP_SERVER_IDENTITY_CHECK: {{ $hsm.atalla.tls.skipServerIdentityCheck | quote }} | ||
| ATALLA_CA_CERT_PATH: {{ $hsm.atalla.tls.caCertPath | quote }} | ||
| ATALLA_CLIENT_CERT_PATH: {{ $hsm.atalla.tls.clientCertPath | quote }} | ||
| ATALLA_CLIENT_KEY_PATH: {{ $hsm.atalla.tls.clientKeyPath | quote }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- include "common.configMapper" (list . .Values.configMaps.backend "testnet-wallet.backend.ConfigMap") }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| suite: testnet-wallet backend - HSM adapter configuration | ||
| templates: | ||
| - configMap.backend.yaml | ||
| set: | ||
| fullnameOverride: test-testnet-wallet | ||
| release: | ||
| name: test-testnet-wallet | ||
| tests: | ||
| # The backend rejects an empty ATALLA_HOST, so the keys must be absent | ||
| # rather than blank in every environment that does not run the adapter. | ||
| - it: 'omits every HSM key when the adapter is disabled' | ||
| asserts: | ||
| - notExists: | ||
| path: data.HSM_ENABLED | ||
| - notExists: | ||
| path: data.ATALLA_HOST | ||
| - notExists: | ||
| path: data.ISSUER_GRPC_PORT | ||
| # The contentMap keys are still there. | ||
| - equal: | ||
| path: data.NODE_ENV | ||
| value: production | ||
|
|
||
| - it: 'emits the adapter block when enabled, alongside the contentMap keys' | ||
| set: | ||
| config: | ||
| backend: | ||
| hsm: | ||
| enabled: true | ||
| atalla: | ||
| host: '10.0.0.1' | ||
| port: 13506 | ||
| asserts: | ||
| - equal: | ||
| path: data.HSM_ENABLED | ||
| value: 'true' | ||
| - equal: | ||
| path: data.HSM_SERVER_ROLE | ||
| value: both | ||
| - equal: | ||
| path: data.HSM_GRPC_HOST | ||
| value: 0.0.0.0 | ||
| - equal: | ||
| path: data.ISSUER_GRPC_PORT | ||
| value: '50051' | ||
| - equal: | ||
| path: data.MERCHANT_GRPC_PORT | ||
| value: '50052' | ||
| - equal: | ||
| path: data.ATALLA_HOST | ||
| value: '10.0.0.1' | ||
| # Numbers must reach the ConfigMap as strings. | ||
| - equal: | ||
| path: data.ATALLA_PORT | ||
| value: '13506' | ||
| - equal: | ||
| path: data.ATALLA_POOL_SIZE | ||
| value: '1' | ||
| - equal: | ||
| path: data.ATALLA_CA_CERT_PATH | ||
| value: /etc/atalla/tls/ca.crt | ||
| # The override must merge with the contentMap, not replace it. | ||
| - equal: | ||
| path: data.NODE_ENV | ||
| value: production | ||
|
|
||
| - it: 'drops the TLS paths when Atalla TLS is off' | ||
| set: | ||
| config: | ||
| backend: | ||
| hsm: | ||
| enabled: true | ||
| atalla: | ||
| host: '10.0.0.1' | ||
| port: 13506 | ||
| tls: | ||
| enabled: false | ||
| asserts: | ||
| - equal: | ||
| path: data.ATALLA_TLS_ENABLED | ||
| value: 'false' | ||
| - notExists: | ||
| path: data.ATALLA_CA_CERT_PATH | ||
| - notExists: | ||
| path: data.ATALLA_SKIP_SERVER_IDENTITY_CHECK | ||
|
|
||
| - it: 'fails the render when the adapter is enabled without an Atalla host' | ||
| set: | ||
| config: | ||
| backend: | ||
| hsm: | ||
| enabled: true | ||
| atalla: | ||
| port: 13506 | ||
| asserts: | ||
| - failedTemplate: | ||
| errorMessage: 'config.backend.hsm.atalla.host is required when config.backend.hsm.enabled is true' | ||
|
|
||
| - it: 'fails the render when the adapter is enabled without an Atalla port' | ||
| set: | ||
| config: | ||
| backend: | ||
| hsm: | ||
| enabled: true | ||
| atalla: | ||
| host: '10.0.0.1' | ||
| asserts: | ||
| - failedTemplate: | ||
| errorMessage: 'config.backend.hsm.atalla.port is required when config.backend.hsm.enabled is true' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.