feat: wip fixing missing details

Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
This commit is contained in:
AlexsJones
2023-03-27 10:33:37 +01:00
parent 1bc839c48b
commit 0852c658de
2 changed files with 36 additions and 5 deletions

View File

@@ -31,11 +31,36 @@ K8sGPT uses analyzers to triage and diagnose issues in your cluster. It has a se
## Usage ## Usage
``` ```
# Ensure KUBECONFIG env is set to an active Kubernetes cluster Kubernetes debugging powered by AI
Usage:
k8sgpt [command]
Available Commands:
analyze This command will find problems within your Kubernetes cluster
auth Authenticate with your chosen backend
completion Generate the autocompletion script for the specified shell
help Help about any command
```
_Run a scan with the default analyzers_
```
k8sgpt auth k8sgpt auth
k8sgpt find problems k8sgpt analyze --explain
# for more detail ```
k8s find problems --explain
_Filter on resource_
```
k8sgpt analyze --explain --resource=Service
```
_Output to JSON_
```
k8sgpt analyze --explain --resource=Service --output=json
``` ```
## Upcoming major milestones ## Upcoming major milestones

View File

@@ -89,6 +89,11 @@ var AnalyzeCmd = &cobra.Command{
if len(*analysisResults) > 0 { if len(*analysisResults) > 0 {
bar = progressbar.Default(int64(len(*analysisResults))) bar = progressbar.Default(int64(len(*analysisResults)))
} }
// This variable is used to store the results that will be printed
// It's necessary because the heap memory is lost when the function returns
var printOutput []analyzer.Analysis
for _, analysis := range *analysisResults { for _, analysis := range *analysisResults {
if explain { if explain {
@@ -100,10 +105,11 @@ var AnalyzeCmd = &cobra.Command{
analysis.Details = parsedText analysis.Details = parsedText
bar.Add(1) bar.Add(1)
} }
printOutput = append(printOutput, analysis)
} }
// print results // print results
for n, analysis := range *analysisResults { for n, analysis := range printOutput {
switch output { switch output {
case "json": case "json":