Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
issue #32: add postgresql support
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Aug 28, 2020
1 parent 3b724a9 commit 2924bac
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
31 changes: 30 additions & 1 deletion internal/model/merge.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package model

import "sort"
import (
"sort"
)

func (app *Application) Merge(apps ...Application) {
if app == nil {
Expand Down Expand Up @@ -132,6 +134,28 @@ func (logger *Logger) Merge(src *Logger) {
}
}

func (postgres *PostgreSQL) Merge(src *PostgreSQL) {
if postgres == nil || src == nil {
return
}

if src.Version != "" {
postgres.Version = src.Version
}
if src.Size != "" {
postgres.Size = src.Size
}
if src.Enabled != nil {
postgres.Enabled = src.Enabled
}
if src.OwnName != nil {
postgres.OwnName = src.OwnName
}
if src.Fixtures != nil {
postgres.Fixtures = src.Fixtures
}
}

func (proxies *Proxies) Merge(src Proxies) {
if proxies == nil || len(src) == 0 {
return
Expand Down Expand Up @@ -248,6 +272,11 @@ func (spec *Specification) Merge(src *Specification) {
}
spec.Balancing.Merge(src.Balancing)

if src.PostgreSQL != nil && spec.PostgreSQL == nil {
spec.PostgreSQL = new(PostgreSQL)
}
spec.PostgreSQL.Merge(src.PostgreSQL)

if src.SFTP != nil && spec.SFTP == nil {
spec.SFTP = new(SFTP)
}
Expand Down
9 changes: 9 additions & 0 deletions internal/model/specification.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ type Logger struct {
Level string `toml:"level,omitempty"`
}

type PostgreSQL struct {
Version string `toml:"version,omitempty"`
Size string `toml:"size,omitempty"`
Enabled *bool `toml:"enabled,omitempty"`
OwnName *bool `toml:"use_own_maintenance_table_name,omitempty"`
Fixtures *bool `toml:"fixtures_enabled,omitempty"`
}

type Proxy struct {
Name string `toml:"name,omitempty"`
Enabled *bool `toml:"enabled,omitempty"`
Expand Down Expand Up @@ -126,6 +134,7 @@ type Specification struct {
Engine *Engine `toml:"engine,omitempty"`
Logger *Logger `toml:"logger,omitempty"`
Balancing *Balancing `toml:"balancing,omitempty"`
PostgreSQL *PostgreSQL `toml:"postgresql,omitempty"`
SFTP *SFTP `toml:"sftp,omitempty"`
Crons Crons `toml:"crons,omitepmty"`
Dependencies Dependencies `toml:"dependencies,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions internal/model/testdata/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ replicas = 1
[logger]
level = "info"

[postgresql]
enabled = true
fixtures_enabled = false
size = "medium"
use_own_maintenance_table_name = false
version = "9.6"

[[proxy]]
enabled = true
name = "s3"
Expand Down
7 changes: 7 additions & 0 deletions internal/model/testdata/components/storages/postgresql.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[postgresql]
enabled = true
size = "medium"
version = "9.6"

use_own_maintenance_table_name = false
fixtures_enabled = false

0 comments on commit 2924bac

Please sign in to comment.