analyze

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AnalyzeCmd = &cobra.Command{
	Use:     "analyze",
	Aliases: []string{"analyse"},
	Short:   "This command will find problems within your Kubernetes cluster",
	Long: `This command will find problems within your Kubernetes cluster and
	provide you with a list of issues that need to be resolved`,
	Run: func(cmd *cobra.Command, args []string) {

		config, err := analysis.NewAnalysis(
			backend,
			language,
			filters,
			namespace,
			nocache,
			explain,
			maxConcurrency,
			withDoc,
			interactiveMode,
		)

		if err != nil {
			color.Red("Error: %v", err)
			os.Exit(1)
		}
		defer config.Close()

		if customAnalysis {
			config.RunCustomAnalysis()
		}
		config.RunAnalysis()

		if explain {
			if err := config.GetAIResults(output, anonymize); err != nil {
				color.Red("Error: %v", err)
				os.Exit(1)
			}
		}

		output_data, err := config.PrintOutput(output)
		if err != nil {
			color.Red("Error: %v", err)
			os.Exit(1)
		}
		fmt.Println(string(output_data))

		if interactiveMode && explain {
			if output == "json" {
				color.Yellow("Caution: interactive mode using --json enabled may use additional tokens.")
			}
			sigs := make(chan os.Signal, 1)
			signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
			interactiveClient := interactive.NewInteractionRunner(config, output_data)

			go interactiveClient.StartInteraction()
			for {
				select {
				case res := <-sigs:
					switch res {
					default:
						os.Exit(0)
					}
				case res := <-interactiveClient.State:
					switch res {
					case interactive.E_EXITED:
						os.Exit(0)
					}
				}
			}
		}
	},
}

AnalyzeCmd represents the problems command

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL