Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( RegisterAuditLogFn = registerAuditLog GetAuditLogFn = getAuditLog )
Functions ¶
func Register ¶
func Register(cfg *config.AuditLogConfig)
Register registers the audit log plugin with the given configuration.
func ResetAuditLog ¶
func ResetAuditLog()
ResetAuditLog clears the registered audit log (for testing).
Types ¶
type AuditLog ¶
type AuditLog interface {
Name() string
Description() string
Version() string
// RecordEntry logs a version bump with metadata.
RecordEntry(entry *Entry) error
// IsEnabled returns whether the plugin is enabled.
IsEnabled() bool
// GetConfig returns the plugin configuration.
GetConfig() *Config
}
AuditLog defines the interface for audit logging.
type AuditLogFile ¶
type AuditLogFile struct {
Entries []Entry `json:"entries" yaml:"entries"`
}
AuditLogFile represents the structure of the audit log file.
type AuditLogPlugin ¶
type AuditLogPlugin struct {
// contains filtered or unexported fields
}
AuditLogPlugin implements the AuditLog interface.
func NewAuditLog ¶
func NewAuditLog(cfg *Config) *AuditLogPlugin
NewAuditLog creates a new audit log plugin.
func NewAuditLogWithOps ¶
func NewAuditLogWithOps(cfg *Config, gitOps GitOperations, fileOps FileOperations) *AuditLogPlugin
NewAuditLogWithOps creates a new audit log plugin with custom operations (for testing).
func (*AuditLogPlugin) Description ¶
func (p *AuditLogPlugin) Description() string
Description returns the plugin description.
func (*AuditLogPlugin) GetConfig ¶
func (p *AuditLogPlugin) GetConfig() *Config
GetConfig returns the plugin configuration.
func (*AuditLogPlugin) IsEnabled ¶
func (p *AuditLogPlugin) IsEnabled() bool
IsEnabled returns whether the plugin is enabled.
func (*AuditLogPlugin) RecordEntry ¶
func (p *AuditLogPlugin) RecordEntry(entry *Entry) error
RecordEntry logs a version bump with metadata.
func (*AuditLogPlugin) Version ¶
func (p *AuditLogPlugin) Version() string
Version returns the plugin version.
type Config ¶
type Config struct {
// Enabled controls whether the plugin is active.
Enabled bool
// Path is the path to the audit log file.
Path string
// Format specifies the output format: json or yaml.
Format string
// IncludeAuthor includes git author in log entries.
IncludeAuthor bool
// IncludeTimestamp includes ISO 8601 timestamp in log entries.
IncludeTimestamp bool
// IncludeCommitSHA includes current commit SHA in log entries.
IncludeCommitSHA bool
// IncludeBranch includes current branch name in log entries.
IncludeBranch bool
}
Config holds configuration for the audit log plugin.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default audit log configuration.
func FromConfigStruct ¶
func FromConfigStruct(cfg *config.AuditLogConfig) *Config
FromConfigStruct converts the config package struct to internal config.
type DefaultFileOps ¶
type DefaultFileOps struct{}
DefaultFileOps implements FileOperations using standard library.
func (*DefaultFileOps) FileExists ¶
func (f *DefaultFileOps) FileExists(path string) bool
FileExists checks if a file exists.
type DefaultGitOps ¶
type DefaultGitOps struct{}
DefaultGitOps implements GitOperations using git commands.
func (*DefaultGitOps) GetAuthor ¶
func (g *DefaultGitOps) GetAuthor() (string, error)
GetAuthor returns the git user name and email.
func (*DefaultGitOps) GetBranch ¶
func (g *DefaultGitOps) GetBranch() (string, error)
GetBranch returns the current branch name.
func (*DefaultGitOps) GetCommitSHA ¶
func (g *DefaultGitOps) GetCommitSHA() (string, error)
GetCommitSHA returns the current commit SHA.
type Entry ¶
type Entry struct {
Timestamp string `json:"timestamp,omitempty" yaml:"timestamp,omitempty"`
PreviousVersion string `json:"previous_version" yaml:"previous_version"`
NewVersion string `json:"new_version" yaml:"new_version"`
BumpType string `json:"bump_type" yaml:"bump_type"`
Author string `json:"author,omitempty" yaml:"author,omitempty"`
CommitSHA string `json:"commit_sha,omitempty" yaml:"commit_sha,omitempty"`
Branch string `json:"branch,omitempty" yaml:"branch,omitempty"`
}
Entry represents a single audit log entry.