@@ -1303,95 +1303,112 @@ func getComponentVersion(componentName string, requiredPackage string, component
1303
1303
return componentVersion
1304
1304
}
1305
1305
1306
+ func fixCloudDefendDirPath (dirPath string , componentVersion string , expectedArch string , actualArch string ) string {
1307
+ fixedDirPath := dirPath
1308
+
1309
+ cloudDefendExpectedDirName := fmt .Sprintf ("cloud-defend-%s-linux-%s" , componentVersion , expectedArch )
1310
+ cloudDefendActualDirName := fmt .Sprintf ("cloud-defend-%s-%s" , componentVersion , actualArch )
1311
+ if strings .Contains (fixedDirPath , cloudDefendExpectedDirName ) {
1312
+ fixedDirPath = strings .ReplaceAll (fixedDirPath , cloudDefendExpectedDirName , cloudDefendActualDirName )
1313
+ }
1314
+
1315
+ return fixedDirPath
1316
+ }
1317
+
1306
1318
func fileHelperWithManifest (requiredPackage string , versionedFlatPath string , versionedDropPath string , manifestResponse tools.Build ) map [string ]string {
1307
1319
1308
- agentComponents := map [string ]string {
1309
- "apm-server" : "apm-server" ,
1310
- "beats" : "metricbeat" ,
1311
- "cloud-defend" : "cloud-defend" ,
1312
- "cloudbeat" : "cloudbeat" ,
1313
- //"elastic-agent-core": "elastic-agent-core",
1314
- "endpoint-dev" : "endpoint-security" ,
1315
- "fleet-server" : "fleet-server" ,
1316
- "prodfiler" : "pf-elastic-collector" ,
1320
+ // Should move this elsewhere so there's only one location for it
1321
+ externalBinaries := map [string ]string {
1322
+ "agentbeat" : "beats" ,
1323
+ "cloudbeat" : "cloudbeat" , // only supporting linux/amd64 or linux/arm64
1324
+ "cloud-defend" : "cloud-defend" ,
1325
+ "apm-server" : "apm-server" , // not supported on darwin/aarch64
1326
+ "endpoint-security" : "endpoint-dev" ,
1327
+ "fleet-server" : "fleet-server" ,
1328
+ "pf-elastic-collector" : "prodfiler" ,
1329
+ "pf-elastic-symbolizer" : "prodfiler" ,
1330
+ "pf-host-agent" : "prodfiler" ,
1317
1331
}
1318
- /*
1319
- externalBinaries := map[string]string{
1320
- "agentbeat": "beats",
1321
- "cloudbeat": "cloudbeat", // only supporting linux/amd64 or linux/arm64
1322
- "cloud-defend": "cloud-defend",
1323
- "apm-server": "apm-server", // not supported on darwin/aarch64
1324
- "endpoint-security": "endpoint-dev",
1325
- "fleet-server": "fleet-server",
1326
- "pf-elastic-collector": "prodfiler",
1327
- "pf-elastic-symbolizer": "prodfiler",
1328
- "pf-host-agent": "prodfiler",
1329
- }
1330
- */
1331
1332
1332
1333
checksums := make (map [string ]string )
1333
1334
1334
1335
projects := manifestResponse .Projects
1335
- //log.Printf(">>>>>>>>> XXX projects: [%s]", projects)
1336
1336
log .Printf (">>>>>>>> XXX in filehelperWithManifest" )
1337
1337
1338
1338
for componentName , _ := range projects {
1339
- if _ , ok := agentComponents [componentName ]; ! ok {
1340
- //log.Printf(">>>>>> XXX Ignoring component [%s]", componentName)
1341
- continue
1342
- }
1343
-
1344
- log .Printf (">>>>>>>>> XXX Found componentName [%s]" , componentName )
1345
1339
1346
1340
log .Printf (">>>>> XXX Checking for requiredPackage: [%s]" , requiredPackage )
1347
1341
for pkgName , _ := range projects [componentName ].Packages {
1348
1342
log .Printf (">>>>>>>> XXX Found pkgName: [%s]" , pkgName )
1349
1343
if strings .Contains (pkgName , requiredPackage ) {
1350
- log .Printf (">>>>>>> XXX Pkg [%s] matches requiredPackage [%s]" , pkgName , requiredPackage )
1344
+ for filePrefix , _ := range externalBinaries {
1345
+ if ! strings .HasPrefix (pkgName , filePrefix ) {
1346
+ continue
1347
+ }
1348
+ log .Printf (">>>>>>> XXX Pkg [%s] matches requiredPackage [%s]" , pkgName , requiredPackage )
1351
1349
1352
- componentVersion := getComponentVersion (componentName , requiredPackage , projects [componentName ], agentComponents )
1353
- log .Printf (">>>>>>> XXX [%s] [%s] version is [%s]" , componentName , requiredPackage , componentVersion )
1350
+ componentVersion := getComponentVersion (componentName , requiredPackage , projects [componentName ], agentComponents )
1351
+ log .Printf (">>>>>>> XXX [%s] [%s] version is [%s]" , componentName , requiredPackage , componentVersion )
1354
1352
1355
- fullPath := filepath .Join (versionedFlatPath , pkgName )
1356
- log .Printf (">>>>>> XXX fullPath [%s]" , fullPath )
1353
+ fullPath := filepath .Join (versionedFlatPath , pkgName )
1354
+ log .Printf (">>>>>> XXX fullPath [%s]" , fullPath )
1357
1355
1358
- var dirToCopy string
1359
- if strings .HasSuffix (fullPath , ".tar.gz" ) {
1360
- dirToCopy = fullPath [:strings .LastIndex (fullPath , ".tar.gz" )]
1361
- } else if strings .HasSuffix (fullPath , ".zip" ) {
1362
- dirToCopy = fullPath [:strings .LastIndex (fullPath , ".zip" )]
1363
- } else {
1364
- dirToCopy = fullPath
1365
- }
1366
- log .Printf (">>>>>> XXX dirToCopy [%s]" , dirToCopy )
1356
+ var dirToCopy string
1357
+ if strings .HasSuffix (fullPath , ".tar.gz" ) {
1358
+ dirToCopy = fullPath [:strings .LastIndex (fullPath , ".tar.gz" )]
1359
+ } else if strings .HasSuffix (fullPath , ".zip" ) {
1360
+ dirToCopy = fullPath [:strings .LastIndex (fullPath , ".zip" )]
1361
+ } else {
1362
+ dirToCopy = fullPath
1363
+ }
1367
1364
1368
- options := copy.Options {
1369
- OnSymlink : func (_ string ) copy.SymlinkAction {
1370
- return copy .Shallow
1371
- },
1372
- Sync : true ,
1373
- }
1374
- log .Printf ("> XXX ManURL prepare to copy %s into %s " , dirToCopy , versionedDropPath )
1365
+ // cloud-defend path exception
1366
+ // When untarred, cloud defend untars to:
1367
+ // cloud-defend-8.14.0-arm64
1368
+ // but the manifest (and most of this code) expects to be the same as
1369
+ // the name in the manifest, which is:
1370
+ // cloud-defend-8.14.0-linux-x86_64
1371
+ // So we have to do a bit of a transformation here
1372
+ if strings .Contains (dirToCopy , "cloud-defend" ) {
1373
+ if strings .Contains (dirToCopy , "x86_64" ) {
1374
+ dirToCopy = fixCloudDefendDirPath (dirToCopy , componentVersion , "x86_64" , "amd64" )
1375
+ }
1376
+ if strings .Contains (dirToCopy , "arm64" ) {
1377
+ // Not actually replacing the arch, but removing the "linux"
1378
+ dirToCopy = fixCloudDefendDirPath (dirToCopy , componentVersion , "arm64" , "arm64" )
1379
+ }
1380
+ }
1375
1381
1376
- //log.Printf(">>>>> SLEEPING")
1377
- //time.Sleep(60 * time.Second)
1378
- //log.Printf(">>>>> DONE SLEEPING")
1382
+ log .Printf (">>>>>> XXX dirToCopy [%s]" , dirToCopy )
1379
1383
1380
- info , err := os .Stat (dirToCopy )
1381
- if err != nil {
1382
- panic (err )
1383
- }
1384
- if info .IsDir () {
1385
- log .Printf (">>> XXX DIR!! [%s]" , dirToCopy )
1386
- } else {
1387
- log .Printf (">>> XXX File! [%s]" , dirToCopy )
1388
- }
1384
+ options := copy.Options {
1385
+ OnSymlink : func (_ string ) copy.SymlinkAction {
1386
+ return copy .Shallow
1387
+ },
1388
+ Sync : true ,
1389
+ }
1390
+ log .Printf ("> XXX ManURL prepare to copy %s into %s " , dirToCopy , versionedDropPath )
1389
1391
1390
- err = copy .Copy (dirToCopy , versionedDropPath , options )
1391
- if err != nil {
1392
- panic (err )
1393
- }
1392
+ info , err := os .Stat (dirToCopy )
1393
+ if err != nil {
1394
+ log .Printf (">>>>> SLEEPING" )
1395
+ time .Sleep (60 * time .Second )
1396
+ log .Printf (">>>>> DONE SLEEPING" )
1394
1397
1398
+ panic (err )
1399
+ }
1400
+ if info .IsDir () {
1401
+ log .Printf (">>> XXX DIR!! [%s]" , dirToCopy )
1402
+ } else {
1403
+ log .Printf (">>> XXX File! [%s]" , dirToCopy )
1404
+ }
1405
+
1406
+ err = copy .Copy (dirToCopy , versionedDropPath , options )
1407
+ if err != nil {
1408
+ panic (err )
1409
+ }
1410
+
1411
+ }
1395
1412
}
1396
1413
}
1397
1414
}
@@ -1464,7 +1481,7 @@ func flattenDependencies(requiredPackages []string, packageVersion, archivePath,
1464
1481
}
1465
1482
1466
1483
log .Printf (">>>> XXX Sleeping...." )
1467
- // time.Sleep(60 * time.Second)
1484
+ time .Sleep (60 * time .Second )
1468
1485
log .Printf (">>>> XXX Done Sleeping...." )
1469
1486
}
1470
1487
0 commit comments