Skip to content

Commit 48c65c3

Browse files
committed
Cleaning up
1 parent 3d9f4ca commit 48c65c3

File tree

1 file changed

+34
-72
lines changed

1 file changed

+34
-72
lines changed

magefile.go

+34-72
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,28 @@ var (
102102
goIntegTestTimeout = 2 * time.Hour
103103
// goProvisionAndTestTimeout is the timeout used for both provisioning and running tests.
104104
goProvisionAndTestTimeout = goIntegTestTimeout + 30*time.Minute
105+
106+
// Map of binaries to download to their project name in the unified-release manager.
107+
// The project names are used to generate the URLs when downloading binaries. For example:
108+
//
109+
// https://artifacts-snapshot.elastic.co/beats/latest/8.11.0-SNAPSHOT.json
110+
// https://artifacts-snapshot.elastic.co/cloudbeat/latest/8.11.0-SNAPSHOT.json
111+
// https://artifacts-snapshot.elastic.co/cloud-defend/latest/8.11.0-SNAPSHOT.json
112+
// https://artifacts-snapshot.elastic.co/apm-server/latest/8.11.0-SNAPSHOT.json
113+
// https://artifacts-snapshot.elastic.co/endpoint-dev/latest/8.11.0-SNAPSHOT.json
114+
// https://artifacts-snapshot.elastic.co/fleet-server/latest/8.11.0-SNAPSHOT.json
115+
// https://artifacts-snapshot.elastic.co/prodfiler/latest/8.11.0-SNAPSHOT.json
116+
externalBinaries = map[string]string{
117+
"agentbeat": "beats",
118+
"cloudbeat": "cloudbeat", // only supporting linux/amd64 or linux/arm64
119+
"cloud-defend": "cloud-defend",
120+
"apm-server": "apm-server", // not supported on darwin/aarch64
121+
"endpoint-security": "endpoint-dev",
122+
"fleet-server": "fleet-server",
123+
"pf-elastic-collector": "prodfiler",
124+
"pf-elastic-symbolizer": "prodfiler",
125+
"pf-host-agent": "prodfiler",
126+
}
105127
)
106128

