export

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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
)

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.

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 Exporter

type Exporter interface {
	Export(ctx context.Context, content, path string) error
}

Exporter is the interface for exporting OPNsense configurations.

type FileExporter

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

FileExporter is a file exporter for OPNsense configurations.

func NewFileExporter

func NewFileExporter(logger *log.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