common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogAndReturnError

func LogAndReturnError[T any](logger *zap.SugaredLogger, newResponse func(string) *T, errMsg string, err error) (*T, error)

LogAndReturnError logs error and returns standardized response This function creates a response object with the given message constructor function

func LogAndReturnErrorWithEvent

func LogAndReturnErrorWithEvent[T any](logger *zap.SugaredLogger, recorder EventRecorder, newResponse func(string) *T, unitName, namespace, reason, errMsg string, err error) (*T, error)

LogAndReturnErrorWithEvent logs error, sends warning event, and returns standardized response

func LogAndReturnSuccess

func LogAndReturnSuccess[T any](logger *zap.SugaredLogger, newResponse func(string) *T, msg string) (*T, error)

LogAndReturnSuccess logs success and returns response This function creates a response object with the given message constructor function

func LogAndReturnSuccessWithEvent

func LogAndReturnSuccessWithEvent[T any](logger *zap.SugaredLogger, recorder EventRecorder, newResponse func(string) *T, unitName, namespace, reason, msg string) (*T, error)

LogAndReturnSuccessWithEvent logs success, sends normal event, and returns response

func LogRequestSafely

func LogRequestSafely(logger *zap.SugaredLogger, operation string, data map[string]interface{})

LogRequestSafely logs request information with sensitive data masked

func SanitizeForLogging

func SanitizeForLogging(data map[string]interface{}) map[string]interface{}

SanitizeForLogging sanitizes sensitive information for logging

Types

type CommandExecutor

type CommandExecutor struct {
	// contains filtered or unexported fields
}

CommandExecutor encapsulates command execution logic

func NewCommandExecutor

func NewCommandExecutor(ctx context.Context, logger *zap.SugaredLogger) *CommandExecutor

NewCommandExecutor creates a new command executor

func (*CommandExecutor) ExecuteCommand

func (e *CommandExecutor) ExecuteCommand(cmd *exec.Cmd, logPrefix string) error

ExecuteCommand executes a single command with stderr logging

func (*CommandExecutor) ExecutePipedCommands

func (e *CommandExecutor) ExecutePipedCommands(cmd1 *exec.Cmd, cmd2 *exec.Cmd, logPrefix string) error

ExecutePipedCommands executes two commands with pipe connection

type EventRecorder

type EventRecorder interface {
	SendWarningEventToUnit(unitName, namespace, reason, message string) error
	SendNormalEventToUnit(unitName, namespace, reason, message string) error
}

EventRecorder interface for sending events

type Response

type Response interface {
	GetMessage() string
}

Response interface for response types with Message field

type ResponseWithMessage

type ResponseWithMessage struct {
	Message string `json:"message"`
}

ResponseWithMessage represents any response type that has a Message field

func (*ResponseWithMessage) GetMessage

func (r *ResponseWithMessage) GetMessage() string

GetMessage implements Response interface

Jump to

Keyboard shortcuts

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