RestoreConfig populates targetConfigMap and targetSecret with values needed to restore a cluster from repositories defined in sourceConfigMap and sourceSecret.
( sourceConfigMap, targetConfigMap *corev1.ConfigMap, sourceSecret, targetSecret *corev1.Secret, )
| 498 | // RestoreConfig populates targetConfigMap and targetSecret with values needed |
| 499 | // to restore a cluster from repositories defined in sourceConfigMap and sourceSecret. |
| 500 | func RestoreConfig( |
| 501 | sourceConfigMap, targetConfigMap *corev1.ConfigMap, |
| 502 | sourceSecret, targetSecret *corev1.Secret, |
| 503 | ) { |
| 504 | initialize.Map(&targetConfigMap.Data) |
| 505 | |
| 506 | // Use the repository definitions from the source cluster. |
| 507 | // |
| 508 | // TODO(cbandy): This is the *entire* instance configuration from another |
| 509 | // cluster. For now, the stanza options are "pg1-path", "pg1-port", and |
| 510 | // "pg1-socket-path" and these are safe enough to use across different |
| 511 | // clusters running the same PostgreSQL version. When that list grows, |
| 512 | // consider changing this to use local stanza options and remote repository options. |
| 513 | targetConfigMap.Data[CMInstanceKey] = sourceConfigMap.Data[CMInstanceKey] |
| 514 | |
| 515 | if sourceSecret != nil && targetSecret != nil { |
| 516 | initialize.Map(&targetSecret.Data) |
| 517 | |
| 518 | // - https://golang.org/issue/45038 |
| 519 | bytesClone := func(b []byte) []byte { return append([]byte(nil), b...) } |
| 520 | |
| 521 | // Use the CA and client certificate from the source cluster. |
| 522 | for _, item := range clientCertificates() { |
| 523 | targetSecret.Data[item.Key] = bytesClone(sourceSecret.Data[item.Key]) |
| 524 | } |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | // Secret populates the pgBackRest Secret. |
| 529 | func Secret(ctx context.Context, |
no test coverage detected