mirror of
https://github.com/valitydev/helmsdeep.git
synced 2024-11-06 08:55:21 +00:00
Add dominant initialization post-install hook (#31)
Co-authored-by: Andrew Mayorov <encube.ul@gmail.com>
This commit is contained in:
parent
8cf3aa2ec4
commit
d5dba6f009
294
config/dominant/init-script.sh
Normal file
294
config/dominant/init-script.sh
Normal file
@ -0,0 +1,294 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o errtrace
|
||||||
|
|
||||||
|
FIXTURE=$(cat <<END
|
||||||
|
{"ops": [
|
||||||
|
|
||||||
|
{"insert": {"object": {"globals": {
|
||||||
|
"ref": {},
|
||||||
|
"data": {
|
||||||
|
"system_account_set": {"value": {"id": 1}},
|
||||||
|
"external_account_set": {"value": {"id": 1}},
|
||||||
|
"inspector": {"value": {"id": 1}}
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"system_account_set": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"name": "Primary",
|
||||||
|
"description": "Primary",
|
||||||
|
"accounts": [
|
||||||
|
{"key": {"symbolic_code": "RUB"}, "value": {
|
||||||
|
"settlement": $(scripts/dominant/create-account.sh RUB)
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"external_account_set": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"name": "Primary",
|
||||||
|
"description": "Primary",
|
||||||
|
"accounts": [
|
||||||
|
{"key": {"symbolic_code": "RUB"}, "value": {
|
||||||
|
"income": $(scripts/dominant/create-account.sh RUB),
|
||||||
|
"outcome": $(scripts/dominant/create-account.sh RUB)
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"inspector": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"name": "Kovalsky",
|
||||||
|
"description": "World famous inspector Kovalsky at your service!",
|
||||||
|
"proxy": {
|
||||||
|
"ref": {"id": 100},
|
||||||
|
"additional": {
|
||||||
|
"risk_score": "high"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"term_set_hierarchy": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"term_sets": [
|
||||||
|
{
|
||||||
|
"action_time": {},
|
||||||
|
"terms": {
|
||||||
|
"payments": {
|
||||||
|
"currencies": {"value": [
|
||||||
|
{"symbolic_code": "RUB"}
|
||||||
|
]},
|
||||||
|
"categories": {"value": [
|
||||||
|
{"id": 1}
|
||||||
|
]},
|
||||||
|
"payment_methods": {"value": [
|
||||||
|
{"id": {"bank_card": "visa"}},
|
||||||
|
{"id": {"bank_card": "mastercard"}}
|
||||||
|
]},
|
||||||
|
"cash_limit": {"decisions": [
|
||||||
|
{
|
||||||
|
"if_": {"condition": {"currency_is": {"symbolic_code": "RUB"}}},
|
||||||
|
"then_": {"value": {
|
||||||
|
"lower": {"inclusive": {"amount": 1000, "currency": {"symbolic_code": "RUB"}}},
|
||||||
|
"upper": {"exclusive": {"amount": 4200000, "currency": {"symbolic_code": "RUB"}}}
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
"fees": {"decisions": [
|
||||||
|
{
|
||||||
|
"if_": {"condition": {"currency_is": {"symbolic_code": "RUB"}}},
|
||||||
|
"then_": {"value": [
|
||||||
|
{
|
||||||
|
"source": {"merchant": "settlement"},
|
||||||
|
"destination": {"system": "settlement"},
|
||||||
|
"volume": {"share": {"parts": {"p": 45, "q": 1000}, "of": "operation_amount"}}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
"holds": {
|
||||||
|
"payment_methods": {"value": [
|
||||||
|
{"id": {"bank_card": "visa"}},
|
||||||
|
{"id": {"bank_card": "mastercard"}}
|
||||||
|
]},
|
||||||
|
"lifetime": {"value": {"seconds": 10}}
|
||||||
|
},
|
||||||
|
"refunds": {
|
||||||
|
"payment_methods": {"value": [
|
||||||
|
{"id": {"bank_card": "visa"}},
|
||||||
|
{"id": {"bank_card": "mastercard"}}
|
||||||
|
]},
|
||||||
|
"fees": {"value": [
|
||||||
|
]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"contract_template": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"terms": {"id": 1}
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"currency": {
|
||||||
|
"ref": {"symbolic_code": "RUB"},
|
||||||
|
"data": {
|
||||||
|
"name": "Russian rubles",
|
||||||
|
"numeric_code": 643,
|
||||||
|
"symbolic_code": "RUB",
|
||||||
|
"exponent": 2
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"category": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"name": "Basic test category",
|
||||||
|
"description": "Basic test category for mocketbank provider",
|
||||||
|
"type": "test"
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"payment_method": {
|
||||||
|
"ref": {"id": {"bank_card": "visa"}},
|
||||||
|
"data": {
|
||||||
|
"name": "VISA",
|
||||||
|
"description": "VISA bank cards"
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"payment_method": {
|
||||||
|
"ref": {"id": {"bank_card": "mastercard"}},
|
||||||
|
"data": {
|
||||||
|
"name": "Mastercard",
|
||||||
|
"description": "Mastercard bank cards"
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"provider": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"name": "Mocketbank",
|
||||||
|
"description": "Mocketbank",
|
||||||
|
"terminal": {"value": [
|
||||||
|
{"id": 1}
|
||||||
|
]},
|
||||||
|
"proxy": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"additional": {}
|
||||||
|
},
|
||||||
|
"abs_account": "0000000001",
|
||||||
|
"terms": {
|
||||||
|
"payments": {
|
||||||
|
"currencies": {"value": [
|
||||||
|
{"symbolic_code": "RUB"}
|
||||||
|
]},
|
||||||
|
"categories": {"value": [
|
||||||
|
{"id": 1}
|
||||||
|
]},
|
||||||
|
"payment_methods": {"value": [
|
||||||
|
{"id": {"bank_card": "visa"}},
|
||||||
|
{"id": {"bank_card": "mastercard"}}
|
||||||
|
]},
|
||||||
|
"cash_limit": {"value": {
|
||||||
|
"lower": {"inclusive": {"amount": 1000, "currency": {"symbolic_code": "RUB"}}},
|
||||||
|
"upper": {"exclusive": {"amount": 10000000, "currency": {"symbolic_code": "RUB"}}}
|
||||||
|
}},
|
||||||
|
"cash_flow": {"decisions": [
|
||||||
|
{
|
||||||
|
"if_": {"condition":
|
||||||
|
{"payment_tool": {"bank_card": {"definition": {"payment_system_is": "visa"}}}}
|
||||||
|
},
|
||||||
|
"then_": {"value": [
|
||||||
|
{
|
||||||
|
"source": {"provider": "settlement"},
|
||||||
|
"destination": {"merchant": "settlement"},
|
||||||
|
"volume": {"share": {"parts": {"p": 1, "q": 1}, "of": "operation_amount"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": {"system": "settlement"},
|
||||||
|
"destination": {"provider": "settlement"},
|
||||||
|
"volume": {"share": {"parts": {"p": 15, "q": 1000}, "of": "operation_amount"}}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if_": {"condition":
|
||||||
|
{"payment_tool": {"bank_card": {"definition": {"payment_system_is": "mastercard"}}}}
|
||||||
|
},
|
||||||
|
"then_": {"value": [
|
||||||
|
{
|
||||||
|
"source": {"provider": "settlement"},
|
||||||
|
"destination": {"merchant": "settlement"},
|
||||||
|
"volume": {"share": {"parts": {"p": 1, "q": 1}, "of": "operation_amount"}}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": {"system": "settlement"},
|
||||||
|
"destination": {"provider": "settlement"},
|
||||||
|
"volume": {"share": {"parts": {"p": 18, "q": 1000}, "of": "operation_amount"}}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
"holds": {
|
||||||
|
"lifetime": {"value": {"seconds": 3600}}
|
||||||
|
},
|
||||||
|
"refunds": {
|
||||||
|
"cash_flow": {"value": [
|
||||||
|
{
|
||||||
|
"source": {"merchant": "settlement"},
|
||||||
|
"destination": {"provider": "settlement"},
|
||||||
|
"volume": {"share": {"parts": {"p": 1, "q": 1}, "of": "operation_amount"}}
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"accounts": [
|
||||||
|
{"key": {"symbolic_code": "RUB"}, "value": {
|
||||||
|
"settlement": $(scripts/dominant/create-account.sh RUB)
|
||||||
|
}}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"terminal": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"name": "Mocketbank Test Acquiring",
|
||||||
|
"description": "Mocketbank Test Acquiring"
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"proxy": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"name": "Mocketbank Proxy",
|
||||||
|
"description": "Mocked bank proxy for integration test purposes",
|
||||||
|
"url": "http://mocketbank:8022/proxy/mocketbank",
|
||||||
|
"options": {}
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"proxy": {
|
||||||
|
"ref": {"id": 100},
|
||||||
|
"data": {
|
||||||
|
"name": "Mocket Inspector Proxy",
|
||||||
|
"description": "Mocked inspector proxy for integration test purposes",
|
||||||
|
"url": "http://mocketinspector:8022/proxy/mocket/inspector",
|
||||||
|
"options": {"risk_score": "high"}
|
||||||
|
}
|
||||||
|
}}}},
|
||||||
|
|
||||||
|
{"insert": {"object": {"payment_institution": {
|
||||||
|
"ref": {"id": 1},
|
||||||
|
"data": {
|
||||||
|
"name": "Test Payment Institution",
|
||||||
|
"system_account_set": {"value": {"id": 1}},
|
||||||
|
"default_contract_template": {"value": {"id": 1}},
|
||||||
|
"providers": {"value": [{"id": 1}]},
|
||||||
|
"inspector": {"value": {"id": 1}},
|
||||||
|
"realm": "test",
|
||||||
|
"residences": ["rus", "aus", "jpn"]
|
||||||
|
}
|
||||||
|
}}}}
|
||||||
|
]}
|
||||||
|
END
|
||||||
|
)
|
||||||
|
|
||||||
|
woorl -s "damsel/proto/domain_config.thrift" "http://dominant:8022/v1/domain/repository" Repository Commit 0 "${FIXTURE}"
|
@ -1 +1,7 @@
|
|||||||
replicaCount: 1
|
replicaCount: 1
|
||||||
|
|
||||||
|
initializationTask:
|
||||||
|
create: true
|
||||||
|
repository: dr2.rbkmoney.com/rbkmoney/holmes
|
||||||
|
tag: bfa6fc0428a75c9f179b89b9278ed1aedbb8b649
|
||||||
|
workdir: /opt/holmes
|
||||||
|
@ -111,6 +111,8 @@ releases:
|
|||||||
- name: dominant
|
- name: dominant
|
||||||
<<: *default
|
<<: *default
|
||||||
set:
|
set:
|
||||||
|
- name: initializationTask.script
|
||||||
|
file: config/dominant/init-script.sh
|
||||||
- name: appConfig
|
- name: appConfig
|
||||||
file: config/dominant/sys.config
|
file: config/dominant/sys.config
|
||||||
- name: vmConfig
|
- name: vmConfig
|
||||||
|
12
services/dominant/templates/initialization-configmap.yaml
Normal file
12
services/dominant/templates/initialization-configmap.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{{- if .Values.initializationTask.create -}}
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: "{{ include "dominant.fullname" . }}-init-task"
|
||||||
|
labels:
|
||||||
|
{{- include "dominant.labels" . | nindent 4 }}
|
||||||
|
data:
|
||||||
|
init-script: |
|
||||||
|
{{- .Values.initializationTask.script | nindent 4 }}
|
||||||
|
{{- end -}}
|
41
services/dominant/templates/initialization-hook.yaml
Normal file
41
services/dominant/templates/initialization-hook.yaml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{{- if .Values.initializationTask.create -}}
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: "{{ .Release.Name }}-initialization-task"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||||
|
app.kubernetes.io/version: {{ .Chart.AppVersion }}
|
||||||
|
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||||
|
annotations:
|
||||||
|
"helm.sh/hook": post-install
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
name: "{{ .Release.Name }}"
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name | quote }}
|
||||||
|
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||||
|
spec:
|
||||||
|
restartPolicy: Never
|
||||||
|
containers:
|
||||||
|
- name: dominant-init-job
|
||||||
|
image: "{{ .Values.initializationTask.repository }}:{{ .Values.initializationTask.tag }}"
|
||||||
|
command: ["{{ .Values.initializationTask.workdir }}/init-script"]
|
||||||
|
volumeMounts:
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: "{{ .Values.initializationTask.workdir }}/init-script"
|
||||||
|
subPath: init-script
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: "{{ include "dominant.fullname" . }}-init-task"
|
||||||
|
items:
|
||||||
|
- key: init-script
|
||||||
|
path: init-script
|
||||||
|
mode: 0755
|
||||||
|
{{- end -}}
|
13
services/dominant/templates/serviceaccount.yaml
Normal file
13
services/dominant/templates/serviceaccount.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{{- if .Values.serviceAccount.create -}}
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: {{ include "dominant.serviceAccountName" . }}
|
||||||
|
labels:
|
||||||
|
{{- include "dominant.labels" . | nindent 4 }}
|
||||||
|
{{- with .Values.serviceAccount.annotations }}
|
||||||
|
annotations:
|
||||||
|
{{- toYaml . | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
@ -5,6 +5,13 @@ image:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
name: dr2reg
|
name: dr2reg
|
||||||
|
|
||||||
|
initializationTask:
|
||||||
|
create: false
|
||||||
|
repository: dr2.rbkmoney.com/rbkmoney/holmes
|
||||||
|
tag: bfa6fc0428a75c9f179b89b9278ed1aedbb8b649
|
||||||
|
script: "#! /bin/sh"
|
||||||
|
workdir: /opt/holmes
|
||||||
|
|
||||||
nameOverride: ""
|
nameOverride: ""
|
||||||
fullnameOverride: ""
|
fullnameOverride: ""
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user