Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added install-info to checkup #1899

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading