From 3b90cfdd8d34bdf2e8a37d9bbbaa3284560a34e7 Mon Sep 17 00:00:00 2001 From: fearful-symmetry Date: Tue, 10 Oct 2023 13:23:25 -0700 Subject: [PATCH] add warning messages to magefile --- magefile.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/magefile.go b/magefile.go index 183889b3e69..74b4eb44da3 100644 --- a/magefile.go +++ b/magefile.go @@ -979,10 +979,10 @@ func packageAgent(platforms []string, packagingFn func()) { panic(err) } - packagesMissing := false packagesCopied := 0 if !requiredPackagesPresent(pwd, b, packageVersion, requiredPackages) { + fmt.Printf("--- Package %s\n", pwd) cmd := exec.Command("mage", "package") cmd.Dir = pwd cmd.Stdout = os.Stdout @@ -1008,6 +1008,14 @@ func packageAgent(platforms []string, packagingFn func()) { targetPath := filepath.Join(archivePath, rp) os.MkdirAll(targetPath, 0755) for _, f := range files { + // safety check; if the user has an older version of the beats repo, + // for example right after a relase where you've `git pulled` from on repo and not the other, + // they might end up with a mishmash of packages from different versions. + // check to see if we have mismatched versions. + if !strings.Contains(f, packageVersion) { + fmt.Printf("WARNING: the file %s doesn't match agent version %s, beats might be out of date\n", f, packageVersion) + } + targetFile := filepath.Join(targetPath, filepath.Base(f)) packagesCopied += 1 if err := sh.Copy(targetFile, f); err != nil { @@ -1017,8 +1025,8 @@ func packageAgent(platforms []string, packagingFn func()) { } // a very basic footcannon protector; if packages are missing and we need to rebuild them, check to see if those files were copied // 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. - if packagesMissing && packagesCopied == 0 { - fmt.Printf(">>> WARNING: no packages were copied, but we repackaged beats anyway. Check binary to see if intended beats are there.") + if packagesCopied == 0 { + fmt.Printf(">>> WARNING: no packages were copied, but we repackaged beats anyway. Check binary to see if intended beats are there.\n") } } } @@ -1153,6 +1161,7 @@ func copyComponentSpecs(componentName, versionedDropPath string) (string, error) targetPath := filepath.Join(versionedDropPath, specFileName) if _, err := os.Stat(targetPath); err != nil { + fmt.Printf(">> File %s does not exist, reverting to local specfile\n", targetPath) // spec not present copy from local sourceSpecFile := filepath.Join("specs", specFileName) if mg.Verbose() {