diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-08-31 10:41:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-31 10:41:32 +0100 |
commit | ba0b3adab4de7865afd467b61638437b1af39fce (patch) | |
tree | 4330451062846ebf6718ac3695ea61b59739cd0f /setup | |
parent | 02ec00b1bbeb43f68a4f9b1f19ee6282e4a34194 (diff) |
Pinecone standalone refactoring (#2685)
This refactors the `dendrite-demo-pinecone` executable so that it:
1. Converts the old `.key` file into a standard `.pem` file
2. Allows passing in the `--config` option to supply a normal Dendrite configuration file, so that you can configure PostgreSQL instead of SQLite, appservices and all the other usual stuff
Diffstat (limited to 'setup')
-rw-r--r-- | setup/config/config.go | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/setup/config/config.go b/setup/config/config.go index 924b51f2..cc9c0447 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -224,12 +224,7 @@ func loadConfig( } privateKeyPath := absPath(basePath, c.Global.PrivateKeyPath) - privateKeyData, err := readFile(privateKeyPath) - if err != nil { - return nil, err - } - - if c.Global.KeyID, c.Global.PrivateKey, err = readKeyPEM(privateKeyPath, privateKeyData, true); err != nil { + if c.Global.KeyID, c.Global.PrivateKey, err = LoadMatrixKey(privateKeyPath, readFile); err != nil { return nil, err } @@ -265,6 +260,14 @@ func loadConfig( return &c, nil } +func LoadMatrixKey(privateKeyPath string, readFile func(string) ([]byte, error)) (gomatrixserverlib.KeyID, ed25519.PrivateKey, error) { + privateKeyData, err := readFile(privateKeyPath) + if err != nil { + return "", nil, err + } + return readKeyPEM(privateKeyPath, privateKeyData, true) +} + // Derive generates data that is derived from various values provided in // the config file. func (config *Dendrite) Derive() error { |