|
| 1 | +{{- $artifactSource := default "generated" .Values.artifacts.source -}} |
| 2 | +{{- if eq $artifactSource "external" }} |
| 3 | +{{- $root := . -}} |
| 4 | +{{- $external := .Values.artifacts.external | default (dict) -}} |
| 5 | +{{- $genesis := get $external "genesis" -}} |
| 6 | +{{- $staticNodes := get $external "staticNodes" -}} |
| 7 | +{{- $validators := get $external "validators" -}} |
| 8 | +{{- $faucet := get $external "faucet" -}} |
| 9 | +{{- $validatorCount := len $validators -}} |
| 10 | +{{- if not $genesis }}{{ fail "artifacts.external.genesis must be provided when artifacts.source is 'external'." }}{{- end }} |
| 11 | +{{- if not $staticNodes }}{{ fail "artifacts.external.staticNodes must include at least one enode when artifacts.source is 'external'." }}{{- end }} |
| 12 | +{{- if not $validators }}{{ fail "artifacts.external.validators must include at least one entry when artifacts.source is 'external'." }}{{- end }} |
| 13 | +{{- if not ($faucet.address) }}{{ fail "artifacts.external.faucet.address must be set when artifacts.source is 'external'." }}{{- end }} |
| 14 | +{{- if not ($faucet.publicKey) }}{{ fail "artifacts.external.faucet.publicKey must be set when artifacts.source is 'external'." }}{{- end }} |
| 15 | +{{- if not ($faucet.privateKey) }}{{ fail "artifacts.external.faucet.privateKey must be set when artifacts.source is 'external'." }}{{- end }} |
| 16 | +{{- $globalValues := default (dict) .Values.global -}} |
| 17 | +{{- $globalReplicaCount := -1 -}} |
| 18 | +{{- if and (kindIs "map" $globalValues) (hasKey $globalValues "network") -}} |
| 19 | + {{- $networkGlobal := index $globalValues "network" -}} |
| 20 | + {{- if and (kindIs "map" $networkGlobal) (hasKey $networkGlobal "validatorReplicaCount") -}} |
| 21 | + {{- $globalReplicaCount = (index $networkGlobal "validatorReplicaCount" | int) -}} |
| 22 | + {{- end -}} |
| 23 | +{{- end -}} |
| 24 | +{{- if and (eq $globalReplicaCount -1) (kindIs "map" $globalValues) (hasKey $globalValues "validatorReplicaCount") -}} |
| 25 | + {{- $globalReplicaCount = (index $globalValues "validatorReplicaCount" | int) -}} |
| 26 | +{{- end -}} |
| 27 | +{{- if eq $globalReplicaCount -1 -}} |
| 28 | + {{- fail (printf "artifacts.external.validators has %d entries. Set global.validatorReplicaCount (or global.network.validatorReplicaCount) to this value and align network-nodes.validatorReplicaCount." $validatorCount) -}} |
| 29 | +{{- end -}} |
| 30 | +{{- if ne $globalReplicaCount $validatorCount -}} |
| 31 | + {{- fail (printf "artifacts.external.validators has %d entries but the configured validator replica count is %d. Update global.validatorReplicaCount (or global.network.validatorReplicaCount) and network-nodes.validatorReplicaCount to match." $validatorCount $globalReplicaCount) -}} |
| 32 | +{{- end -}} |
| 33 | +apiVersion: v1 |
| 34 | +kind: ConfigMap |
| 35 | +metadata: |
| 36 | + name: besu-genesis |
| 37 | + labels: |
| 38 | + {{- include "network-bootstrapper.labels" . | nindent 4 }} |
| 39 | +data: |
| 40 | + genesis.json: |- |
| 41 | +{{ toPrettyJson $genesis | indent 4 }} |
| 42 | +--- |
| 43 | +apiVersion: v1 |
| 44 | +kind: ConfigMap |
| 45 | +metadata: |
| 46 | + name: besu-static-nodes |
| 47 | + labels: |
| 48 | + {{- include "network-bootstrapper.labels" . | nindent 4 }} |
| 49 | +data: |
| 50 | + static-nodes.json: |- |
| 51 | +{{ toPrettyJson $staticNodes | indent 4 }} |
| 52 | +{{- range $index, $validator := $validators }} |
| 53 | +{{- $requiredAddress := required (printf "artifacts.external.validators[%d].address must be set." $index) $validator.address }} |
| 54 | +{{- $requiredPublicKey := required (printf "artifacts.external.validators[%d].publicKey must be set." $index) $validator.publicKey }} |
| 55 | +{{- $requiredPrivateKey := required (printf "artifacts.external.validators[%d].privateKey must be set." $index) $validator.privateKey }} |
| 56 | +{{- $requiredEnode := required (printf "artifacts.external.validators[%d].enode must be set." $index) $validator.enode }} |
| 57 | +--- |
| 58 | +apiVersion: v1 |
| 59 | +kind: ConfigMap |
| 60 | +metadata: |
| 61 | + name: {{ printf "besu-node-validator-%d-address" $index }} |
| 62 | + labels: |
| 63 | + {{- include "network-bootstrapper.labels" $root | nindent 4 }} |
| 64 | +data: |
| 65 | + address: {{ $requiredAddress | quote }} |
| 66 | +--- |
| 67 | +apiVersion: v1 |
| 68 | +kind: ConfigMap |
| 69 | +metadata: |
| 70 | + name: {{ printf "besu-node-validator-%d-enode" $index }} |
| 71 | + labels: |
| 72 | + {{- include "network-bootstrapper.labels" $root | nindent 4 }} |
| 73 | +data: |
| 74 | + enode: {{ $requiredEnode | quote }} |
| 75 | +--- |
| 76 | +apiVersion: v1 |
| 77 | +kind: ConfigMap |
| 78 | +metadata: |
| 79 | + name: {{ printf "besu-node-validator-%d-pubkey" $index }} |
| 80 | + labels: |
| 81 | + {{- include "network-bootstrapper.labels" $root | nindent 4 }} |
| 82 | +data: |
| 83 | + publicKey: {{ $requiredPublicKey | quote }} |
| 84 | +--- |
| 85 | +apiVersion: v1 |
| 86 | +kind: Secret |
| 87 | +metadata: |
| 88 | + name: {{ printf "besu-node-validator-%d-private-key" $index }} |
| 89 | + labels: |
| 90 | + {{- include "network-bootstrapper.labels" $root | nindent 4 }} |
| 91 | +type: Opaque |
| 92 | +stringData: |
| 93 | + privateKey: {{ $requiredPrivateKey | quote }} |
| 94 | +{{- end }} |
| 95 | +--- |
| 96 | +apiVersion: v1 |
| 97 | +kind: ConfigMap |
| 98 | +metadata: |
| 99 | + name: besu-faucet-address |
| 100 | + labels: |
| 101 | + {{- include "network-bootstrapper.labels" . | nindent 4 }} |
| 102 | +data: |
| 103 | + address: {{ $faucet.address | quote }} |
| 104 | +--- |
| 105 | +apiVersion: v1 |
| 106 | +kind: ConfigMap |
| 107 | +metadata: |
| 108 | + name: besu-faucet-pubkey |
| 109 | + labels: |
| 110 | + {{- include "network-bootstrapper.labels" . | nindent 4 }} |
| 111 | +data: |
| 112 | + publicKey: {{ $faucet.publicKey | quote }} |
| 113 | +--- |
| 114 | +apiVersion: v1 |
| 115 | +kind: Secret |
| 116 | +metadata: |
| 117 | + name: besu-faucet-private-key |
| 118 | + labels: |
| 119 | + {{- include "network-bootstrapper.labels" . | nindent 4 }} |
| 120 | +type: Opaque |
| 121 | +stringData: |
| 122 | + privateKey: {{ $faucet.privateKey | quote }} |
| 123 | +{{- end }} |
0 commit comments