@@ -43,14 +43,14 @@ func NewConfig(dataDir string) *Config {
4343 }
4444}
4545
46- // Print will output the local configuration data to stdout.
46+ // Print outputs the interna/user config to stdout.
4747func (c * Config ) Print (w io.Writer ) error {
48- internalCfg , err := c .pullFromConfig (c .internalConfigFilePath )
48+ internalCfg , err := c .pullFromFile (c .internalConfigFilePath )
4949 if err != nil {
5050 return fmt .Errorf ("failed to read internal config: %s" , err )
5151 }
5252
53- userCfg , err := c .pullFromConfig (c .userConfigFilePath )
53+ userCfg , err := c .pullFromFile (c .userConfigFilePath )
5454 if err != nil {
5555 return fmt .Errorf ("failed to read internal config: %s" , err )
5656 }
@@ -71,8 +71,8 @@ func (c *Config) Print(w io.Writer) error {
7171 return e .Encode (cfg )
7272}
7373
74- // Setup will ensure the required configuration files are created and that the parent
75- // postgresql.conf file is including them.
74+ // Setup will ensure the required configuration files are stubbed and the parent
75+ // postgresql.conf file includes them.
7676func (c Config ) Setup () error {
7777 if _ , err := os .Stat (c .internalConfigFilePath ); err != nil {
7878 if os .IsNotExist (err ) {
@@ -145,8 +145,7 @@ func (c Config) WriteDefaults() error {
145145 "shared_preload_libraries" : "repmgr" ,
146146 }
147147
148- // Write configuration to local file.
149- if err := c .writeToConfig (c .internalConfigFilePath , conf ); err != nil {
148+ if err := c .writeToFile (c .internalConfigFilePath , conf ); err != nil {
150149 return fmt .Errorf ("failed to write to pg config file: %s" , err )
151150 }
152151
@@ -160,8 +159,7 @@ func (c Config) WriteUserConfig(ctx context.Context, conn *pgx.Conn, consul *sta
160159 return fmt .Errorf ("failed to write to consul: %s" , err )
161160 }
162161
163- // Write configuration to local file.
164- if err := c .writeToConfig (c .userConfigFilePath , cfg ); err != nil {
162+ if err := c .writeToFile (c .userConfigFilePath , cfg ); err != nil {
165163 return fmt .Errorf ("failed to write to pg config file: %s" , err )
166164 }
167165 }
@@ -172,14 +170,12 @@ func (c Config) WriteUserConfig(ctx context.Context, conn *pgx.Conn, consul *sta
172170// SyncUserConfig will pull the latest user-defined configuration data from Consul and
173171// write it to the user config file.
174172func (c Config ) SyncUserConfig (ctx context.Context , consul * state.ConsulClient ) error {
175- // Apply Consul configuration.
176- cfg , err := c .pullConfigFromConsul (consul )
173+ cfg , err := c .pullFromConsul (consul )
177174 if err != nil {
178175 return fmt .Errorf ("failed to pull config from consul: %s" , err )
179176 }
180177
181- // Write configuration to local file.
182- if err := c .writeToConfig (c .userConfigFilePath , cfg ); err != nil {
178+ if err := c .writeToFile (c .userConfigFilePath , cfg ); err != nil {
183179 return fmt .Errorf ("failed to write to pg config file: %s" , err )
184180 }
185181
@@ -214,8 +210,8 @@ func (c Config) pushToConsul(consul *state.ConsulClient, conf PGConfig) error {
214210 return nil
215211}
216212
217- func (c Config ) writeToConfig ( pathToConfig string , conf PGConfig ) error {
218- file , err := os .OpenFile (pathToConfig , os .O_CREATE | os .O_RDWR | os .O_TRUNC , 0644 )
213+ func (c Config ) writeToFile ( pathToFile string , conf PGConfig ) error {
214+ file , err := os .OpenFile (pathToFile , os .O_CREATE | os .O_RDWR | os .O_TRUNC , 0644 )
219215 if err != nil {
220216 return err
221217 }
@@ -229,7 +225,7 @@ func (c Config) writeToConfig(pathToConfig string, conf PGConfig) error {
229225 return nil
230226}
231227
232- func (c Config ) pullFromConfig (pathToFile string ) (PGConfig , error ) {
228+ func (c Config ) pullFromFile (pathToFile string ) (PGConfig , error ) {
233229 file , err := os .Open (pathToFile )
234230 if err != nil {
235231 return nil , err
@@ -248,7 +244,7 @@ func (c Config) pullFromConfig(pathToFile string) (PGConfig, error) {
248244 return pgConf , nil
249245}
250246
251- func (c Config ) pullConfigFromConsul (consul * state.ConsulClient ) (PGConfig , error ) {
247+ func (c Config ) pullFromConsul (consul * state.ConsulClient ) (PGConfig , error ) {
252248 configBytes , err := consul .PullUserConfig ()
253249 if err != nil {
254250 return nil , err
0 commit comments