107129
func init() {
@@ -1078,27 +1100,6 @@ func collectPackageDependencies(platforms []string, packageVersion string, requi
10781100
os.Setenv(agentDropPath, dropPath)
10791101

10801102
if devtools.ExternalBuild == true {
1081-
// Map of binaries to download to their project name in the unified-release manager.
1082-
// The project names are used to generate the URLs when downloading binaries. For example:
1083-
//
1084-
// https://artifacts-snapshot.elastic.co/beats/latest/8.11.0-SNAPSHOT.json
1085-
// https://artifacts-snapshot.elastic.co/cloudbeat/latest/8.11.0-SNAPSHOT.json
1086-
// https://artifacts-snapshot.elastic.co/cloud-defend/latest/8.11.0-SNAPSHOT.json
1087-
// https://artifacts-snapshot.elastic.co/apm-server/latest/8.11.0-SNAPSHOT.json
1088-
// https://artifacts-snapshot.elastic.co/endpoint-dev/latest/8.11.0-SNAPSHOT.json
1089-
// https://artifacts-snapshot.elastic.co/fleet-server/latest/8.11.0-SNAPSHOT.json
1090-
// https://artifacts-snapshot.elastic.co/prodfiler/latest/8.11.0-SNAPSHOT.json
1091-
externalBinaries := map[string]string{
1092-
"agentbeat": "beats",
1093-
"cloudbeat": "cloudbeat", // only supporting linux/amd64 or linux/arm64
1094-
"cloud-defend": "cloud-defend",
1095-
"apm-server": "apm-server", // not supported on darwin/aarch64
1096-
"endpoint-security": "endpoint-dev",
1097-
"fleet-server": "fleet-server",
1098-
"pf-elastic-collector": "prodfiler",
1099-
"pf-elastic-symbolizer": "prodfiler",
1100-
"pf-host-agent": "prodfiler",
1101-
}
11021103

11031104
// Only log fatal logs for logs produced using logrus. This is the global logger
11041105
// used by github.com/elastic/e2e-testing/pkg/downloads which can only be configured globally like this or via
@@ -1196,23 +1197,8 @@ func collectPackageDependencies(platforms []string, packageVersion string, requi
11961197
return archivePath, dropPath
11971198
}
11981199

1199-
func getIndAgentGlobExpr(versionedFlatPath string, packageVersion string) string {
1200-
parsedPackageVersion, err := version.ParseVersion(packageVersion)
1201-
if err != nil {
1202-
panic(err)
1203-
}
1204-
1205-
bumpedPatchNumber := parsedPackageVersion.Patch() + 1
1206-
1207-
globExpr := filepath.Join(versionedFlatPath, fmt.Sprintf("*%d.%d.[%d|%d]*", parsedPackageVersion.Major(), parsedPackageVersion.Minor(), parsedPackageVersion.Patch(), bumpedPatchNumber))
1208-
1209-
return globExpr
1210-
}
1211-
12121200
func fileHelperNoManifest(versionedFlatPath string, versionedDropPath string, packageVersion string) map[string]string {
1213-
log.Printf(">>>>>>>>>> XXX versionedFlatPath: [%s]", versionedFlatPath)
12141201
globExpr := filepath.Join(versionedFlatPath, fmt.Sprintf("*%s*", packageVersion))
1215-
//globExpr := getIndAgentGlobExpr(versionedFlatPath, packageVersion)
12161202
if mg.Verbose() {
12171203
log.Printf("Finding files to copy with %s", globExpr)
12181204
}
@@ -1221,8 +1207,8 @@ func fileHelperNoManifest(versionedFlatPath string, versionedDropPath string, pa
12211207
panic(err)
12221208
}
12231209
if mg.Verbose() {
1224-
log.Printf(" XXX Validating checksums for %+v", files)
1225-
log.Printf("--- XXX Copying into %s: %v", versionedDropPath, files)
1210+
log.Printf(" Validating checksums for %+v", files)
1211+
log.Printf("--- Copying into %s: %v", versionedDropPath, files)
12261212
}
12271213

12281214
checksums := make(map[string]string)
@@ -1234,17 +1220,7 @@ func fileHelperNoManifest(versionedFlatPath string, versionedDropPath string, pa
12341220
Sync: true,
12351221
}
12361222
if mg.Verbose() {
1237-
log.Printf("> XXX prepare to copy %s into %s ", f, versionedDropPath)
1238-
}
1239-
1240-
info, err := os.Stat(f)
1241-
if err != nil {
1242-
panic(err)
1243-
}
1244-
if info.IsDir() {
1245-
log.Printf(">>> XXX DIR!! [%s]", f)
1246-
} else {
1247-
log.Printf(">>> XXX File! [%s]", f)
1223+
log.Printf("> prepare to copy %s into %s ", f, versionedDropPath)
12481224
}
12491225

12501226
err = copy.Copy(f, versionedDropPath, options)
@@ -1254,13 +1230,13 @@ func fileHelperNoManifest(versionedFlatPath string, versionedDropPath string, pa
12541230

12551231
// copy spec file for match
12561232
specName := filepath.Base(f)
1257-
log.Printf(">>>> XXX specName: [%s]", specName)
12581233
idx := strings.Index(specName, "-"+packageVersion)
12591234
if idx != -1 {
12601235
specName = specName[:idx]
1261-
log.Printf(">>>> XXX specName[:idx] [%s]", specName)
12621236
}
1263-
log.Printf(">>>> XXX specName final: [%s]", specName)
1237+
if mg.Verbose() {
1238+
log.Printf(">>>> Looking to copy spec file: [%s]", specName)
1239+
}
12641240

12651241
checksum, err := copyComponentSpecs(specName, versionedDropPath)
12661242
if err != nil {
@@ -1273,7 +1249,11 @@ func fileHelperNoManifest(versionedFlatPath string, versionedDropPath string, pa
12731249
return checksums
12741250
}
12751251

1276-
func getComponentVersion(componentName string, requiredPackage string, componentProject tools.Project, externalBinaries map[string]string) string {
1252+
// This function is used when building with a Manifest. In that manifest, it's possible
1253+
// for projects in an Independent Agent Release to have different versions since the opted-in
1254+
// ones will be one patch version higher than the opted-out/previously released projects.
1255+
// This function tries to find the versions from the package name
1256+
func getComponentVersion(componentName string, requiredPackage string, componentProject tools.Project) string {
12771257
var componentVersion string
12781258
for pkgName, _ := range componentProject.Packages {
12791259
log.Printf(">>>>>>>>>>> XXX getComponentVersion Package: %s <<<<", pkgName)
@@ -1321,23 +1301,9 @@ func fixCloudDefendDirPath(dirPath string, componentVersion string, expectedArch
13211301

13221302
func fileHelperWithManifest(requiredPackage string, versionedFlatPath string, versionedDropPath string, manifestResponse tools.Build) map[string]string {
13231303

1324-
// Should move this elsewhere so there's only one location for it
1325-
externalBinaries := map[string]string{
1326-
"agentbeat": "beats",
1327-
"cloudbeat": "cloudbeat", // only supporting linux/amd64 or linux/arm64
1328-
"cloud-defend": "cloud-defend",
1329-
"apm-server": "apm-server", // not supported on darwin/aarch64
1330-
"endpoint-security": "endpoint-dev",
1331-
"fleet-server": "fleet-server",
1332-
"pf-elastic-collector": "prodfiler",
1333-
"pf-elastic-symbolizer": "prodfiler",
1334-
"pf-host-agent": "prodfiler",
1335-
}
1336-
13371304
checksums := make(map[string]string)
13381305

13391306
projects := manifestResponse.Projects
1340-
log.Printf(">>>>>>>> XXX in filehelperWithManifest")
13411307

13421308
for componentName, _ := range projects {
13431309

@@ -1351,7 +1317,7 @@ func fileHelperWithManifest(requiredPackage string, versionedFlatPath string, ve
13511317
}
13521318
log.Printf(">>>>>>> XXX Pkg [%s] matches requiredPackage [%s]", pkgName, requiredPackage)
13531319

1354-
componentVersion := getComponentVersion(componentName, requiredPackage, projects[componentName], externalBinaries)
1320+
componentVersion := getComponentVersion(componentName, requiredPackage, projects[componentName])
13551321
log.Printf(">>>>>>> XXX [%s] [%s] version is [%s]", componentName, requiredPackage, componentVersion)
13561322

13571323
fullPath := filepath.Join(versionedFlatPath, pkgName)
@@ -1395,10 +1361,6 @@ func fileHelperWithManifest(requiredPackage string, versionedFlatPath string, ve
13951361

13961362
info, err := os.Stat(dirToCopy)
13971363
if err != nil {
1398-
log.Printf(">>>>> SLEEPING")
1399-
time.Sleep(60 * time.Second)
1400-
log.Printf(">>>>> DONE SLEEPING")
1401-
14021364
panic(err)
14031365
}
14041366
if info.IsDir() {

0 commit comments

Comments
 (0)