export

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package export provides functionality to export data to files.

Index

Constants

View Source
const (
	// DefaultFilePermissions defines the default file permissions for exported files.
	DefaultFilePermissions = 0o600
)

File export constants for permissions and platform detection.

Variables

View Source
var (
	// ErrPathNotRegularFile is returned when the target path exists but is not a regular file.
	ErrPathNotRegularFile = errors.New("path exists but is not a regular file")
	// ErrEmptyContent is returned when attempting to export empty content.
	ErrEmptyContent = errors.New("cannot export empty content")
	// ErrOperationCancelled is returned when an export operation is cancelled by context.
	ErrOperationCancelled = errors.New("operation cancelled by context")
)

Define static errors for better error handling.

View Source
var ErrNoResolvableAncestor = errors.New("no resolvable ancestor directory")

ErrNoResolvableAncestor is returned when no ancestor directory of a path can be resolved.

Functions

This section is empty.

Types

type Error

type Error struct {
	Operation string // The operation that failed (e.g., "validate_path", "create_directory", "write_file")
	Path      string // The file path involved in the error
	Message   string // Human-readable error message
	Cause     error  // The underlying error that caused this export error
}

Error represents an error that occurred during file export operations.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface for Error.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying error.

type FileExporter

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

FileExporter is a file exporter for OPNsense configurations.

func NewFileExporter

func NewFileExporter(logger *logging.Logger) *FileExporter

NewFileExporter creates and returns a new FileExporter for writing data to files. If logger is nil, operations will continue without logging (graceful degradation).

func (*FileExporter) Export

func (e *FileExporter) Export(ctx context.Context, content, path string) error

Export exports an OPNsense configuration to a file with comprehensive validation and error handling.

Jump to

Keyboard shortcuts

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