Skip to content

Commit

Permalink
fix provider log cmd
Browse files Browse the repository at this point in the history
Signed-off-by: Emily McMullan <[email protected]>
  • Loading branch information
eemcmullan committed Apr 24, 2024
1 parent a3de93b commit e943e19
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cmd/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ func (a *analyzeCommand) RunAnalysis(ctx context.Context, xmlOutputDir string, v
if err != nil {
return err
}
err = a.getProviderLogs(ctx)
err = a.getProviderLogs()
if err != nil {
a.log.Error(err, "failed to get provider container logs")
}
Expand Down Expand Up @@ -1280,22 +1280,26 @@ func (a *analyzeCommand) RmProviderContainers(ctx context.Context) error {
}

// TODO multiple providers
func (a *analyzeCommand) getProviderLogs(ctx context.Context) error {
func (a *analyzeCommand) getProviderLogs() error {
if len(a.providerContainerNames) == 0 {
return nil
}
providerLogFilePath := filepath.Join(a.output, "provider.log")
a.log.V(1).Info("getting provider container logs",
"container", a.providerContainerNames[0])

// send each provider logs to log file
cmd := exec.CommandContext(
ctx,
Settings.PodmanBinary,
logArgs := []string{Settings.PodmanBinary,
"logs",
a.providerContainerNames[0],
"&>",
providerLogFilePath)
providerLogFilePath}
joinedArgs := strings.Join(logArgs, " ")

// send each provider logs to log file
cmd := exec.Command(
"/bin/sh",
"-c",
joinedArgs)

return cmd.Run()
}

0 comments on commit e943e19

Please sign in to comment.