Documentation
¶
Overview ¶
Copyright © 2025 NAME HERE <EMAIL ADDRESS>
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CheckCmd = &cobra.Command{ Use: "check", Aliases: []string{"chk"}, Short: "Analyzes a stack from a YAML file, checks each component’s EOL status.", Long: `The 'check' command analyzes each software component listed in your stack YAML file (default: .geol.yaml), retrieves End-of-Life (EOL) information, and displays the EOL status report. Great to identify outdated software in a given stack. Try using 'geol check init' to generate a sample stack YAML file. See https://opt-nc.github.io/geol/docs/tutorial-basics/check-command for more`, Example: `geol check geol check --file stack.yaml geol check --json`, Run: func(cmd *cobra.Command, args []string) { file, _ := cmd.Flags().GetString("file") strict, _ := cmd.Flags().GetBool("strict") jsonOutput, _ := cmd.Flags().GetBool("json") _, err := os.Stat(file) if err != nil { log.Fatal().Msg("Error: the file does not exist: " + file) } data, err := os.ReadFile(file) if err != nil { log.Fatal().Msg("Error reading file: " + err.Error()) } var config geolConfig if err := yaml.Unmarshal(data, &config); err != nil { log.Fatal().Msg("YAML format error: " + err.Error()) } validation := checkRequiredKeys(config) hasErrors := false if len(validation.missing) > 0 { for _, missing := range validation.missing { log.Error().Msgf("Missing or empty key: %s", missing) } hasErrors = true } if len(validation.duplicates) > 0 { for _, duplicate := range validation.duplicates { log.Error().Msg(duplicate) } hasErrors = true } if hasErrors { log.Fatal().Msg("Validation failed: please fix the errors above") } utilities.AnalyzeCacheProductsValidity(cmd) today := time.Now() if dateStr, _ := cmd.Flags().GetString("date"); dateStr != "" { parsed, err := time.Parse("2006-01-02", dateStr) if err != nil { log.Fatal().Msgf("Invalid --date format: %q (expected YYYY-MM-DD)", dateStr) } today = parsed log.Info().Msgf("Using reference date: %s", dateStr) } rows, errorOut, violations := getStackTableRows(config.Stack, today) if jsonOutput { output := struct { Title string `json:"title"` SoftwareComponents []stackTableRow `json:"software_components"` }{ Title: config.AppName, SoftwareComponents: rows, } jsonData, err := json.MarshalIndent(output, "", " ") if err != nil { log.Fatal().Msg("Error generating JSON output: " + err.Error()) } fmt.Println(string(jsonData)) } else { tableStr := renderStackTable(rows) styledTitle := lipgloss.NewStyle(). Bold(true).Foreground(lipgloss.Color("#FFFF88")). Background(lipgloss.Color("#5F5FFF")). Render("## " + config.AppName) _, _ = lipgloss.Println(styledTitle) _, _ = lipgloss.Println(tableStr) } if len(violations) > 0 { for _, violation := range violations { log.Error().Msg(violation) } } if errorOut && strict { log.Fatal().Msg("One or more products are past EOL or not in latest version. Exiting with error due to strict mode.") } }, }
checkCmd represents the check command
View Source
var InitCmd = &cobra.Command{ Use: "init", Aliases: []string{"i"}, Short: "Generate a valid template configuration file for check command", Long: `The init command generates a default configuration file for the check command. Use this command to create a starter YAML file that you can customize for your environment. You can specify the output path with the --output flag. Use --force to overwrite an existing file.`, Example: `geol check init geol check init --output stack.yaml geol check init --output stack.yaml --force`, Run: func(cmd *cobra.Command, args []string) { templates.GenerateCheckTemplate(output, force, appName, appID) }, }
InitCmd represents the init command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.