Merge pull request #13991 from EdwinWalela/edwin-dev

Add --audit flag to minikube logs command
pull/14016/head^2
Steven Powell 2022-04-22 16:46:10 -07:00 committed by GitHub
commit 58eed153fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 22 additions and 4 deletions

View File

@ -50,6 +50,8 @@ var (
showProblems bool
// fileOutput is where to write logs to. If omitted, writes to stdout.
fileOutput string
// auditLogs only shows the audit logs
auditLogs bool
)
// logsCmd represents the logs command
@ -73,7 +75,13 @@ var logsCmd = &cobra.Command{
exit.Error(reason.Usage, "Failed to create file", err)
}
}
if auditLogs {
err := logs.OutputAudit(numberOfLines)
if err != nil {
klog.Errorf("failed to output audit logs: %v", err)
}
return
}
logs.OutputOffline(numberOfLines, logOutput)
if shouldSilentFail() {
@ -91,7 +99,6 @@ var logsCmd = &cobra.Command{
if err != nil {
exit.Error(reason.InternalNewRuntime, "Unable to get runtime", err)
}
if followLogs {
err := logs.Follow(cr, bs, *co.Config, co.CP.Runner, logOutput)
if err != nil {
@ -142,4 +149,5 @@ func init() {
logsCmd.Flags().IntVarP(&numberOfLines, "length", "n", 60, "Number of lines back to go within the log")
logsCmd.Flags().StringVar(&nodeName, "node", "", "The node to get logs from. Defaults to the primary control plane.")
logsCmd.Flags().StringVar(&fileOutput, "file", "", "If present, writes to the provided file instead of stdout.")
logsCmd.Flags().BoolVar(&auditLogs, "audit", false, "Show only the audit logs")
}

View File

@ -208,7 +208,7 @@ func Output(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.Cluster
}
// outputAudit displays the audit logs.
func outputAudit(lines int) error {
func OutputAudit(lines int) error {
out.Styled(style.Empty, "")
out.Styled(style.Empty, "==> Audit <==")
r, err := audit.Report(lines)
@ -252,7 +252,7 @@ func OutputOffline(lines int, logOutput *os.File) {
defer out.SetOutFile(os.Stdout)
out.SetErrFile(logOutput)
defer out.SetErrFile(os.Stderr)
if err := outputAudit(lines); err != nil {
if err := OutputAudit(lines); err != nil {
klog.Errorf("failed to output audit logs: %v", err)
}
if err := outputLastStart(); err != nil {

View File

@ -20,6 +20,7 @@ minikube logs [flags]
### Options
```
--audit Show only the audit logs
--file string If present, writes to the provided file instead of stdout.
-f, --follow Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.
-n, --length int Number of lines back to go within the log (default 60)

View File

@ -575,6 +575,7 @@
"Setting profile failed": "Setzten des Profiles fehlgeschlagen",
"Show a list of global command-line options (applies to all commands).": "Zeige eine Liste von globalen Kommandozeilen Parametern (die auf alle Befehle angewendet werden können)",
"Show only log entries which point to known problems": "Zeige nur Log Einträge, die auf bekannte Probleme hinweisen",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "Zeige die aktuellsten Journal Einträge und gebe neue Einträge aus, sobald diese im Journal eingetragen werden.",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "Simuliere den Numa Node Count in Minikube, der unterstützte Numa Node Count Bereich ist 1-8 (nur kvm2 Treiber)",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "Wechsel des kubectl Kontexts für {{.profile_name}} übersprungen, weil --keep-context gesetzt wurde.",

View File

@ -582,6 +582,7 @@
"Setting profile failed": "",
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",

View File

@ -557,6 +557,7 @@
"Setting profile failed": "Échec de la définition du profil",
"Show a list of global command-line options (applies to all commands).": "Affiche une liste des options de ligne de commande globales (s'applique à toutes les commandes).",
"Show only log entries which point to known problems": "Afficher uniquement les entrées de journal qui pointent vers des problèmes connus",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "Affichez uniquement les entrées de journal les plus récentes et imprimez en continu de nouvelles entrées au fur et à mesure qu'elles sont ajoutées au journal.",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "Simulez le nombre de nœuds numa dans minikube, la plage de nombre de nœuds numa pris en charge est de 1 à 8 (pilote kvm2 uniquement)",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "Changement de contexte kubectl ignoré pour {{.profile_name}} car --keep-context a été défini.",

View File

@ -573,6 +573,7 @@
"Setting profile failed": "プロファイルの設定に失敗しました",
"Show a list of global command-line options (applies to all commands).": "(全コマンドに適用される) グローバルコマンドラインオプションの一覧を表示します。",
"Show only log entries which point to known problems": "既知の問題を示すログエントリーのみ表示します",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "直近のジャーナルエントリーのみ表示し、ジャーナルに追加された新しいエントリーを連続して表示します。",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "minikube 中の NUMA ノードカウントをシミュレートします (対応 NUMA ノードカウント範囲は 18 (kvm2 ドライバーのみ))",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "--keep-context が設定されたので、{{.profile_name}} 用 kubectl コンテキストの切替をスキップしました。",

View File

@ -594,6 +594,7 @@
"Setting profile failed": "프로필 설정이 실패하였습니다",
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",

View File

@ -595,6 +595,7 @@
"Setting profile failed": "Ustawianie profilu nie powiodło się",
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "Pokaż logi które wskazują na znane problemy",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "Zignorowano zmianę kontekstu kubectl dla {{.profile_name}} ponieważ --keep-context zostało przekazane",

View File

@ -542,6 +542,7 @@
"Setting profile failed": "",
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",

View File

@ -542,6 +542,7 @@
"Setting profile failed": "",
"Show a list of global command-line options (applies to all commands).": "",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",

View File

@ -678,6 +678,7 @@
"Setting profile failed": "设置配置文件失败",
"Show a list of global command-line options (applies to all commands).": "显示全局命令行选项列表 (应用于所有命令)。",
"Show only log entries which point to known problems": "",
"Show only the audit logs": "",
"Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.": "",
"Simulate numa node count in minikube, supported numa node count range is 1-8 (kvm2 driver only)": "",
"Skipped switching kubectl context for {{.profile_name}} because --keep-context was set.": "",