@@ -13,6 +13,7 @@ import (
13
13
"os"
14
14
"path"
15
15
"path/filepath"
16
+ "strings"
16
17
"time"
17
18
18
19
"github.com/magefile/mage/mg"
@@ -68,14 +69,34 @@ func DownloadManifest(manifest string) (tools.Build, error) {
68
69
}
69
70
70
71
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
+ }
78
98
}
99
+
79
100
return []string {val .URL , val .ShaURL , val .AscURL }
80
101
81
102
}
@@ -113,12 +134,6 @@ func DownloadComponentsFromManifest(manifest string, platforms []string, platfor
113
134
// For Independent Agent Releases, any opted-in projects will have a version that is
114
135
// one Patch version ahead since we are using the new bumped DRA artifacts for those projects.
115
136
// 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 ()
122
137
123
138
errGrp , downloadsCtx := errgroup .WithContext (context .Background ())
124
139
for component , pkgs := range componentSpec {
@@ -133,11 +148,6 @@ func DownloadComponentsFromManifest(manifest string, platforms []string, platfor
133
148
for _ , pkg := range pkgs {
134
149
reqPackage := platformPackages [platform ]
135
150
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
- }
141
151
if pkgURL != nil {
142
152
for _ , p := range pkgURL {
143
153
log .Printf (">>>>>>>>> Downloading [%s] [%s] " , pkg , p )
0 commit comments