From 2dd7686dcb815c56d29ed1a720ff16a11bdfead3 Mon Sep 17 00:00:00 2001 From: Lee Surprenant Date: Mon, 4 Oct 2021 13:56:42 -0400 Subject: [PATCH] favor maps over lists due to helm list merge limitations Originally, I went with an approach that uses lists of objects. However, after experiencing some pain with the helm support for combining / overriding lists, I reverted back to a map-based approach where the key-names have more value. This is more consistent with the approach we use in fhir-server-config anyway, and so I went ahead and made them exactly alike so that we can just rely on helm's toJson instead of writing our own templates for this. Signed-off-by: Lee Surprenant --- charts/ibm-fhir-server/README.md | 13 ++++---- .../templates/_fhirServerConfigJson.tpl | 33 ++----------------- charts/ibm-fhir-server/values.yaml | 17 +++++----- 3 files changed, 17 insertions(+), 46 deletions(-) diff --git a/charts/ibm-fhir-server/README.md b/charts/ibm-fhir-server/README.md index 69b0a3d..65c1c9b 100644 --- a/charts/ibm-fhir-server/README.md +++ b/charts/ibm-fhir-server/README.md @@ -167,13 +167,12 @@ If the `objectStorage.objectStorageSecret` value is set, this helm chart will on | db.tenantKey | string | `nil` | | | db.type | string | `"postgresql"` | | | db.user | string | `"postgres"` | | -| endpoints | list | A single entry for resourceType "Resource" that applies to all resource types | Control which interactions are supported for which resource type endpoints | -| endpoints[0].interactions | list | All interactions. | The set of enabled interactions for this resource type: [create, read, vread, history, search, update, patch, delete] | -| endpoints[0].profiles | list | `nil` | Instances of this type must claim conformance to at least one of the listed profiles; nil means no profile conformance required | -| endpoints[0].resourceType | string | `"Resource"` | A valid FHIR resource type; use "Resource" for whole-system behavior | -| endpoints[0].searchIncludes | list | `nil` | Valid _include arguments while searching this resource type; nil means no restrictions | -| endpoints[0].searchParameters | list | `[{"code":"*","url":"*"}]` | A mapping from enabled search parameter codes to search parameter definitions | -| endpoints[0].searchRevIncludes | list | `nil` | Valid _revInclude arguments while searching this resource type; nil means no restrictions | +| endpoints | object | A single entry for resourceType "Resource" that applies to all resource types | Control which interactions are supported for which resource type endpoints | +| endpoints.Resource.interactions | list | All interactions. | The set of enabled interactions for this resource type: [create, read, vread, history, search, update, patch, delete] | +| endpoints.Resource.profiles.atLeastOne | list | `nil` | Instances of this type must claim conformance to at least one of the listed profiles; nil means no profile conformance required | +| endpoints.Resource.searchIncludes | list | `nil` | Valid _include arguments while searching this resource type; nil means no restrictions | +| endpoints.Resource.searchParameters | object | `{"*":"*"}` | A mapping from enabled search parameter codes to search parameter definitions | +| endpoints.Resource.searchRevIncludes | list | `nil` | Valid _revInclude arguments while searching this resource type; nil means no restrictions | | extensionSearchParametersTemplate | string | `"defaultSearchParameters"` | Template containing the extension-search-parameters.json content | | extraEnv | string | `""` | | | extraJvmOptions | string | `""` | | diff --git a/charts/ibm-fhir-server/templates/_fhirServerConfigJson.tpl b/charts/ibm-fhir-server/templates/_fhirServerConfigJson.tpl index ef1d7aa..6cd090d 100644 --- a/charts/ibm-fhir-server/templates/_fhirServerConfigJson.tpl +++ b/charts/ibm-fhir-server/templates/_fhirServerConfigJson.tpl @@ -19,37 +19,8 @@ The default fhir-server-config.json. }, "resources": { "open": {{ not .Values.restrictEndpoints }} - {{- range $i, $endpoint := .Values.endpoints }} - {{- if $endpoint.resourceType }}, - "{{ $endpoint.resourceType }}": { - {{- if $endpoint.searchIncludes }} - "searchIncludes": {{ toJson $endpoint.searchIncludes }} - {{- end}} - {{- if $endpoint.searchRevIncludes }} - {{- if $endpoint.searchIncludes }},{{- end }} - "searchRevIncludes": {{ toJson $endpoint.searchRevIncludes }} - {{- end}} - {{- if $endpoint.profiles }} - {{- if or $endpoint.searchIncludes $endpoint.searchRevIncludes }},{{- end }} - "profiles": { - "atLeastOne": {{ toJson $endpoint.profiles }} - } - {{- end}} - {{- if $endpoint.searchParameters }} - {{- if or $endpoint.searchIncludes $endpoint.searchRevIncludes $endpoint.searchProfiles }},{{- end }} - "searchParameters": { - {{- $lastIndex := sub (len $endpoint.searchParameters) 1 }} - {{- range $j, $param := $endpoint.searchParameters }} - "{{ $param.code }}": "{{ $param.url }}"{{ if not (eq $j $lastIndex) }},{{ end }} - {{- end }} - } - {{- end}} - {{- if $endpoint.interactions }} - {{- if or $endpoint.searchIncludes $endpoint.searchRevIncludes $endpoint.searchProfiles $endpoint.searchParameters }},{{- end }} - "interactions": {{ toJson $endpoint.interactions }} - {{- end}} - } - {{- end }} + {{- range $endpoint, $conf := .Values.endpoints }}, + "{{ $endpoint }}": {{ toPrettyJson $conf | indent 16 }} {{- end }} }, "security": { diff --git a/charts/ibm-fhir-server/values.yaml b/charts/ibm-fhir-server/values.yaml index 8d1ae9c..1d8188a 100644 --- a/charts/ibm-fhir-server/values.yaml +++ b/charts/ibm-fhir-server/values.yaml @@ -24,19 +24,20 @@ restrictEndpoints: false # -- Control which interactions are supported for which resource type endpoints # @default -- A single entry for resourceType "Resource" that applies to all resource types endpoints: - # yamllint disable-line rule:comments - - # -- A valid FHIR resource type; use "Resource" for whole-system behavior - resourceType: Resource - # -- (list) Valid _include arguments while searching this resource type; nil means no restrictions + Resource: + # -- (list) Valid _include arguments while searching this resource type; + # nil means no restrictions searchIncludes: - # -- (list) Valid _revInclude arguments while searching this resource type; nil means no restrictions + # -- (list) Valid _revInclude arguments while searching this resource type; + # nil means no restrictions searchRevIncludes: - # -- (list) Instances of this type must claim conformance to at least one of the listed profiles; nil means no profile conformance required profiles: + # -- (list) Instances of this type must claim conformance to at least one of the listed profiles; + # nil means no profile conformance required + atLeastOne: # -- A mapping from enabled search parameter codes to search parameter definitions searchParameters: - - code: "*" - url: "*" + "*": "*" # -- The set of enabled interactions for this resource type: # [create, read, vread, history, search, update, patch, delete] # @default -- All interactions.