@@ -18,13 +18,14 @@ import (
18
18
)
19
19
20
20
const (
21
+ frogbotConfigDir = ".frogbot"
21
22
FrogbotConfigFile = "frogbot-config.yml"
22
23
)
23
24
24
25
var errFrogbotConfigNotFound = fmt .Errorf ("%s wasn't found in the Frogbot directory and its subdirectories. Assuming all the configuration is stored as environment variables" , FrogbotConfigFile )
25
26
26
27
// Possible Config file path's to Frogbot Management repository
27
- var frogbotConfigPath = filepath .Join (".frogbot" , FrogbotConfigFile )
28
+ var osFrogbotConfigPath = filepath .Join (frogbotConfigDir , FrogbotConfigFile )
28
29
29
30
type FrogbotConfigAggregator []FrogbotRepoConfig
30
31
@@ -142,7 +143,7 @@ func getFrogbotConfig(client vcsclient.VcsClient) (configData *FrogbotConfigAggr
142
143
}
143
144
// Read the config from the current working dir, if reading from the target branch failed
144
145
if targetConfigContent == nil && err == nil {
145
- configData , err = ReadConfigFromFileSystem (frogbotConfigPath )
146
+ configData , err = ReadConfigFromFileSystem (osFrogbotConfigPath )
146
147
}
147
148
148
149
return configData , err
@@ -294,7 +295,7 @@ func extractEnvParams() (*coreconfig.ServerDetails, Git, error) {
294
295
// ReadConfigFromFileSystem looks for .frogbot/frogbot-config.yml from the given path. The path is relatively from the root.
295
296
// If the config file is not found in the relative path, it will search in parent dirs.
296
297
func ReadConfigFromFileSystem (configRelativePath string ) (config * FrogbotConfigAggregator , err error ) {
297
- log .Debug ("Reading config from file system. Looking for" , frogbotConfigPath )
298
+ log .Debug ("Reading config from file system. Looking for" , osFrogbotConfigPath )
298
299
fullConfigDirPath , err := filepath .Abs (configRelativePath )
299
300
if err != nil {
300
301
return nil , err
@@ -398,24 +399,23 @@ func generateConfigAggregatorFromEnv(gitParams *Git, server *coreconfig.ServerDe
398
399
}
399
400
400
401
// downloadConfigFromTarget downloads the .frogbot/frogbot-config.yml from the target repository
401
- func downloadConfigFromTarget (client vcsclient.VcsClient ) ([]byte , error ) {
402
+ func downloadConfigFromTarget (client vcsclient.VcsClient ) (configContent []byte , err error ) {
402
403
var branch string
403
404
_ = readParamFromEnv (GitBaseBranchEnv , & branch )
404
405
var repo string
405
406
_ = readParamFromEnv (GitRepoEnv , & repo )
406
407
var owner string
407
408
_ = readParamFromEnv (GitRepoOwnerEnv , & owner )
408
- var configContent []byte
409
- var err error
410
409
var statusCode int
411
410
if repo != "" && owner != "" {
412
411
if branch == "" {
413
412
log .Debug (GitBaseBranchEnv , "is missing. Assuming that the" , FrogbotConfigFile , "file exists on default branch" )
414
413
}
415
414
log .Debug ("Downloading" , FrogbotConfigFile , "from target" , owner , "/" , repo , "/" , branch )
416
- configContent , statusCode , err = client .DownloadFileFromRepo (context .Background (), owner , repo , branch , frogbotConfigPath )
415
+ gitFrogbotConfigPath := fmt .Sprintf ("%s/%s" , frogbotConfigDir , FrogbotConfigFile )
416
+ configContent , statusCode , err = client .DownloadFileFromRepo (context .Background (), owner , repo , branch , gitFrogbotConfigPath )
417
417
if statusCode == http .StatusNotFound {
418
- log .Debug (frogbotConfigPath , "wasn't found on" , owner , "/" , repo )
418
+ log .Debug (gitFrogbotConfigPath , "wasn't found on" , owner , "/" , repo )
419
419
// If .frogbot/frogbot-config.yml isn't found, we'll try to run Frogbot using environment variables
420
420
return nil , & ErrMissingConfig {errFrogbotConfigNotFound .Error ()}
421
421
}
0 commit comments