Skip to content

Commit

Permalink
feat(seeding): adjust config for seeding data
Browse files Browse the repository at this point in the history
* make authority and credential authorities for operator overwriteable
* add configuration to add own config maps for seeding

Refs: #77
  • Loading branch information
Phil91 committed Oct 22, 2024
1 parent 4f9a315 commit 0954e9b
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 11 deletions.
83 changes: 83 additions & 0 deletions charts/ssi-asr/templates/configmap-seeding-initialdata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{{- /*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/}}

{{- if .Values.migrations.seeding.useInitial -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-initial-data
namespace: {{ .Release.Namespace }}
data:
authorities.json: |-
[
{
"bpn": "{{ .Values.operator.bpn }}"
},
{
"bpn": "BPNL00000003CRHL"
}
]
credentials.json: |-
[
{
"id": "255e01fc-65f6-43cd-8dfa-95e95fa95f60",
"type_id": 1,
"name": "BusinessPartnerCredential"
},
{
"id": "255e01fc-65f6-43cd-8dfa-95e95fa95f61",
"type_id": 2,
"name": "MembershipCredential"
},
{
"id": "10df6ecd-faa3-45ed-8da5-96261f6542dd",
"type_id": 3,
"name": "DataExchangeGovernanceCredential"
},
{
"id": "255e01fc-65f6-43cd-8dfa-95e95fa95f6b",
"type_id": 4,
"name": "DismantlerCredential"
}
]
credential_authorities.json: |-
[
{
"credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f60",
"bpn": "{{ .Values.operator.bpn }}"
},
{
"credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f61",
"bpn": "{{ .Values.operator.bpn }}"
},
{
"credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f6b",
"bpn": "{{ .Values.operator.bpn }}"
},
{
"credential_id": "255e01fc-65f6-43cd-8dfa-95e95fa95f6b",
"bpn": "BPNL00000003CRHL"
},
{
"credential_id": "10df6ecd-faa3-45ed-8da5-96261f6542dd",
"bpn": "{{ .Values.operator.bpn }}"
}
]
{{- end }}
38 changes: 35 additions & 3 deletions charts/ssi-asr/templates/job-registry-migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,16 @@ spec:
- name: "CONNECTIONSTRINGS__REGISTRYDB"
value: "Server={{ .Values.externalDatabase.host }};Database={{ .Values.externalDatabase.database }};Port={{ .Values.externalDatabase.port }};User Id={{ .Values.externalDatabase.username }};Password=$(REGISTRY_PASSWORD);Ssl Mode={{ .Values.dbConnection.sslMode }};"
{{- end }}
- name: "SEEDING__TESTDATAENVIRONMENTS__0"
value: "{{ .Values.migrations.seeding.testDataEnvironments }}"
- name: "SEEDING__DATAPATHS__0"
value: "{{ .Values.migrations.seeding.testDataPaths }}"
value: "Seeder/Data/"
- name: "SEEDING__DATAPATHS__1"
value: "Seeder/Data/overwrite"
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
- name: "SEEDING__DATAPATHS__2"
value: "Seeder/Data/import/custom-test-data"
- name: "SEEDING__TESTDATAENVIRONMENTS__2"
value: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.filename }}"
{{- end }}
- name: "SERILOG__MINIMUMLEVEL__Default"
value: "{{ .Values.migrations.logging.default }}"
ports:
Expand All @@ -79,3 +85,29 @@ spec:
protocol: TCP
resources:
{{- toYaml .Values.migrations.resources | nindent 10 }}
{{- if or (.Values.migrations.seeding.useInitial) (and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename)) }}
volumeMounts:
{{- if (.Values.migrations.seeding.useInitial) }}
- name: data-initial
mountPath: /migrations/Seeder/Data/overwrite
{{- end }}
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
- name: test-data-custom
mountPath: /migrations/Seeder/Data/import/custom-test-data
{{- end }}
{{- end }}
{{- if or (.Values.migrations.seeding.useInitial) (and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename)) }}
volumes:
{{- if (.Values.migrations.seeding.useInitial) }}
- name: data-initial
configMap:
name: {{ .Release.Name }}-initial-data
optional: true
{{- end }}
{{- if and (.Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap) (.Values.migrations.seeding.seedTestData.useOwnConfigMap.filename) }}
- name: test-data-custom
configMap:
name: "{{ .Values.migrations.seeding.seedTestData.useOwnConfigMap.configMap }}"
optional: true
{{- end }}
{{- end }}
17 changes: 15 additions & 2 deletions charts/ssi-asr/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
# SPDX-License-Identifier: Apache-2.0
###############################################################

# -- Set information related to the operator company
operator:
# -- The bpn of the operator
bpn: "empty"

service:
image:
name: "docker.io/tractusx/ssi-authority-schema-registry-service"
Expand Down Expand Up @@ -62,8 +67,16 @@ migrations:
cpu: 75m
memory: 200M
seeding:
testDataEnvironments: ""
testDataPaths: "Seeder/Data"
# -- Enables dynamic seeding of information related to the operator company: operator.bpn;
# If set to `true` the data configured in the config map 'configmap-seeding-initialdata.yaml' will be taken to insert the initial data;
useInitial: true
# -- Option to seed test data provided in a configMap
seedTestData:
useOwnConfigMap:
# -- ConfigMap containing json files for the tables to seed, e.g. credentials.test.json, authorities.test.json, etc.
configMap: ""
# -- Filename identifying the test data files e.g. for credentials.test.json the value would be "test"
filename: ""
logging:
default: "Information"

Expand Down
2 changes: 2 additions & 0 deletions environments/helm-values/values-int.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#
# SPDX-License-Identifier: Apache-2.0
###############################################################
operator:
bpn: "BPNL00000003CRHK"

ingress:
enabled: true
Expand Down
2 changes: 2 additions & 0 deletions environments/helm-values/values-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#
# SPDX-License-Identifier: Apache-2.0
###############################################################
operator:
bpn: "BPNL00000003CRHK"

ingress:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"type_id": 2,
"name": "MembershipCredential"
},
{
"id": "255e01fc-65f6-43cd-8dfa-95e95fa95f6b",
"type_id": 4,
"name": "DismantlerCredential"
},
{
"id": "10df6ecd-faa3-45ed-8da5-96261f6542dd",
"type_id": 3,
"name": "DataExchangeGovernanceCredential"
},
{
"id": "255e01fc-65f6-43cd-8dfa-95e95fa95f6b",
"type_id": 4,
"name": "DismantlerCredential"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@

<None Remove="Seeder\Data" />
<Content Include="Seeder\Data\**" LinkBase="Seeder\Data" CopyToOutputDirectory="Always" />

<None Remove="Seeder\Data\overwrite" />
<Content Include="Seeder\Data\overwrite\**" LinkBase="Seeder\Data\overwrite" CopyToOutputDirectory="Always" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
},
"Seeding": {
"DataPaths": [
"Seeder/Data"
"Seeder/Data",
"Seeder/Data/overwrite"
],
"TestDataEnvironments": []
}
Expand Down

0 comments on commit 0954e9b

Please sign in to comment.