Skip to content

Commit 39990d1

Browse files
Merge pull request loft-sh#1226 from janekbaraniewski/POD-768/update-exposed-devcontainer-util-funcs
POD-768 | Update devcontainer helper funcs
2 parents 0d36cf8 + 1fd266d commit 39990d1

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pkg/devcontainer/helpers.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ type GetWorkspaceConfigResult struct {
2222
}
2323

2424
func FindDevcontainerFiles(ctx context.Context, rawSource, tmpDirPath string, maxDepth int, log log.Logger) (*GetWorkspaceConfigResult, error) {
25-
result := &GetWorkspaceConfigResult{ConfigPaths: []string{}}
26-
2725
// local path
2826
isLocalPath, _ := file.IsLocalDir(rawSource)
2927
if isLocalPath {
30-
return FindFilesInLocalDir(result, rawSource, maxDepth, log)
28+
return FindFilesInLocalDir(rawSource, maxDepth, log)
3129
}
3230

3331
// git repo
3432
gitRepository, gitPRReference, gitBranch, gitCommit, gitSubDir := git.NormalizeRepository(rawSource)
3533
if strings.HasSuffix(rawSource, ".git") || git.PingRepository(gitRepository) {
3634
log.Debug("Git repository detected")
37-
return FindFilesInGitRepo(ctx, result, gitRepository, gitPRReference, gitBranch, gitCommit, gitSubDir, tmpDirPath, maxDepth, log)
35+
return FindFilesInGitRepo(ctx, gitRepository, gitPRReference, gitBranch, gitCommit, gitSubDir, tmpDirPath, maxDepth, log)
3836
}
3937

38+
result := &GetWorkspaceConfigResult{ConfigPaths: []string{}}
39+
4040
// container image
4141
_, err := image.GetImage(ctx, rawSource)
4242
if err == nil {
@@ -50,8 +50,9 @@ func FindDevcontainerFiles(ctx context.Context, rawSource, tmpDirPath string, ma
5050
return result, nil
5151
}
5252

53-
func FindFilesInLocalDir(result *GetWorkspaceConfigResult, rawSource string, maxDepth int, log log.Logger) (*GetWorkspaceConfigResult, error) {
53+
func FindFilesInLocalDir(rawSource string, maxDepth int, log log.Logger) (*GetWorkspaceConfigResult, error) {
5454
log.Debug("Local directory detected")
55+
result := &GetWorkspaceConfigResult{ConfigPaths: []string{}}
5556
result.IsLocal = true
5657
initialDepth := strings.Count(rawSource, string(filepath.Separator))
5758
err := filepath.WalkDir(rawSource, func(path string, info fs.DirEntry, err error) error {
@@ -81,8 +82,11 @@ func FindFilesInLocalDir(result *GetWorkspaceConfigResult, rawSource string, max
8182
return result, nil
8283
}
8384

84-
func FindFilesInGitRepo(ctx context.Context, result *GetWorkspaceConfigResult, gitRepository, gitPRReference, gitBranch, gitCommit, gitSubDir, tmpDirPath string, maxDepth int, log log.Logger) (*GetWorkspaceConfigResult, error) {
85-
result.IsGitRepository = true
85+
func FindFilesInGitRepo(ctx context.Context, gitRepository, gitPRReference, gitBranch, gitCommit, gitSubDir, tmpDirPath string, maxDepth int, log log.Logger) (*GetWorkspaceConfigResult, error) {
86+
result := &GetWorkspaceConfigResult{
87+
ConfigPaths: []string{},
88+
IsGitRepository: true,
89+
}
8690

8791
gitInfo := git.NewGitInfo(gitRepository, gitBranch, gitCommit, gitPRReference, gitSubDir)
8892
log.Debugf("Cloning git repository into %s", tmpDirPath)

0 commit comments

Comments
 (0)