mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-05-13 20:56:50 +00:00
* Remove `logger` module * Remove `shared` module * Move `cli` folder contents into project root * Fix linter * Change the module name from `github.com/kubeshark/kubeshark/cli` to `github.com/kubeshark/kubeshark` * Set the default `Makefile` rule to `build` * Add `lint` rule * Fix the linter errors
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
|
|
"github.com/creasty/defaults"
|
|
"github.com/kubeshark/kubeshark/config"
|
|
"github.com/kubeshark/kubeshark/config/configStructs"
|
|
"github.com/kubeshark/kubeshark/errormessage"
|
|
"github.com/kubeshark/kubeshark/kubeshark/fsUtils"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var logsCmd = &cobra.Command{
|
|
Use: "logs",
|
|
Short: "Create a zip file with logs for Github issue or troubleshoot",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
kubernetesProvider, err := getKubernetesProviderForCli()
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
ctx := context.Background()
|
|
|
|
if validationErr := config.Config.Logs.Validate(); validationErr != nil {
|
|
return errormessage.FormatError(validationErr)
|
|
}
|
|
|
|
log.Printf("Using file path %s", config.Config.Logs.FilePath())
|
|
|
|
if dumpLogsErr := fsUtils.DumpLogs(ctx, kubernetesProvider, config.Config.Logs.FilePath()); dumpLogsErr != nil {
|
|
log.Printf("Failed dump logs %v", dumpLogsErr)
|
|
}
|
|
|
|
return nil
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(logsCmd)
|
|
|
|
defaultLogsConfig := configStructs.LogsConfig{}
|
|
if err := defaults.Set(&defaultLogsConfig); err != nil {
|
|
log.Print(err)
|
|
}
|
|
|
|
logsCmd.Flags().StringP(configStructs.FileLogsName, "f", defaultLogsConfig.FileStr, "Path for zip file (default current <pwd>\\kubeshark_logs.zip)")
|
|
}
|