@@ -163,7 +163,8 @@ func newFlagConfig(versionStr string) *basicTypeConfig {
163163 miniserverTimeout := flags .Int ("miniserverTimeout" , 0 , "Timeout for requests to the Miniserver" )
164164 flags .Parse (os .Args [1 :])
165165 if * versionFlag {
166- fmt .Printf ("Version: %s" , versionStr )
166+ fmt .Printf ("Version : %s\n " , versionStr )
167+ fmt .Printf ("Build for: %s\n " , buildForOS )
167168 os .Exit (0 )
168169 }
169170 cfg := newDefaultConfig ()
@@ -206,32 +207,20 @@ func newFlagConfig(versionStr string) *basicTypeConfig {
206207 return cfg
207208}
208209
209- // readConfigFiles tries to read a config file specified by filename.
210- // On success a slize of bytes containing the file content is returned.
211- // If filename is empty readConfigFile tries to read all default files.
212- // On success a byte string containing the content of the first file found is returned.
213- // On failure an empty slize of bytes is returned. Errors are ignored.
214210func readConfigFile (filename string ) (name string , f []byte , err error ) {
215- defaultConfigFiles := []string {
216- "/etc/loxwebhook/config.toml" ,
217- "./config.toml" ,
218- }
219- if filename != "" {
220- f , err = ioutil .ReadFile (filename )
221- if err != nil {
222- err = errors .Wrap (err , "Error reading config file" )
223- return
224- }
225- name = filename
226- return
227- }
228- for _ , fn := range defaultConfigFiles {
229- f , err = ioutil .ReadFile (fn )
211+ if filename == "" {
212+ f , err = ioutil .ReadFile (defaultConfigFile )
230213 if err == nil {
231- name = fn
232- break
214+ name = defaultConfigFile
233215 }
216+ // Ignore errors because we might get all nedded parameters
217+ // from flags and/or environment variables
234218 err = nil
219+ return
220+ }
221+ f , err = ioutil .ReadFile (filename )
222+ if err == nil {
223+ name = filename
235224 }
236225 return
237226}
0 commit comments