|
| 1 | +locals { |
| 2 | + output_attributes = lookup(var.instance.spec.source, "attributes", {}) |
| 3 | + |
| 4 | + # Pure passthrough of the referenced datastore's mongo contract. Absent fields |
| 5 | + # surface as null; when database_name is set, connection strings and the |
| 6 | + # logical name target that database (query params such as tls / replicaSet are |
| 7 | + # preserved by local.rewrite_db). |
| 8 | + output_interfaces = { |
| 9 | + writer = { |
| 10 | + host = lookup(local.writer, "host", null) |
| 11 | + port = lookup(local.writer, "port", null) |
| 12 | + username = lookup(local.writer, "username", null) |
| 13 | + password = lookup(local.writer, "password", null) |
| 14 | + connection_string = local.rewrite_db["writer"] |
| 15 | + name = local.has_database ? local.database_name : lookup(local.writer, "name", null) |
| 16 | + secrets = lookup(local.writer, "secrets", ["password", "connection_string"]) |
| 17 | + } |
| 18 | + reader = { |
| 19 | + host = lookup(local.reader, "host", null) |
| 20 | + port = lookup(local.reader, "port", null) |
| 21 | + username = lookup(local.reader, "username", null) |
| 22 | + password = lookup(local.reader, "password", null) |
| 23 | + connection_string = local.rewrite_db["reader"] |
| 24 | + name = local.has_database ? local.database_name : lookup(local.reader, "name", null) |
| 25 | + secrets = lookup(local.reader, "secrets", ["password", "connection_string"]) |
| 26 | + } |
| 27 | + cluster = { |
| 28 | + endpoint = lookup(local.cluster, "endpoint", null) |
| 29 | + username = lookup(local.cluster, "username", null) |
| 30 | + password = lookup(local.cluster, "password", null) |
| 31 | + connection_string = local.rewrite_db["cluster"] |
| 32 | + secrets = lookup(local.cluster, "secrets", ["password", "connection_string"]) |
| 33 | + } |
| 34 | + } |
| 35 | +} |
0 commit comments