Skip to content

Commit 463055f

Browse files
authored
Fix resolving frogbot-config.yml file on Windows (#243)
1 parent eb62342 commit 463055f

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

commands/utils/params.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ import (
1818
)
1919

2020
const (
21+
frogbotConfigDir = ".frogbot"
2122
FrogbotConfigFile = "frogbot-config.yml"
2223
)
2324

2425
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)
2526

2627
// Possible Config file path's to Frogbot Management repository
27-
var frogbotConfigPath = filepath.Join(".frogbot", FrogbotConfigFile)
28+
var osFrogbotConfigPath = filepath.Join(frogbotConfigDir, FrogbotConfigFile)
2829

2930
type FrogbotConfigAggregator []FrogbotRepoConfig
3031

@@ -142,7 +143,7 @@ func getFrogbotConfig(client vcsclient.VcsClient) (configData *FrogbotConfigAggr
142143
}
143144
// Read the config from the current working dir, if reading from the target branch failed
144145
if targetConfigContent == nil && err == nil {
145-
configData, err = ReadConfigFromFileSystem(frogbotConfigPath)
146+
configData, err = ReadConfigFromFileSystem(osFrogbotConfigPath)
146147
}
147148

148149
return configData, err
@@ -294,7 +295,7 @@ func extractEnvParams() (*coreconfig.ServerDetails, Git, error) {
294295
// ReadConfigFromFileSystem looks for .frogbot/frogbot-config.yml from the given path. The path is relatively from the root.
295296
// If the config file is not found in the relative path, it will search in parent dirs.
296297
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)
298299
fullConfigDirPath, err := filepath.Abs(configRelativePath)
299300
if err != nil {
300301
return nil, err
@@ -398,24 +399,23 @@ func generateConfigAggregatorFromEnv(gitParams *Git, server *coreconfig.ServerDe
398399
}
399400

400401
// 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) {
402403
var branch string
403404
_ = readParamFromEnv(GitBaseBranchEnv, &branch)
404405
var repo string
405406
_ = readParamFromEnv(GitRepoEnv, &repo)
406407
var owner string
407408
_ = readParamFromEnv(GitRepoOwnerEnv, &owner)
408-
var configContent []byte
409-
var err error
410409
var statusCode int
411410
if repo != "" && owner != "" {
412411
if branch == "" {
413412
log.Debug(GitBaseBranchEnv, "is missing. Assuming that the", FrogbotConfigFile, "file exists on default branch")
414413
}
415414
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)
417417
if statusCode == http.StatusNotFound {
418-
log.Debug(frogbotConfigPath, "wasn't found on", owner, "/", repo)
418+
log.Debug(gitFrogbotConfigPath, "wasn't found on", owner, "/", repo)
419419
// If .frogbot/frogbot-config.yml isn't found, we'll try to run Frogbot using environment variables
420420
return nil, &ErrMissingConfig{errFrogbotConfigNotFound.Error()}
421421
}

go.mod

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ go 1.19
55
require (
66
github.com/go-git/go-git/v5 v5.5.1
77
github.com/golang/mock v1.6.0
8-
github.com/jfrog/build-info-go v1.8.6
8+
github.com/jfrog/build-info-go v1.8.7
99
github.com/jfrog/froggit-go v1.5.5
1010
github.com/jfrog/gofrog v1.2.5
11-
github.com/jfrog/jfrog-cli-core/v2 v2.29.2
12-
github.com/jfrog/jfrog-client-go v1.26.1
11+
github.com/jfrog/jfrog-cli-core/v2 v2.29.4
12+
github.com/jfrog/jfrog-client-go v1.26.2
1313
github.com/mholt/archiver/v3 v3.5.1
1414
github.com/pkg/errors v0.9.1
1515
github.com/stretchr/testify v1.8.1

go.sum

+6-6
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,16 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i
208208
github.com/jedib0t/go-pretty/v6 v6.4.3 h1:2n9BZ0YQiXGESUSR+6FLg0WWWE80u+mIz35f0uHWcIE=
209209
github.com/jedib0t/go-pretty/v6 v6.4.3/go.mod h1:MgmISkTWDSFu0xOqiZ0mKNntMQ2mDgOcwOkwBEkMDJI=
210210
github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4=
211-
github.com/jfrog/build-info-go v1.8.6 h1:N627DBFIQvx1fbvkaRfsBvgQ74aim9i8A+b2QX0Aulo=
212-
github.com/jfrog/build-info-go v1.8.6/go.mod h1:iSTj26qEX3eUtyAGMH0qKsW4WJT+MceYxLWP9FfiAq4=
211+
github.com/jfrog/build-info-go v1.8.7 h1:a9aGDs5ROWcTbWP6xjmutf+yporTpEPG7lVlRnQa714=
212+
github.com/jfrog/build-info-go v1.8.7/go.mod h1:iSTj26qEX3eUtyAGMH0qKsW4WJT+MceYxLWP9FfiAq4=
213213
github.com/jfrog/froggit-go v1.5.5 h1:fRjYd7SKTKZV+lnSAEFZSfltWkQKNDxScOT/iCC2KYA=
214214
github.com/jfrog/froggit-go v1.5.5/go.mod h1:KOJN88vwiYz+5kYufC1idMaa2G48XoRMas6l6G7sQfE=
215215
github.com/jfrog/gofrog v1.2.5 h1:jCgJC0iGQ8bU7jCC+YEFJTNINyngApIrhd8BjZAVRIE=
216216
github.com/jfrog/gofrog v1.2.5/go.mod h1:o00tSRff6IapTgaCMuX1Cs9MH08Y1JqnsKgRtx91Gc4=
217-
github.com/jfrog/jfrog-cli-core/v2 v2.29.2 h1:woz24oNwiPPCxFOtkp9hcA/Wd2IOks7St9ITZCogAHc=
218-
github.com/jfrog/jfrog-cli-core/v2 v2.29.2/go.mod h1:L0y88qAKMWaZFwc/gri50ylEDpjwUtPuXUYpGdvjAP4=
219-
github.com/jfrog/jfrog-client-go v1.26.1 h1:Vu8bHgpIG4t0TTl30x24lrRrP84Othp7YQwXF5YHjLY=
220-
github.com/jfrog/jfrog-client-go v1.26.1/go.mod h1:q+QWoyufy21pXTzF+c6ddbuEj16AxCTFe/yrvnVzor0=
217+
github.com/jfrog/jfrog-cli-core/v2 v2.29.4 h1:pqrCySCWaacMIAXYaGfAz3ySEHPQiZOZwVbqH5cplOA=
218+
github.com/jfrog/jfrog-cli-core/v2 v2.29.4/go.mod h1:HeW+Zaq7w7VpZbS+wsNnB9Kqy5KfkoaQ1ASxAwnBAYw=
219+
github.com/jfrog/jfrog-client-go v1.26.2 h1:UHijddbkdgmZ/zzbpFX8YJFtvaaGWya8gy/vtERjl0M=
220+
github.com/jfrog/jfrog-client-go v1.26.2/go.mod h1:+NW2Wvtt3vssM3dgw7d1TJ8l+rHl0rILujE8neUllhw=
221221
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
222222
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
223223
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=

0 commit comments

Comments
 (0)