@@ -196,7 +196,7 @@ func (Dev) Package() {
196
196
os .Setenv (devEnv , "true" )
197
197
198
198
if _ , hasExternal := os .LookupEnv (externalArtifacts ); ! hasExternal {
199
- devtools .ExternalBuild = " true"
199
+ devtools .ExternalBuild = true
200
200
}
201
201
202
202
devtools .DevBuild = true
@@ -813,7 +813,7 @@ func (Cloud) Image() {
813
813
devtools .SelectedPackageTypes = []devtools.PackageType {devtools .Docker }
814
814
815
815
if _ , hasExternal := os .LookupEnv (externalArtifacts ); ! hasExternal {
816
- devtools .ExternalBuild = " true"
816
+ devtools .ExternalBuild = true
817
817
}
818
818
819
819
Package ()
@@ -1055,7 +1055,7 @@ func collectPackageDependencies(platforms []string, packageVersion string, requi
1055
1055
1056
1056
os .Setenv (agentDropPath , dropPath )
1057
1057
1058
- if devtools .ExternalBuild == " true" {
1058
+ if devtools .ExternalBuild == true {
1059
1059
// Map of binaries to download to their project name in the unified-release manager.
1060
1060
// The project names are used to generate the URLs when downloading binaries. For example:
1061
1061
//
@@ -1077,126 +1077,101 @@ func collectPackageDependencies(platforms []string, packageVersion string, requi
1077
1077
"pf-elastic-symbolizer" : "prodfiler" ,
1078
1078
"pf-host-agent" : "prodfiler" ,
1079
1079
}
1080
- downloadFromExternalBuild (platforms , archivePath , packageVersion , externalBinaries )
1081
- } else if devtools .ExternalBuild == "agentbeat" {
1082
- // package agentbeat, then also pull external builds for non-agentbeat binaries
1083
- externalBinaries := map [string ]string {
1084
- "cloudbeat" : "cloudbeat" , // only supporting linux/amd64 or linux/arm64
1085
- "cloud-defend" : "cloud-defend" ,
1086
- "apm-server" : "apm-server" , // not supported on darwin/aarch64
1087
- "endpoint-security" : "endpoint-dev" ,
1088
- "fleet-server" : "fleet-server" ,
1089
- "pf-elastic-collector" : "prodfiler" ,
1090
- "pf-elastic-symbolizer" : "prodfiler" ,
1091
- "pf-host-agent" : "prodfiler" ,
1092
- }
1093
- downloadFromExternalBuild (platforms , archivePath , packageVersion , externalBinaries )
1094
- packageAgentBeat (packageVersion , archivePath , requiredPackages )
1095
-
1096
- } else {
1097
- packageAgentBeat (packageVersion , archivePath , requiredPackages )
1098
- }
1099
- } else {
1100
- archivePath = movePackagesToArchive (dropPath , requiredPackages )
1101
- }
1102
- return archivePath , dropPath
1103
- }
1104
-
1105
- // downloadFromExternalBuild downloads the component binaries and places them in the drop path for the rest of the build
1106
- func downloadFromExternalBuild (platforms []string , archivePath string , packageVersion string , externalBinaries map [string ]string ) {
1107
-
1108
- // Only log fatal logs for logs produced using logrus. This is the global logger
1109
- // used by github.com/elastic/e2e-testing/pkg/downloads which can only be configured globally like this or via
1110
- // environment variables.
1111
- //
1112
- // Using FatalLevel avoids filling the build log with scary looking errors when we attempt to
1113
- // download artifacts on unsupported platforms and choose to ignore the errors.
1114
- //
1115
- // Change this to InfoLevel to see exactly what the downloader is doing.
1116
- logrus .SetLevel (logrus .FatalLevel )
1117
-
1118
- errGroup , ctx := errgroup .WithContext (context .Background ())
1119
- completedDownloads := & atomic.Int32 {}
1120
- for binary , project := range externalBinaries {
1121
- for _ , platform := range platforms {
1122
- reqPackage := platformPackages [platform ]
1123
- targetPath := filepath .Join (archivePath , reqPackage )
1124
- os .MkdirAll (targetPath , 0755 )
1125
- newVersion , packageName := getPackageName (binary , packageVersion , reqPackage )
1126
- errGroup .Go (downloadBinary (ctx , project , packageName , binary , platform , newVersion , targetPath , completedDownloads ))
1127
- }
1128
- }
1129
-
1130
- err := errGroup .Wait ()
1131
- if err != nil {
1132
- panic (err )
1133
- }
1134
- if completedDownloads .Load () == 0 {
1135
- panic (fmt .Sprintf ("No packages were successfully downloaded. You may be building against an invalid or unreleased version. version=%s. If this is an unreleased version, try SNAPSHOT=true or EXTERNAL=false" , packageVersion ))
1136
- }
1137
- }
1138
-
1139
- // packageAgentBeat packages the beat from the local code in the beats path
1140
- func packageAgentBeat (packageVersion string , archivePath string , requiredPackages []string ) {
1141
- packedBeats := []string {"agentbeat" }
1142
- // build from local repo, will assume beats repo is located on the same root level
1143
- for _ , b := range packedBeats {
1144
- pwd , err := filepath .Abs (filepath .Join ("../beats/x-pack" , b ))
1145
- if err != nil {
1146
- panic (err )
1147
- }
1148
-
1149
- packagesCopied := 0
1150
1080
1151
- if ! requiredPackagesPresent (pwd , b , packageVersion , requiredPackages ) {
1152
- fmt .Printf ("--- Package %s\n " , pwd )
1153
- cmd := exec .Command ("mage" , "package" )
1154
- cmd .Dir = pwd
1155
- cmd .Stdout = os .Stdout
1156
- cmd .Stderr = os .Stderr
1157
- cmd .Env = append (os .Environ (), fmt .Sprintf ("PWD=%s" , pwd ), "AGENT_PACKAGING=on" )
1158
- if envVar := selectedPackageTypes (); envVar != "" {
1159
- cmd .Env = append (cmd .Env , envVar )
1160
- }
1161
-
1162
- if err := cmd .Run (); err != nil {
1163
- panic (err )
1081
+ // Only log fatal logs for logs produced using logrus. This is the global logger
1082
+ // used by github.com/elastic/e2e-testing/pkg/downloads which can only be configured globally like this or via
1083
+ // environment variables.
1084
+ //
1085
+ // Using FatalLevel avoids filling the build log with scary looking errors when we attempt to
1086
+ // download artifacts on unsupported platforms and choose to ignore the errors.
1087
+ //
1088
+ // Change this to InfoLevel to see exactly what the downloader is doing.
1089
+ logrus .SetLevel (logrus .FatalLevel )
1090
+
1091
+ errGroup , ctx := errgroup .WithContext (context .Background ())
1092
+ completedDownloads := & atomic.Int32 {}
1093
+ for binary , project := range externalBinaries {
1094
+ for _ , platform := range platforms {
1095
+ reqPackage := platformPackages [platform ]
1096
+ targetPath := filepath .Join (archivePath , reqPackage )
1097
+ os .MkdirAll (targetPath , 0755 )
1098
+ newVersion , packageName := getPackageName (binary , packageVersion , reqPackage )
1099
+ errGroup .Go (downloadBinary (ctx , project , packageName , binary , platform , newVersion , targetPath , completedDownloads ))
1100
+ }
1164
1101
}
1165
- }
1166
1102
1167
- // copy to new drop
1168
- sourcePath := filepath .Join (pwd , "build" , "distributions" )
1169
- for _ , rp := range requiredPackages {
1170
- files , err := filepath .Glob (filepath .Join (sourcePath , "*" + rp + "*" ))
1103
+ err = errGroup .Wait ()
1171
1104
if err != nil {
1172
1105
panic (err )
1173
1106
}
1107
+ if completedDownloads .Load () == 0 {
1108
+ panic (fmt .Sprintf ("No packages were successfully downloaded. You may be building against an invalid or unreleased version. version=%s. If this is an unreleased version, try SNAPSHOT=true or EXTERNAL=false" , packageVersion ))
1109
+ }
1110
+ } else {
1111
+ packedBeats := []string {"agentbeat" }
1112
+ // build from local repo, will assume beats repo is located on the same root level
1113
+ for _ , b := range packedBeats {
1114
+ pwd , err := filepath .Abs (filepath .Join ("../beats/x-pack" , b ))
1115
+ if err != nil {
1116
+ panic (err )
1117
+ }
1118
+
1119
+ packagesCopied := 0
1120
+
1121
+ if ! requiredPackagesPresent (pwd , b , packageVersion , requiredPackages ) {
1122
+ fmt .Printf ("--- Package %s\n " , pwd )
1123
+ cmd := exec .Command ("mage" , "package" )
1124
+ cmd .Dir = pwd
1125
+ cmd .Stdout = os .Stdout
1126
+ cmd .Stderr = os .Stderr
1127
+ cmd .Env = append (os .Environ (), fmt .Sprintf ("PWD=%s" , pwd ), "AGENT_PACKAGING=on" )
1128
+ if envVar := selectedPackageTypes (); envVar != "" {
1129
+ cmd .Env = append (cmd .Env , envVar )
1130
+ }
1174
1131
1175
- targetPath := filepath .Join (archivePath , rp )
1176
- os .MkdirAll (targetPath , 0755 )
1177
- for _ , f := range files {
1178
- // safety check; if the user has an older version of the beats repo,
1179
- // for example right after a release where you've `git pulled` from on repo and not the other,
1180
- // they might end up with a mishmash of packages from different versions.
1181
- // check to see if we have mismatched versions.
1182
- if ! strings .Contains (f , packageVersion ) {
1183
- // if this panic hits weird edge cases where we don't want actual failures, revert to a printf statement.
1184
- panic (fmt .Sprintf ("the file %s doesn't match agent version %s, beats repo might be out of date" , f , packageVersion ))
1132
+ if err := cmd .Run (); err != nil {
1133
+ panic (err )
1134
+ }
1185
1135
}
1186
1136
1187
- targetFile := filepath .Join (targetPath , filepath .Base (f ))
1188
- packagesCopied += 1
1189
- if err := sh .Copy (targetFile , f ); err != nil {
1190
- panic (err )
1137
+ // copy to new drop
1138
+ sourcePath := filepath .Join (pwd , "build" , "distributions" )
1139
+ for _ , rp := range requiredPackages {
1140
+ files , err := filepath .Glob (filepath .Join (sourcePath , "*" + rp + "*" ))
1141
+ if err != nil {
1142
+ panic (err )
1143
+ }
1144
+
1145
+ targetPath := filepath .Join (archivePath , rp )
1146
+ os .MkdirAll (targetPath , 0755 )
1147
+ for _ , f := range files {
1148
+ // safety check; if the user has an older version of the beats repo,
1149
+ // for example right after a release where you've `git pulled` from on repo and not the other,
1150
+ // they might end up with a mishmash of packages from different versions.
1151
+ // check to see if we have mismatched versions.
1152
+ if ! strings .Contains (f , packageVersion ) {
1153
+ // if this panic hits weird edge cases where we don't want actual failures, revert to a printf statement.
1154
+ panic (fmt .Sprintf ("the file %s doesn't match agent version %s, beats repo might be out of date" , f , packageVersion ))
1155
+ }
1156
+
1157
+ targetFile := filepath .Join (targetPath , filepath .Base (f ))
1158
+ packagesCopied += 1
1159
+ if err := sh .Copy (targetFile , f ); err != nil {
1160
+ panic (err )
1161
+ }
1162
+ }
1163
+ }
1164
+ // a very basic footcannon protector; if packages are missing and we need to rebuild them, check to see if those files were copied
1165
+ // if we needed to repackage beats but still somehow copied nothing, could indicate an issue. Usually due to beats and agent being at different versions.
1166
+ if packagesCopied == 0 {
1167
+ fmt .Println (">>> WARNING: no packages were copied, but we repackaged beats anyway. Check binary to see if intended beats are there." )
1191
1168
}
1192
1169
}
1193
1170
}
1194
- // a very basic footcannon protector; if packages are missing and we need to rebuild them, check to see if those files were copied
1195
- // if we needed to repackage beats but still somehow copied nothing, could indicate an issue. Usually due to beats and agent being at different versions.
1196
- if packagesCopied == 0 {
1197
- fmt .Println (">>> WARNING: no packages were copied, but we repackaged beats anyway. Check binary to see if intended beats are there." )
1198
- }
1171
+ } else {
1172
+ archivePath = movePackagesToArchive (dropPath , requiredPackages )
1199
1173
}
1174
+ return archivePath , dropPath
1200
1175
}
1201
1176
1202
1177
// flattenDependencies will extract all the required packages collected in archivePath and dropPath in flatPath and
@@ -1240,7 +1215,7 @@ func flattenDependencies(requiredPackages []string, packageVersion, archivePath,
1240
1215
log .Printf (">>> Extracting %s to %s" , m , versionedFlatPath )
1241
1216
}
1242
1217
if err := devtools .Extract (m , versionedFlatPath ); err != nil {
1243
- panic (fmt . Errorf ( "error extracting %s: %s" , m , err ) )
1218
+ panic (err )
1244
1219
}
1245
1220
}
1246
1221
0 commit comments