Skip to content

Commit ac0f535

Browse files
committed
better package finding
1 parent 18456a9 commit ac0f535

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

dev-tools/mage/manifest/manifest.go

+28-18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os"
1414
"path"
1515
"path/filepath"
16+
"strings"
1617
"time"
1718

1819
"github.com/magefile/mage/mg"
@@ -68,14 +69,34 @@ func DownloadManifest(manifest string) (tools.Build, error) {
6869
}
6970

7071
func resolveManifestPackage(project tools.Project, pkg string, reqPackage string, version string) []string {
71-
packageName := fmt.Sprintf("%s-%s-%s", pkg, version, reqPackage)
72-
val, ok := project.Packages[packageName]
73-
if !ok {
74-
return nil
75-
}
76-
if mg.Verbose() {
77-
log.Printf(">>>>>>>>>>> Project branch/commit [%s, %s]", project.Branch, project.CommitHash)
72+
var val tools.Package
73+
var ok = true
74+
75+
for pkgName, _ := range project.Packages {
76+
if strings.HasPrefix(pkgName, pkg) {
77+
log.Printf(">>>>>>>>>>> XXX Package: %s <<<<", pkgName)
78+
firstSplit := strings.Split(pkgName, pkg+"-")
79+
secondHalf := firstSplit[1]
80+
if strings.Contains(secondHalf, reqPackage) {
81+
log.Printf(">>>>>>>>>>> XXX Second Half: %s <<<<", secondHalf)
82+
pkgVersion := strings.Split(secondHalf, "-"+reqPackage)[0]
83+
log.Printf(">>>>>>>>>>> XXX Got Version: %s <<<<", pkgVersion)
84+
85+
foundPkgKey := fmt.Sprintf("%s-%s-%s", pkg, pkgVersion, reqPackage)
86+
log.Printf(">>>>>>>>>>> XXX Found Pkg Key: %s <<<<", foundPkgKey)
87+
88+
val, ok = project.Packages[foundPkgKey]
89+
if !ok {
90+
return nil
91+
}
92+
93+
if mg.Verbose() {
94+
log.Printf(">>>>>>>>>>> Project branch/commit [%s, %s]", project.Branch, project.CommitHash)
95+
}
96+
}
97+
}
7898
}
99+
79100
return []string{val.URL, val.ShaURL, val.AscURL}
80101

81102
}
@@ -113,12 +134,6 @@ func DownloadComponentsFromManifest(manifest string, platforms []string, platfor
113134
// For Independent Agent Releases, any opted-in projects will have a version that is
114135
// one Patch version ahead since we are using the new bumped DRA artifacts for those projects.
115136
// This is acceptable since it is being released only as bundled with Elastic Agent.
116-
patchPlusOneString := fmt.Sprintf("%d.%d.%d", parsedManifestVersion.Major(), parsedManifestVersion.Minor(), parsedManifestVersion.Patch()+1)
117-
parsedPatchPlusOneVersion, err := version.ParseVersion(patchPlusOneString)
118-
if err != nil {
119-
return fmt.Errorf("failed to parse bumped patch version for Ind Agent Release: [%s]", patchPlusOneString)
120-
}
121-
majorMinorPatchPlusOneVersion := parsedPatchPlusOneVersion.VersionWithPrerelease()
122137

123138
errGrp, downloadsCtx := errgroup.WithContext(context.Background())
124139
for component, pkgs := range componentSpec {
@@ -133,11 +148,6 @@ func DownloadComponentsFromManifest(manifest string, platforms []string, platfor
133148
for _, pkg := range pkgs {
134149
reqPackage := platformPackages[platform]
135150
pkgURL := resolveManifestPackage(projects[component], pkg, reqPackage, majorMinorPatchVersion)
136-
if pkgURL == nil {
137-
// If the artifact doesn't match the manifest's version, check if it matches
138-
// the Patch + 1 version that Independent Agent opted-in projects use
139-
pkgURL = resolveManifestPackage(projects[component], pkg, reqPackage, majorMinorPatchPlusOneVersion)
140-
}
141151
if pkgURL != nil {
142152
for _, p := range pkgURL {
143153
log.Printf(">>>>>>>>> Downloading [%s] [%s] ", pkg, p)

0 commit comments

Comments
 (0)