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

Enable LongServiceOutput header/label for payloads #292

Merged
merged 1 commit into from
Nov 6, 2024
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
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