@@ -14,6 +14,7 @@ import (
14
14
"github.com/pkg/errors"
15
15
16
16
"gitlab.com/postgres-ai/database-lab/pkg/log"
17
+ "gitlab.com/postgres-ai/database-lab/pkg/retrieval/engine/postgres/tools/fs"
17
18
"gitlab.com/postgres-ai/database-lab/pkg/util"
18
19
)
19
20
@@ -109,10 +110,6 @@ func (c Corrector) Run(dataDir string) error {
109
110
}
110
111
}
111
112
112
- for configKey , configValue := range c .ExtraConfig {
113
- pgConfDstLines = append (pgConfDstLines , fmt .Sprintf ("%s = '%s'" , configKey , configValue ))
114
- }
115
-
116
113
output := strings .Join (pgConfDstLines , "\n " )
117
114
118
115
if err := ioutil .WriteFile (pgConfDst , []byte (output ), 0644 ); err != nil {
@@ -121,3 +118,23 @@ func (c Corrector) Run(dataDir string) error {
121
118
122
119
return nil
123
120
}
121
+
122
+ // ApplyExtraConf applies extra configuration to the provided Postgres directory.
123
+ func (c Corrector ) ApplyExtraConf (dataDir string ) error {
124
+ log .Dbg ("Applying extra configuration" )
125
+
126
+ pgConf := path .Join (dataDir , pgConfName )
127
+ pgConfLines := make ([]string , 0 , len (c .ExtraConfig ))
128
+
129
+ for configKey , configValue := range c .ExtraConfig {
130
+ pgConfLines = append (pgConfLines , fmt .Sprintf ("%s = '%s'" , configKey , configValue ))
131
+ }
132
+
133
+ output := strings .Join (pgConfLines , "\n " )
134
+
135
+ if err := fs .AppendFile (pgConf , []byte (output )); err != nil {
136
+ return errors .Wrapf (err , "cannot write extra configuration to %s" , pgConf )
137
+ }
138
+
139
+ return nil
140
+ }
0 commit comments