utils

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package common provides shared utilities for output plugins.

Package common provides shared utilities for output plugins.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidPath added in v0.1.28

func IsValidPath(path string) bool

IsValidPath checks if a path is safe to use in exec.Command arguments. It rejects paths containing directory traversal (..) or shell metacharacters that could be exploited if the path were ever passed through a shell. This is defense-in-depth — exec.Command does not invoke a shell, but we guard against future misuse.

func MakeScriptExecutable added in v0.1.28

func MakeScriptExecutable(writtenFiles []string, scriptName string, verbose bool)

MakeScriptExecutable searches writtenFiles for a file with the given base name and makes it executable (0o750). Errors are logged as warnings when verbose is true but never returned — a non-executable script is not fatal.

func TemplateFuncs

func TemplateFuncs() template.FuncMap

TemplateFuncs returns standard template functions for all output plugins. This delegates to the public pkg/template.TemplateFuncs() to avoid duplication. Both internal and external plugins use the same template functions for consistency.

Types

type VerboseLogger

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

VerboseLogger implements a simple logger that writes to an io.Writer. This is used by output plugins that need to log verbose information. during template processing or generation.

func NewVerboseLogger

func NewVerboseLogger(out io.Writer) *VerboseLogger

NewVerboseLogger creates a new VerboseLogger that writes to the given writer.

func (*VerboseLogger) Printf

func (l *VerboseLogger) Printf(format string, v ...any)

Printf writes a formatted message to the logger's output writer. A newline is automatically appended to the format string.

Jump to

Keyboard shortcuts

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