Skip to content

Commit

Permalink
Add ability to configure MysqlDB app via Options (#1633)
Browse files Browse the repository at this point in the history
* add options in MysqlDB constructor for being configurable from outside

* change func name after review
  • Loading branch information
alexvbg authored Sep 13, 2022
1 parent 5786c9d commit 9f8d11a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/app/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@ type MysqlDB struct {
chart helm.ChartInfo
}

type MysqlDBOptions func(*MysqlDB)

func MysqlDBChartValues(values map[string]string) MysqlDBOptions {
return func(db *MysqlDB) {
for k, v := range values {
db.chart.Values[k] = v
}
}
}

// Last tested working version "6.14.11"
func NewMysqlDB(name string) App {
return &MysqlDB{
func NewMysqlDB(name string, opts ...MysqlDBOptions) App {
m := MysqlDB{
name: name,
chart: helm.ChartInfo{
Release: appendRandString(name),
Expand All @@ -57,6 +67,10 @@ func NewMysqlDB(name string) App {
},
},
}
for _, opt := range opts {
opt(&m)
}
return &m
}

func (mdb *MysqlDB) Init(ctx context.Context) error {
Expand Down

0 comments on commit 9f8d11a

Please sign in to comment.