servicelog

package
v0.68.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const InternalOnlyTemplate = `` /* 149-byte string literal not displayed */

InternalOnlyTemplate is the fixed JSON template used for internal-only service logs (the -i flag in the CLI).

Variables

View Source
var ErrDeclined = errors.New("service log not sent: user declined")

Functions

func CheckServiceLogsLastHour

func CheckServiceLogsLastHour(ocmClient *sdk.Connection, clusterID string) bool

checkServiceLogsLastHour returns true if there were service logs sent in the past hour, printing warnings for each one found.

func FetchServiceLogs

func FetchServiceLogs(ocmClient *sdk.Connection, clusterID string, allMessages bool, internalOnly bool) (*v1.ClustersClusterLogsListResponse, error)

FetchServiceLogs retrieves all service logs for a cluster.

func GetServiceLogsSince

func GetServiceLogsSince(ocmClient *sdk.Connection, clusterID string, timeSince time.Time, allMessages bool, internalOnly bool) ([]*v1.LogEntry, error)

GetServiceLogsSince returns the service logs for a cluster sent since the given time.

func Post

func Post(ocmClient *sdk.Connection, cluster *cmv1.Cluster, req PostRequest) error

Post sends a service log to a cluster from a template. It handles the full pipeline: template loading, parameter substitution, link validation, user confirmation, and HTTP POST. It always runs an interactive confirmation flow. For non-interactive sends (e.g. batch operations that confirm upfront), use Prepare + PostMessage directly.

func PostMessage

func PostMessage(ocmClient *sdk.Connection, cluster *cmv1.Cluster, msg Message) error

PostMessage posts a pre-built Message to a cluster. It sets cluster-specific fields (ClusterUUID, ClusterID, SubscriptionID) and sends the HTTP request. No template loading or prompting.

Types

type Message

type Message struct {
	Severity       string   `json:"severity"`
	ServiceName    string   `json:"service_name"`
	ClusterUUID    string   `json:"cluster_uuid,omitempty"`
	ClusterID      string   `json:"cluster_id,omitempty"`
	Summary        string   `json:"summary"`
	Description    string   `json:"description"`
	InternalOnly   bool     `json:"internal_only"`
	EventStreamID  string   `json:"event_stream_id"`
	SubscriptionID string   `json:"subscription_id,omitempty"`
	DocReferences  []string `json:"doc_references"`
}

func Prepare

func Prepare(req PostRequest) (Message, error)

Prepare loads a template, substitutes parameters, and validates links, returning a Message ready for PostMessage. Use this to prepare once and send to multiple clusters without re-fetching the template.

func (*Message) FindLeftovers

func (m *Message) FindLeftovers() []string

func (*Message) ReplaceWithFlag

func (m *Message) ReplaceWithFlag(variable, value string)

func (*Message) SearchFlag

func (m *Message) SearchFlag(placeholder string) bool

type PostRequest

type PostRequest struct {
	Template       string
	TemplateParams []string
	InternalOnly   bool
	SkipLinkCheck  bool
}

PostRequest describes what to send and how to interact with the user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL