Skip to content

Commit

Permalink
added install-info to checkup (#1899)
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarfda authored Oct 21, 2024
1 parent 4ebb37d commit f9c8e4e
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion ee/debug/checkups/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (
"io"
"os"
"runtime"

"github.com/kolide/launcher/pkg/launcher"
)

type installCheckup struct {
}

func (i *installCheckup) Name() string {
return "Package Install Logs"
return "Package Install"
}

func (i *installCheckup) Run(ctx context.Context, extraWriter io.Writer) error {
Expand All @@ -24,6 +26,10 @@ func (i *installCheckup) Run(ctx context.Context, extraWriter io.Writer) error {
return fmt.Errorf("gathering installation logs: %w", err)
}

if err := gatherInstallerInfo(extraZip); err != nil {
return fmt.Errorf("gathering installer info: %w", err)
}

return nil

}
Expand Down Expand Up @@ -66,3 +72,35 @@ func gatherInstallationLogs(z *zip.Writer) error {

return nil
}

func gatherInstallerInfo(z *zip.Writer) error {
if runtime.GOOS == "windows" {
// Installer info is not available on Windows
return nil
}

configDir := launcher.DefaultPath(launcher.EtcDirectory)
installerInfoPath := fmt.Sprintf("%s/installer-info.json", configDir)

installerInfoFile, err := os.Open(installerInfoPath)
if err != nil {
// If the file doesn't exist, you might want to skip without error
if os.IsNotExist(err) {
return nil
}
return fmt.Errorf("opening %s: %w", installerInfoPath, err)
}
defer installerInfoFile.Close()

installerInfoZipPath := "installer-info.json"
out, err := z.Create(installerInfoZipPath)
if err != nil {
return fmt.Errorf("creating %s in zip: %w", installerInfoZipPath, err)
}

if _, err := io.Copy(out, installerInfoFile); err != nil {
return fmt.Errorf("writing %s contents to zip: %w", installerInfoZipPath, err)
}

return nil
}

0 comments on commit f9c8e4e

Please sign in to comment.