Skip to content

Commit 0f08341

Browse files
committed
Make path determination more resilient w.r.t. including pipeline id or not
1 parent 0ff08a4 commit 0f08341

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

components/datadog/agent/package.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@ func GetPackagePath(localPath string, flavor tifos.Flavor, agentFlavor string, a
5757
packagePath := localPath
5858
matches := []string{}
5959
if pathInfo.IsDir() {
60-
packagePath = path.Join(packagePath, subFolder)
61-
packagePath = path.Join(packagePath, "pkg")
62-
if flavor == tifos.WindowsServer {
63-
packagePath = path.Join(packagePath, "pipeline-"+pipelineID)
60+
packagePath = path.Join(packagePath, subFolder, "pkg")
61+
62+
// If a dedicated pipeline-identified folder is available, use that
63+
packagePathWithPipelineID := path.Join(packagePath, "pipeline-"+pipelineID)
64+
if info, err := os.Stat(packagePathWithPipelineID); err == nil && info.IsDir() {
65+
packagePath = packagePathWithPipelineID
6466
}
67+
6568
entries, err := os.ReadDir(packagePath)
6669
if err != nil {
6770
return "", err

0 commit comments

Comments
 (0)