Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure Improvements in main file /kind cleanup #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func Main() {
func Run(logger log.Logger, streams kindcmd.IOStreams, args []string) error {
// NOTE: we handle the quiet flag here so we can fully silence cobra
if checkQuiet(args) {
// if we are in quiet mode, we want to suppress all status output
// only streams.Out should be written to (program output)
// If we are in quiet mode, we want to suppress all status output
// Only streams.Out should be written to (program output)
logger = log.NoopLogger{}
streams.ErrOut = ioutil.Discard
}
// actually run the command
// Actually run the command
c := cmd.NewCommand(logger, streams)
c.SetArgs(args)
if err := c.Execute(); err != nil {
Expand Down Expand Up @@ -61,25 +61,25 @@ func checkQuiet(args []string) bool {
return quiet
}

// logError logs the error and the root stacktrace if there is one
// logError logs the error and the root stack trace if there is one
func logError(logger log.Logger, err error) {
colorEnabled := kindcmd.ColorEnabled(logger)
if colorEnabled {
logger.Errorf("\x1b[31mERROR\x1b[0m: %v", err)
} else {
logger.Errorf("ERROR: %v", err)
}
// Display Output if the error was from running a command ...
if err := exec.RunErrorForError(err); err != nil {
// Display output if the error was from running a command ...
if execErr := exec.RunErrorForError(err); execErr != nil {
if colorEnabled {
logger.Errorf("\x1b[31mCommand Output\x1b[0m: %s", err.Output)
logger.Errorf("\x1b[31mCommand Output\x1b[0m: %s", execErr.Output)
} else {
logger.Errorf("\nCommand Output: %s", err.Output)
logger.Errorf("\nCommand Output: %s", execErr.Output)
}
}
// TODO: stacktrace should probably be guarded by a higher level ...?
// TODO: Stack trace should probably be guarded by a higher level ...?
if logger.V(1).Enabled() {
// Then display stack trace if any (there should be one...)
// Then display the stack trace if any (there should be one...)
if trace := errors.StackTrace(err); trace != nil {
if colorEnabled {
logger.Errorf("\x1b[31mStack Trace\x1b[0m: %+v", trace)
Expand Down
Binary file added oryxBuildBinary
Binary file not shown.