Skip to content

Commit

Permalink
Merge pull request #292 from atc0005/i251-enable-longserviceoutput-if…
Browse files Browse the repository at this point in the history
…-payload-provided

Enable LongServiceOutput header/label for payloads
  • Loading branch information
atc0005 authored Nov 6, 2024
2 parents de7347f + bd863c6 commit d3e9e11
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sections.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,17 @@ func (p Plugin) handleLongServiceOutput(w io.Writer) {
var totalWritten int

// Hide section header/label if threshold and error values were not
// specified by client code or if client code opted to explicitly hide
// those sections; there is no need to use a header to separate the
// LongServiceOutput from those sections if they are not displayed.
// specified by client code, if client code opted to explicitly hide
// threshold or error sections or if no encoded payload content was
// provided; there is no need to use a header to separate the
// LongServiceOutput from those sections if they are not displayed (or
// provided in the case of an encoded payload).
//
// If we hide the section header, we still provide some padding to
// prevent the LongServiceOutput from running up against the
// ServiceOutput content.
switch {
case !p.isThresholdsSectionHidden() || !p.isErrorsHidden():
case !p.isThresholdsSectionHidden() || !p.isErrorsHidden() || !p.isPayloadSectionHidden():
written, err := fmt.Fprintf(w,
"%s**%s**%s",
CheckOutputEOL,
Expand Down Expand Up @@ -366,6 +368,12 @@ func (p Plugin) isErrorsHidden() bool {
return false
}

// isPayloadSectionHidden indicates whether the Payload section should be
// omitted from output.
func (p Plugin) isPayloadSectionHidden() bool {
return p.encodedPayloadBuffer.Len() == 0
}

// getThresholdsLabelText retrieves the custom thresholds label text if set,
// otherwise returns the default value.
func (p Plugin) getThresholdsLabelText() string {
Expand Down

0 comments on commit d3e9e11

Please sign in to comment.