export

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2025 License: Apache-2.0 Imports: 6 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 = errors.New("path exists but is not a regular file")
	ErrEmptyContent       = errors.New("cannot export empty content")
	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{}

FileExporter is a file exporter for OPNsense configurations.

func NewFileExporter

func NewFileExporter() *FileExporter

NewFileExporter creates and returns a new FileExporter for writing data to files.

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