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

Issue 18016: Add infos count to oc status #18422

Merged
merged 1 commit into from
Feb 5, 2018
Merged
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
32 changes: 22 additions & 10 deletions pkg/oc/cli/describe/projectstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error

// We print errors by default and warnings if -v is used. If we get none,
// this would be an extra new line.
if len(errorMarkers) != 0 || (d.Suggest && len(warningMarkers) != 0) {
if len(errorMarkers) != 0 || len(infoMarkers) != 0 || (d.Suggest && len(warningMarkers) != 0) {
fmt.Fprintln(out)
}

errors, warnings := "", ""
errors, warnings, infos := "", "", ""
if len(errorMarkers) == 1 {
errors = "1 error"
} else if len(errorMarkers) > 1 {
Expand All @@ -355,16 +355,28 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error
} else if len(warningMarkers) > 1 {
warnings = fmt.Sprintf("%d warnings", len(warningMarkers))
}
if len(infoMarkers) == 1 {
infos = "1 info"
} else if len(infoMarkers) > 0 {
infos = fmt.Sprintf("%d infos", len(infoMarkers))
}

switch {
case !d.Suggest && len(errorMarkers) > 0 && len(warningMarkers) > 0:
fmt.Fprintf(out, "%s and %s identified, use '%[3]s status -v' to see details.\n", errors, warnings, d.CommandBaseName)

case !d.Suggest && len(errorMarkers) > 0 && errorSuggestions > 0:
fmt.Fprintf(out, "%s identified, use '%[2]s status -v' to see details.\n", errors, d.CommandBaseName)
markerStrings := []string{errors, warnings, infos}
markerString := ""
count := 0
for _, m := range markerStrings {
if len(m) > 0 {
if count > 0 {
markerString = fmt.Sprintf("%s, ", markerString)
}
markerString = fmt.Sprintf("%s%s", markerString, m)
count++
}
}

case !d.Suggest && len(warningMarkers) > 0:
fmt.Fprintf(out, "%s identified, use '%[2]s status -v' to see details.\n", warnings, d.CommandBaseName)
switch {
case !d.Suggest && ((len(errorMarkers) > 0 && errorSuggestions > 0) || len(warningMarkers) > 0 || len(infoMarkers) > 0):
fmt.Fprintf(out, "%s identified, use '%s status -v' to see details.\n", markerString, d.CommandBaseName)
Copy link
Contributor

@juanvallejo juanvallejo Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where the count for each of these is printed.

EDIT: nevermind, see it now. Mind having a separate branch for a single info above?

if len(infoMarkers) == 1 {
    ...
} else if len(infoMarkers) > 1 

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I wasn't sure if it grammatically made more sense to have, eg, "2 infos identified" vs "2 info identified"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated


case (len(services) == 0) && (len(standaloneDCs) == 0) && (len(standaloneImages) == 0):
fmt.Fprintln(out, "You have no services, deployment configs, or build configs.")
Expand Down