You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which convention should we adopt/follow to log error when we call a CLI command.
Return error to the caller (yes/no)
Do we have to format the errors within the function called and return the error to the caller ?
fmt.Errorf("building labels with key %s and value %s : %w", v1alpha1.CLISecretLabelKey, v1alpha1.CLISecretLabelValue, err)
Log messages or errors within a function called (yes/no)
Can we also log messages (info, debug, warning or error) within a function called by a command ?.
Log verbose level
I'm a bit confused about what logr reports when we set the verbosity to V(1)
logger.V(1).Info(fmt.Sprintf("Got the context for the cluster: %s.", cluster))
This generates =>
Nov 15 13:32:07 DEBUG+3 Got the context for the cluster: my-konflux.
How such a V level int is mapped to the following values: debug, info, warn, and error listed by a command using -h
❯ ./idpbuilder get clusters -h
Get idp clusters
Usage:
idpbuilder get clusters [flags]
Flags:
-h, --help help for clusters
Global Flags:
--color Enable colored log messages.
--kubePath string kube config file Path.
-l, --log-level string Set the log verbosity. Supported values are: debug, info, warn, and error. (default "info")
Os exit (yes/no)
Should we also call os.exit when a blocking error is discovered (example : it is needed to have access to a kube cluster but we cannot) within a function called by a CLI command
See example hereafter
var ClustersCmd = &cobra.Command{
Use: "clusters",
Short: "Get idp clusters",
Long: ``,
RunE: list,
PreRunE: preClustersE,
}
func preClustersE(cmd *cobra.Command, args []string) error {
return helpers.SetLogger()
}
func list(cmd *cobra.Command, args []string) error {
clusters, err := populateClusterList()
if err != nil {
return err
} else {
// Convert the list of the clusters to Table of clusters
printTable(printers.PrintOptions{}, generateClusterTable(clusters))
return nil
}
}
func populateClusterList() ([]Cluster, error) {
logger := helpers.CmdLogger
detectOpt, err := util.DetectKindNodeProvider()
if err != nil {
logger.Error(err, "failed to detect the provider.")
os.Exit(1)
}
Questions
Which convention should we adopt/follow to log error when we call a CLI command.
Return error to the caller (yes/no)
Do we have to format the errors within the function called and return the error to the caller ?
Log messages or errors within a function called (yes/no)
Can we also log messages (info, debug, warning or error) within a function called by a command ?.
Log verbose level
I'm a bit confused about what logr reports when we set the verbosity to V(1)
This generates =>
How such a V level int is mapped to the following values:
debug, info, warn, and error
listed by a command using-h
Os exit (yes/no)
Should we also call
os.exit
when a blocking error is discovered (example : it is needed to have access to a kube cluster but we cannot) within a function called by a CLI commandSee example hereafter
@nabuskey @nimakaviani @greghaynes
The text was updated successfully, but these errors were encountered: