From 9f8d11a373712e006f351412550553221f830b9f Mon Sep 17 00:00:00 2001 From: alexvbg Date: Tue, 13 Sep 2022 18:18:16 +0200 Subject: [PATCH] Add ability to configure MysqlDB app via Options (#1633) * add options in MysqlDB constructor for being configurable from outside * change func name after review --- pkg/app/mysql.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/app/mysql.go b/pkg/app/mysql.go index 0d1fc49b4a..87d78d8b92 100644 --- a/pkg/app/mysql.go +++ b/pkg/app/mysql.go @@ -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), @@ -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 {