fix: Update element chat config and defaults

- Update element chat default name to 'elementchat'
- Sanitize element chat name from invalid characters
- Set default namespace based on sanitized name
- Validate namespace for invalid characters
- Update documentation with new default values
This commit is contained in:
Mahmoud-Emad
2025-11-03 15:49:54 +02:00
parent 2e56311cd0
commit 8e5507b04e
3 changed files with 21 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ A Kubernetes installer for Element Chat (Matrix Conduit + Element Web) with TFGr
## Overview
This installer deploys a complete Matrix chat solution consisting of:
- **Conduit**: A lightweight Matrix homeserver implementation
- **Element Web**: A modern web client for Matrix
- **TFGW (ThreeFold Gateway)**: Provides public FQDNs with TLS termination
@@ -30,9 +31,9 @@ All configuration options are optional and have sensible defaults:
### Hostnames and Namespace
```v
installer.matrix_hostname = 'matrixchat' // Default: 'matrixchat'
installer.element_hostname = 'elementchat' // Default: 'elementchat'
installer.namespace = 'chat' // Default: 'chat'
installer.matrix_hostname = 'matrixchat' // Default: '${installer.name}matrix'
installer.element_hostname = 'elementchat' // Default: '${installer.name}element'
installer.namespace = 'chat-namespace' // Default: '${installer.name}-element-chat-namespace'
```
**Note**: Use only alphanumeric characters in hostnames (no underscores or dashes).

View File

@@ -30,7 +30,7 @@ pub mut:
@[heap]
pub struct ElementChat {
pub mut:
name string = 'element_chat'
name string = 'elementchat'
matrix_hostname string
element_hostname string
namespace string
@@ -55,8 +55,22 @@ pub mut:
fn obj_init(mycfg_ ElementChat) !ElementChat {
mut mycfg := mycfg_
if mycfg.name == '' {
mycfg.name = 'elementchat'
}
// Replace the dashes, dots, and underscores with nothing
mycfg.name = mycfg.name.replace('_', '')
mycfg.name = mycfg.name.replace('-', '')
mycfg.name = mycfg.name.replace('.', '')
if mycfg.namespace == '' {
mycfg.namespace = 'chat'
mycfg.namespace = '${mycfg.name}-element-chat-namespace'
}
if mycfg.namespace.contains('_') || mycfg.namespace.contains('.') {
console.print_stderr('namespace cannot contain _, was: ${mycfg.namespace}, use dashes instead.')
return error('namespace cannot contain _, was: ${mycfg.namespace}')
}
if mycfg.matrix_hostname == '' {