rewrap

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackupManager

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

BackupManager handles creation and restoration of key file backups.

func NewBackupManager

func NewBackupManager(options BackupOptions) *BackupManager

NewBackupManager creates a new backup manager.

func (*BackupManager) BackupExists

func (m *BackupManager) BackupExists(originalPath string) bool

BackupExists checks if a backup file exists for the given path.

func (*BackupManager) CreateBackup

func (m *BackupManager) CreateBackup(filePath string) (string, error)

CreateBackup creates a backup copy of a file atomically. Returns the backup file path if successful.

func (*BackupManager) GetBackupPath

func (m *BackupManager) GetBackupPath(originalPath string) string

GetBackupPath returns the backup path for a given file.

func (*BackupManager) RemoveBackup

func (m *BackupManager) RemoveBackup(originalPath string) error

RemoveBackup deletes a backup file.

func (*BackupManager) RestoreBackup

func (m *BackupManager) RestoreBackup(originalPath string) error

RestoreBackup restores a file from its backup.

type BackupOptions

type BackupOptions struct {
	Enabled bool   // Create backups
	Suffix  string // Backup file suffix
}

BackupOptions configures backup behavior.

type Reporter

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

Reporter generates statistics and reports from rewrap results.

func NewReporter

func NewReporter() *Reporter

NewReporter creates a new statistics reporter.

func (*Reporter) AddResult

func (r *Reporter) AddResult(result *vault.RewrapResult)

AddResult processes a rewrap result and updates statistics.

func (*Reporter) AddResults

func (r *Reporter) AddResults(results []*vault.RewrapResult)

AddResults processes multiple results.

func (*Reporter) GetFailedFiles

func (r *Reporter) GetFailedFiles() []string

GetFailedFiles returns a list of files that failed to rewrap.

func (*Reporter) GetSkippedFiles

func (r *Reporter) GetSkippedFiles() []string

GetSkippedFiles returns files that were skipped

func (*Reporter) GetStatistics

func (r *Reporter) GetStatistics() *Statistics

GetStatistics returns the current statistics.

func (*Reporter) GetSuccessfulFiles

func (r *Reporter) GetSuccessfulFiles() []string

GetSuccessfulFiles returns a list of files that were successfully rewrapped.

func (*Reporter) WriteCSV

func (r *Reporter) WriteCSV(w io.Writer) error

WriteCSV outputs statistics in CSV format.

func (*Reporter) WriteJSON

func (r *Reporter) WriteJSON(w io.Writer, includeResults bool) error

WriteJSON outputs statistics in JSON format.

func (*Reporter) WriteText

func (r *Reporter) WriteText(w io.Writer, includeDetails bool) error

WriteText outputs statistics in human-readable text format.

type RewrapOptions

type RewrapOptions struct {
	VaultClient  *vault.Client // Vault client for rewrapping
	MinVersion   int           // Minimum key version to require
	DryRun       bool          // If true, don't modify files
	CreateBackup bool          // Whether to create backups
	BackupSuffix string        // Backup file suffix (default: ".bak")
	Logger       logger.Logger // Logger interface (not pointer)
}

RewrapOptions configures the rewrap operation.

type Rewrapper

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

Rewrapper orchestrates the key re-wrapping process.

func NewRewrapper

func NewRewrapper(options RewrapOptions) (*Rewrapper, error)

NewRewrapper creates a new key re-wrapper.

func (*Rewrapper) RewrapBatch

func (r *Rewrapper) RewrapBatch(ctx context.Context, keyFiles []string) ([]*vault.RewrapResult, error)

RewrapBatch processes multiple key files.

func (*Rewrapper) RewrapFile

func (r *Rewrapper) RewrapFile(ctx context.Context, keyFilePath string) (*vault.RewrapResult, error)

RewrapFile processes a single .key file.

type ScanOptions

type ScanOptions struct {
	Directory string // Root directory to scan
	Recursive bool   // Scan subdirectories recursively
}

ScanOptions configures the key file scanner.

type ScanResult

type ScanResult struct {
	Files []string // Discovered .key file paths
	Count int      // Number of files found
	Error error    // Error if scan failed
}

ScanResult represents the outcome of scanning a directory for key files.

func ScanSingleFile

func ScanSingleFile(filePath string) (*ScanResult, error)

ScanSingleFile validates and returns a single .key file path. This is a convenience function for processing a single file.

type Scanner

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

Scanner finds .key files in a directory structure.

func NewScanner

func NewScanner(options ScanOptions) (*Scanner, error)

NewScanner creates a new key file scanner.

func (*Scanner) Scan

func (s *Scanner) Scan() (*ScanResult, error)

Scan searches for .key files according to the configured options.

type Statistics

type Statistics struct {
	TotalFiles    int                   `json:"total_files"`
	Successful    int                   `json:"successful"`
	Failed        int                   `json:"failed"`
	Skipped       int                   `json:"skipped"`
	VersionCounts map[int]int           `json:"version_counts"`
	Results       []*vault.RewrapResult `json:"results,omitempty"`
}

Statistics contains aggregated rewrap operation statistics.

Jump to

Keyboard shortcuts

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