handle psql style pg connection strings

pull/99/head
James Batt 4 years ago
parent 2e7dbf79d3
commit 3ff9c1a6de

@ -8,7 +8,11 @@ metadata:
spec:
replicas: 1
strategy:
type: "{{ .Values.strategy.type }}"
{{- if .Values.persistence.enabled }}
type: {{ .Values.strategy.type | default "Recreate" | quote }}
{{- else }}
type: {{ .Values.strategy.type | default "RollingUpdate" | quote }}
{{- end }}
selector:
matchLabels:
{{- include "wg-access-server.selectorLabels" . | nindent 6 }}

@ -53,8 +53,14 @@ image:
repository: place1/wg-access-server
pullPolicy: IfNotPresent
strategy:
type: Recreate
# multiple replicas is only supported when using
# a supported highly-available storage backend (i.e. postgresql)
replicas: 1
strategy: {}
# the deployment strategy type will default to "Recreate" when persistence is enabled
# or "RollingUpdate" when persistence is not enabled.
# type: Recreate
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious

@ -40,7 +40,7 @@ and is the recommended storage backend where possible.
Example connection string:
- `postgres://user:password@localhost:5432/database?sslmode=disable`
- `postgresql://user:password@localhost:5432/database?sslmode=disable`
### Mysql
@ -84,13 +84,13 @@ If you need to do the above within a kubernetes deployment substitute `docker ex
The migrate command is non-destructive but it's always a good idea to take a backup of your data first!
### Example: `sqlite3://` to `postgres://`
### Example: `sqlite3://` to `postgresql://`
First you'll need to make sure your postgres server is up and that you can connect to it from your
wg-access-server container/pod/vm.
```bash
wg-access-server migrate sqlite3:///data/db.sqlite3 postgres://user:password@localhost:5432/database?sslmode=disable
wg-access-server migrate sqlite3:///data/db.sqlite3 postgresql://user:password@localhost:5432/database?sslmode=disable
```
Remember to update your wg-access-server config to connect to postgres 😀

@ -23,7 +23,7 @@ type AppConfig struct {
ExternalHost string `yaml:"externalHost"`
// The storage backend where device configuration will
// be persisted.
// Supports memory:// postgres:// mysql:// sqlite3://
// Supports memory:// postgresql:// mysql:// sqlite3://
// Defaults to memory://
Storage string `yaml:"storage"`
// DisableMetadata allows you to turn off collection of device

@ -60,6 +60,8 @@ func NewStorage(uri string) (Storage, error) {
case "memory":
logrus.Warn("storing data in memory - devices will not persist between restarts")
return NewMemoryStorage(), nil
case "postgresql":
fallthrough
case "postgres":
fallthrough
case "mysql":

@ -18,7 +18,7 @@ func TestMemoryStorage(t *testing.T) {
func TestPostgresqlStorage(t *testing.T) {
require := require.New(t)
s, err := NewStorage("postgres://localhost:5432/dbname?sslmode=disable")
s, err := NewStorage("postgresql://localhost:5432/dbname?sslmode=disable")
require.NoError(err)
require.IsType(&SQLStorage{}, s)

@ -47,6 +47,11 @@ func NewSqlStorage(u *url.URL) *SQLStorage {
var connectionString string
switch u.Scheme {
case "postgresql":
// handle `postgresql` as the scheme to be compatible with
// standar uri style postgresql connection strings (i.e. like psql)
u.Scheme = "postgres"
fallthrough
case "postgres":
connectionString = pgconn(u)
case "mysql":

Loading…
Cancel
Save