repository

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Package repository provides functionality for interacting with bundle repositories

Package repository provides interfaces and implementations for accessing templates and modules

Index

Constants

This section is empty.

Variables

DefaultCacheManager is the default cache manager

View Source
var DefaultFactory = NewFactory()

DefaultFactory is the default repository factory with standard repository types registered

View Source
var DefaultManager = NewManager()

DefaultManager is the default repository manager

Functions

func AddRepository

func AddRepository(repo Repository) error

AddRepository adds a repository to the default manager

func ConnectAll

func ConnectAll(ctx context.Context) error

ConnectAll connects to all repositories in the default manager

func DisconnectAll

func DisconnectAll() error

DisconnectAll disconnects from all repositories in the default manager

func FindFiles

func FindFiles(ctx context.Context, pattern string) (map[Repository][]FileInfo, error)

FindFiles finds files matching a pattern in all repositories in the default manager

func FindFilesWithCache

func FindFilesWithCache(ctx context.Context, pattern string) (map[Repository][]FileInfo, error)

FindFiles finds files matching a pattern in all repositories with caching using the default cache manager

func GetFile

func GetFile(ctx context.Context, path string) (io.ReadCloser, error)

GetFile gets a file from any repository that has it in the default manager

func GetFileFromRepo

func GetFileFromRepo(ctx context.Context, repoName, path string) (io.ReadCloser, error)

GetFileFromRepo gets a file from a specific repository in the default manager

func GetFileFromRepoWithCache

func GetFileFromRepoWithCache(ctx context.Context, repoName, path string) (io.ReadCloser, error)

GetFileFromRepo gets a file from a specific repository with caching using the default cache manager

func GetFileWithCache

func GetFileWithCache(ctx context.Context, path string) (io.ReadCloser, error)

GetFile gets a file from any repository that has it with caching using the default cache manager

func RemoveRepository

func RemoveRepository(name string) error

RemoveRepository removes a repository from the default manager

Types

type BaseRepository

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

BaseRepository provides common functionality for all repository implementations

func NewBaseRepository

func NewBaseRepository(config *Config) *BaseRepository

NewBaseRepository creates a new base repository

func (*BaseRepository) AcquireConnection

func (r *BaseRepository) AcquireConnection(ctx context.Context) error

AcquireConnection acquires a connection from the pool

func (*BaseRepository) CreateContextWithTimeout

func (r *BaseRepository) CreateContextWithTimeout(ctx context.Context) (context.Context, context.CancelFunc)

CreateContextWithTimeout creates a context with the repository's timeout

func (*BaseRepository) GetLastError

func (r *BaseRepository) GetLastError() (error, time.Time)

GetLastError returns the last error and its time

func (*BaseRepository) GetName

func (r *BaseRepository) GetName() string

GetName returns the repository name

func (*BaseRepository) GetType

func (r *BaseRepository) GetType() RepositoryType

GetType returns the repository type

func (*BaseRepository) GetURL

func (r *BaseRepository) GetURL() string

GetURL returns the repository URL

func (*BaseRepository) IsConnected

func (r *BaseRepository) IsConnected() bool

IsConnected returns true if the repository is connected

func (*BaseRepository) ReleaseConnection

func (r *BaseRepository) ReleaseConnection()

ReleaseConnection releases a connection back to the pool

func (*BaseRepository) WithRetry

func (r *BaseRepository) WithRetry(ctx context.Context, operation func() error) error

WithRetry executes a function with retry logic

type CacheManager

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

CacheManager manages caching for repository operations

func NewCacheManager

func NewCacheManager(manager *Manager, options *CacheManagerOptions) *CacheManager

NewCacheManager creates a new cache manager

func (*CacheManager) Clear

func (c *CacheManager) Clear()

Clear clears all caches

func (*CacheManager) ClearFileCache

func (c *CacheManager) ClearFileCache()

ClearFileCache clears the file cache

func (*CacheManager) ClearQueryCache

func (c *CacheManager) ClearQueryCache()

ClearQueryCache clears the query cache

func (*CacheManager) FindFile

func (c *CacheManager) FindFile(ctx context.Context, path string) (Repository, error)

FindFile finds a file in all repositories with caching

func (*CacheManager) FindFiles

func (c *CacheManager) FindFiles(ctx context.Context, pattern string) (map[Repository][]FileInfo, error)

FindFiles finds files matching a pattern in all repositories with caching

func (*CacheManager) GetFile

func (c *CacheManager) GetFile(ctx context.Context, path string) (io.ReadCloser, error)

GetFile gets a file from any repository that has it with caching

func (*CacheManager) GetFileFromRepo

func (c *CacheManager) GetFileFromRepo(ctx context.Context, repoName, path string) (io.ReadCloser, error)

GetFileFromRepo gets a file from a specific repository with caching

func (*CacheManager) GetStats

func (c *CacheManager) GetStats() map[string]interface{}

GetStats returns statistics about the cache

func (*CacheManager) Prune

func (c *CacheManager) Prune() int

Prune removes old entries from all caches

func (*CacheManager) SetCompressionEnabled

func (c *CacheManager) SetCompressionEnabled(enabled bool)

SetCompressionEnabled sets whether compression is enabled

func (*CacheManager) SetCompressionLevel

func (c *CacheManager) SetCompressionLevel(level int)

SetCompressionLevel sets the compression level (1-9)

func (*CacheManager) SetDefaultTTL

func (c *CacheManager) SetDefaultTTL(ttl time.Duration)

SetDefaultTTL sets the default TTL for cache entries

func (*CacheManager) SetMaxSize

func (c *CacheManager) SetMaxSize(maxSize int)

SetMaxSize sets the maximum size of the caches

func (*CacheManager) SetPruneInterval

func (c *CacheManager) SetPruneInterval(interval time.Duration)

SetPruneInterval sets the interval at which to prune the cache

type CacheManagerOptions

type CacheManagerOptions struct {
	// EnableCache enables caching
	EnableCache bool
	// DefaultTTL is the default time-to-live for cache entries
	DefaultTTL time.Duration
	// MaxSize is the maximum size of the cache
	MaxSize int
	// EnableCompression enables compression of cached data
	EnableCompression bool
	// CompressionLevel is the compression level (1-9)
	CompressionLevel int
	// PruneInterval is the interval at which to prune the cache
	PruneInterval time.Duration
}

CacheManagerOptions represents options for the cache manager

func DefaultCacheManagerOptions

func DefaultCacheManagerOptions() *CacheManagerOptions

DefaultCacheManagerOptions returns default cache manager options

type CacheStats

type CacheStats struct {
	// QueryHits is the number of query cache hits
	QueryHits int64
	// QueryMisses is the number of query cache misses
	QueryMisses int64
	// FileHits is the number of file cache hits
	FileHits int64
	// FileMisses is the number of file cache misses
	FileMisses int64
	// TotalHits is the total number of cache hits
	TotalHits int64
	// TotalMisses is the total number of cache misses
	TotalMisses int64
	// TotalLookups is the total number of lookups
	TotalLookups int64
	// HitRatio is the overall hit ratio
	HitRatio float64
}

CacheStats tracks statistics for the cache manager

type Config

type Config struct {
	// Type is the repository type
	Type RepositoryType

	// Name is the repository name
	Name string

	// URL is the repository URL
	URL string

	// Branch is the repository branch (for Git repositories)
	Branch string

	// Username is the username for authentication
	Username string

	// Password is the password or token for authentication
	Password string

	// Timeout is the timeout for repository operations
	Timeout time.Duration

	// AuditLogger is the audit logger for repository operations
	AuditLogger *audit.AuditLogger

	// ProxyURL is the URL of the proxy server
	ProxyURL string

	// InsecureSkipVerify disables TLS certificate verification
	InsecureSkipVerify bool

	// MaxConnections is the maximum number of connections to the repository
	MaxConnections int

	// RetryCount is the number of times to retry a failed operation
	RetryCount int

	// RetryDelay is the delay between retries
	RetryDelay time.Duration
}

Config represents the configuration for a repository

func NewConfig

func NewConfig(repoType RepositoryType, name, url string) *Config

NewConfig creates a new repository configuration with default values

type DatabaseConfig

type DatabaseConfig struct {
	// Type is the database type
	Type DatabaseType

	// TableName is the name of the table storing templates
	TableName string

	// ConnectionString is the database connection string
	ConnectionString string
}

DatabaseConfig extends the repository Config with database-specific options

type DatabaseRepository

type DatabaseRepository struct {
	*BaseRepository
	// contains filtered or unexported fields
}

DatabaseRepository implements the Repository interface for database repositories

func (*DatabaseRepository) Connect

func (r *DatabaseRepository) Connect(ctx context.Context) error

Connect establishes a connection to the database repository

func (*DatabaseRepository) DeleteFile

func (r *DatabaseRepository) DeleteFile(ctx context.Context, path string) error

DeleteFile deletes a file from the database repository

func (*DatabaseRepository) Disconnect

func (r *DatabaseRepository) Disconnect() error

Disconnect closes the connection to the database repository

func (*DatabaseRepository) FileExists

func (r *DatabaseRepository) FileExists(ctx context.Context, path string) (bool, error)

FileExists checks if a file exists in the database repository

func (*DatabaseRepository) GetBranch

func (r *DatabaseRepository) GetBranch() string

GetBranch returns the branch of the repository Database repositories don't have branches, so this returns an empty string

func (*DatabaseRepository) GetFile

func (r *DatabaseRepository) GetFile(ctx context.Context, path string) (io.ReadCloser, error)

GetFile retrieves a file from the database repository

func (*DatabaseRepository) GetLastModified

func (r *DatabaseRepository) GetLastModified(ctx context.Context, path string) (time.Time, error)

GetLastModified gets the last modified time of a file in the database repository

func (*DatabaseRepository) ListFiles

func (r *DatabaseRepository) ListFiles(ctx context.Context, pattern string) ([]FileInfo, error)

ListFiles lists files in the database repository matching the pattern

func (*DatabaseRepository) StoreFile

func (r *DatabaseRepository) StoreFile(ctx context.Context, path string, name string, content []byte, isDirectory bool) error

StoreFile stores a file in the database repository

type DatabaseType

type DatabaseType string

DatabaseType represents the type of database

const (
	// MySQL database type
	MySQL DatabaseType = "mysql"
	// PostgreSQL database type
	PostgreSQL DatabaseType = "postgres"
	// SQLite database type
	SQLite DatabaseType = "sqlite"
)

type Factory

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

Factory creates repository instances based on configuration

func NewFactory

func NewFactory() *Factory

NewFactory creates a new repository factory

func (*Factory) Create

func (f *Factory) Create(config *Config) (Repository, error)

Create creates a repository instance based on the configuration

func (*Factory) Register

func (f *Factory) Register(repoType RepositoryType, creator RepositoryCreator)

Register registers a repository creator for a specific type

type FileInfo

type FileInfo struct {
	// Path is the path to the file within the repository
	Path string

	// Name is the name of the file
	Name string

	// Size is the size of the file in bytes
	Size int64

	// LastModified is the time the file was last modified
	LastModified time.Time

	// IsDirectory indicates if the file is a directory
	IsDirectory bool
}

FileInfo represents information about a file in a repository

type GitHubRepository

type GitHubRepository struct {
	*BaseRepository
	// contains filtered or unexported fields
}

GitHubRepository implements the Repository interface for GitHub repositories

func (*GitHubRepository) Connect

func (r *GitHubRepository) Connect(ctx context.Context) error

Connect establishes a connection to the GitHub repository

func (*GitHubRepository) Disconnect

func (r *GitHubRepository) Disconnect() error

Disconnect closes the connection to the GitHub repository

func (*GitHubRepository) FileExists

func (r *GitHubRepository) FileExists(ctx context.Context, path string) (bool, error)

FileExists checks if a file exists in the GitHub repository

func (*GitHubRepository) GetBranch

func (r *GitHubRepository) GetBranch() string

GetBranch returns the branch of the repository

func (*GitHubRepository) GetFile

func (r *GitHubRepository) GetFile(ctx context.Context, path string) (io.ReadCloser, error)

GetFile retrieves a file from the GitHub repository

func (*GitHubRepository) GetLastModified

func (r *GitHubRepository) GetLastModified(ctx context.Context, path string) (time.Time, error)

GetLastModified gets the last modified time of a file in the GitHub repository

func (*GitHubRepository) ListFiles

func (r *GitHubRepository) ListFiles(ctx context.Context, pattern string) ([]FileInfo, error)

ListFiles lists files in the GitHub repository matching the pattern

type GitLabRepository

type GitLabRepository struct {
	*BaseRepository
	// contains filtered or unexported fields
}

GitLabRepository implements the Repository interface for GitLab repositories

func (*GitLabRepository) Connect

func (r *GitLabRepository) Connect(ctx context.Context) error

Connect establishes a connection to the GitLab repository

func (*GitLabRepository) Disconnect

func (r *GitLabRepository) Disconnect() error

Disconnect closes the connection to the GitLab repository

func (*GitLabRepository) FileExists

func (r *GitLabRepository) FileExists(ctx context.Context, path string) (bool, error)

FileExists checks if a file exists in the GitLab repository

func (*GitLabRepository) GetBranch

func (r *GitLabRepository) GetBranch() string

GetBranch returns the branch of the repository

func (*GitLabRepository) GetFile

func (r *GitLabRepository) GetFile(ctx context.Context, path string) (io.ReadCloser, error)

GetFile retrieves a file from the GitLab repository

func (*GitLabRepository) GetLastModified

func (r *GitLabRepository) GetLastModified(ctx context.Context, path string) (time.Time, error)

GetLastModified gets the last modified time of a file in the GitLab repository

func (*GitLabRepository) ListFiles

func (r *GitLabRepository) ListFiles(ctx context.Context, pattern string) ([]FileInfo, error)

ListFiles lists files in the GitLab repository matching the pattern

type HTTPRepository

type HTTPRepository struct {
	*BaseRepository
	// contains filtered or unexported fields
}

HTTPRepository implements the Repository interface for HTTP/HTTPS repositories

func (*HTTPRepository) Connect

func (r *HTTPRepository) Connect(ctx context.Context) error

Connect establishes a connection to the HTTP repository

func (*HTTPRepository) Disconnect

func (r *HTTPRepository) Disconnect() error

Disconnect closes the connection to the HTTP repository

func (*HTTPRepository) FileExists

func (r *HTTPRepository) FileExists(ctx context.Context, filePath string) (bool, error)

FileExists checks if a file exists in the HTTP repository

func (*HTTPRepository) GetBranch

func (r *HTTPRepository) GetBranch() string

GetBranch returns the branch of the repository HTTP repositories don't have branches, so this returns an empty string

func (*HTTPRepository) GetFile

func (r *HTTPRepository) GetFile(ctx context.Context, filePath string) (io.ReadCloser, error)

GetFile retrieves a file from the HTTP repository

func (*HTTPRepository) GetLastModified

func (r *HTTPRepository) GetLastModified(ctx context.Context, filePath string) (time.Time, error)

GetLastModified gets the last modified time of a file in the HTTP repository

func (*HTTPRepository) ListFiles

func (r *HTTPRepository) ListFiles(ctx context.Context, pattern string) ([]FileInfo, error)

ListFiles lists files in the HTTP repository matching the pattern Note: HTTP repositories typically don't support directory listing, so this implementation is limited and may not work for all HTTP servers

type LocalFSRepository

type LocalFSRepository struct {
	*BaseRepository
	// contains filtered or unexported fields
}

LocalFSRepository implements the Repository interface for local file system repositories

func (*LocalFSRepository) Connect

func (r *LocalFSRepository) Connect(ctx context.Context) error

Connect establishes a connection to the local file system repository

func (*LocalFSRepository) Disconnect

func (r *LocalFSRepository) Disconnect() error

Disconnect closes the connection to the local file system repository

func (*LocalFSRepository) FileExists

func (r *LocalFSRepository) FileExists(ctx context.Context, path string) (bool, error)

FileExists checks if a file exists in the local file system repository

func (*LocalFSRepository) GetBranch

func (r *LocalFSRepository) GetBranch() string

GetBranch returns the branch of the repository Local file system repositories don't have branches, so this returns an empty string

func (*LocalFSRepository) GetFile

func (r *LocalFSRepository) GetFile(ctx context.Context, path string) (io.ReadCloser, error)

GetFile retrieves a file from the local file system repository

func (*LocalFSRepository) GetLastModified

func (r *LocalFSRepository) GetLastModified(ctx context.Context, path string) (time.Time, error)

GetLastModified gets the last modified time of a file in the local file system repository

func (*LocalFSRepository) ListFiles

func (r *LocalFSRepository) ListFiles(ctx context.Context, pattern string) ([]FileInfo, error)

ListFiles lists files in the local file system repository matching the pattern

type Manager

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

Manager manages multiple repositories

func NewManager

func NewManager() *Manager

NewManager creates a new repository manager

func (*Manager) AddRepository

func (m *Manager) AddRepository(repo Repository) error

AddRepository adds a repository to the manager

func (*Manager) ConnectAll

func (m *Manager) ConnectAll(ctx context.Context) error

ConnectAll connects to all repositories

func (*Manager) CreateRepository

func (m *Manager) CreateRepository(config *Config) (Repository, error)

CreateRepository creates a new repository from a configuration

func (*Manager) DisconnectAll

func (m *Manager) DisconnectAll() error

DisconnectAll disconnects from all repositories

func (*Manager) FindFile

func (m *Manager) FindFile(ctx context.Context, path string) (Repository, error)

FindFile finds a file in all repositories

func (*Manager) FindFiles

func (m *Manager) FindFiles(ctx context.Context, pattern string) (map[Repository][]FileInfo, error)

FindFiles finds files matching a pattern in all repositories

func (*Manager) GetFile

func (m *Manager) GetFile(ctx context.Context, path string) (io.ReadCloser, error)

GetFile gets a file from any repository that has it

func (*Manager) GetFileFromRepo

func (m *Manager) GetFileFromRepo(ctx context.Context, repoName, path string) (io.ReadCloser, error)

GetFileFromRepo gets a file from a specific repository

func (*Manager) GetRepository

func (m *Manager) GetRepository(name string) (Repository, error)

GetRepository gets a repository by name

func (*Manager) ListRepositories

func (m *Manager) ListRepositories() []Repository

ListRepositories lists all repositories

func (*Manager) RemoveRepository

func (m *Manager) RemoveRepository(name string) error

RemoveRepository removes a repository from the manager

type OfflineBundleRepository

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

OfflineBundleRepository implements the Repository interface for offline bundles

func NewOfflineBundleRepository

func NewOfflineBundleRepository(basePath string, auditTrail *trail.AuditTrailManager) *OfflineBundleRepository

NewOfflineBundleRepository creates a new offline bundle repository

func (*OfflineBundleRepository) Connect

func (r *OfflineBundleRepository) Connect(ctx context.Context) error

Connect connects to the repository

func (*OfflineBundleRepository) Disconnect

func (r *OfflineBundleRepository) Disconnect(ctx context.Context) error

Disconnect disconnects from the repository

func (*OfflineBundleRepository) GetFile

func (r *OfflineBundleRepository) GetFile(ctx context.Context, path string) ([]byte, error)

GetFile gets a file from the repository

func (*OfflineBundleRepository) GetFileInfo

func (r *OfflineBundleRepository) GetFileInfo(ctx context.Context, path string) (FileInfo, error)

GetFileInfo gets information about a file in the repository

func (*OfflineBundleRepository) GetOfflineBundle

func (r *OfflineBundleRepository) GetOfflineBundle() *bundle.OfflineBundle

GetOfflineBundle gets the loaded offline bundle

func (*OfflineBundleRepository) GetRepositoryInfo

func (r *OfflineBundleRepository) GetRepositoryInfo(ctx context.Context) (RepositoryInfo, error)

GetRepositoryInfo gets information about the repository

func (*OfflineBundleRepository) GetValidationLevel

func (r *OfflineBundleRepository) GetValidationLevel() bundle.ValidationLevel

GetValidationLevel gets the current validation level

func (*OfflineBundleRepository) IsConnected

func (r *OfflineBundleRepository) IsConnected() bool

IsConnected checks if the repository is connected

func (*OfflineBundleRepository) ListFiles

func (r *OfflineBundleRepository) ListFiles(ctx context.Context, path string) ([]FileInfo, error)

ListFiles lists files in the repository

func (*OfflineBundleRepository) SetValidationLevel

func (r *OfflineBundleRepository) SetValidationLevel(level bundle.ValidationLevel)

SetValidationLevel sets the validation level for offline bundles

type Repository

type Repository interface {
	// Connect establishes a connection to the repository
	Connect(ctx context.Context) error

	// Disconnect closes the connection to the repository
	Disconnect() error

	// IsConnected returns true if the repository is connected
	IsConnected() bool

	// GetName returns the name of the repository
	GetName() string

	// GetBranch returns the branch of the repository
	GetBranch() string

	// GetType returns the type of the repository
	GetType() RepositoryType

	// GetURL returns the repository URL
	GetURL() string

	// ListFiles lists files in the repository matching the pattern
	ListFiles(ctx context.Context, pattern string) ([]FileInfo, error)

	// GetFile retrieves a file from the repository
	GetFile(ctx context.Context, filePath string) (io.ReadCloser, error)

	// FileExists checks if a file exists in the repository
	FileExists(ctx context.Context, filePath string) (bool, error)

	// GetLastModified gets the last modified time of a file in the repository
	GetLastModified(ctx context.Context, filePath string) (time.Time, error)
}

Repository defines the interface for interacting with a template/module repository

func Create

func Create(config *Config) (Repository, error)

Create creates a repository instance using the default factory

func CreateRepository

func CreateRepository(config *Config) (Repository, error)

CreateRepository creates a new repository from a configuration and adds it to the default manager

func FindFile

func FindFile(ctx context.Context, path string) (Repository, error)

FindFile finds a file in all repositories in the default manager

func FindFileWithCache

func FindFileWithCache(ctx context.Context, path string) (Repository, error)

FindFile finds a file in all repositories with caching using the default cache manager

func GetRepository

func GetRepository(name string) (Repository, error)

GetRepository gets a repository by name from the default manager

func ListRepositories

func ListRepositories() []Repository

ListRepositories lists all repositories in the default manager

func NewDatabaseRepository

func NewDatabaseRepository(config *Config) (Repository, error)

NewDatabaseRepository creates a new database repository

func NewGitHubRepository

func NewGitHubRepository(config *Config) (Repository, error)

NewGitHubRepository creates a new GitHub repository

func NewGitLabRepository

func NewGitLabRepository(config *Config) (Repository, error)

NewGitLabRepository creates a new GitLab repository

func NewHTTPRepository

func NewHTTPRepository(config *Config) (Repository, error)

NewHTTPRepository creates a new HTTP repository

func NewLocalFSRepository

func NewLocalFSRepository(config *Config) (Repository, error)

NewLocalFSRepository creates a new local file system repository

func NewS3Repository

func NewS3Repository(config *Config) (Repository, error)

NewS3Repository creates a new S3 repository

type RepositoryAuditLogger

type RepositoryAuditLogger struct {
	// AuditLogger is the underlying audit logger
	AuditLogger *audit.AuditLogger
	// RepositoryType is the type of repository (HTTP, File, etc.)
	RepositoryType string
	// RepositoryURL is the URL of the repository
	RepositoryURL string
}

RepositoryAuditLogger is a wrapper around the audit.AuditLogger that provides repository-specific audit logging functionality

func NewRepositoryAuditLogger

func NewRepositoryAuditLogger(auditLogger *audit.AuditLogger, repositoryType, repositoryURL string) *RepositoryAuditLogger

NewRepositoryAuditLogger creates a new repository audit logger

func (*RepositoryAuditLogger) GenerateComplianceReport

func (l *RepositoryAuditLogger) GenerateComplianceReport(ctx context.Context, repositoryID string, startTime, endTime time.Time) (string, error)

GenerateComplianceReport generates a compliance report for repository operations

func (*RepositoryAuditLogger) LogFileDownloadFailure

func (l *RepositoryAuditLogger) LogFileDownloadFailure(ctx context.Context, repositoryID, filePath string, err error)

LogFileDownloadFailure logs a failed file download

func (*RepositoryAuditLogger) LogFileDownloadStart

func (l *RepositoryAuditLogger) LogFileDownloadStart(ctx context.Context, repositoryID, filePath string)

LogFileDownloadStart logs the start of a file download

func (*RepositoryAuditLogger) LogFileDownloadSuccess

func (l *RepositoryAuditLogger) LogFileDownloadSuccess(ctx context.Context, repositoryID, filePath string, sizeBytes int64)

LogFileDownloadSuccess logs a successful file download

func (*RepositoryAuditLogger) LogFileExists

func (l *RepositoryAuditLogger) LogFileExists(ctx context.Context, repositoryID, filePath string, exists bool)

LogFileExists logs a file existence check

func (*RepositoryAuditLogger) LogFileExistsFailure

func (l *RepositoryAuditLogger) LogFileExistsFailure(ctx context.Context, repositoryID, filePath string, err error)

LogFileExistsFailure logs a failed file existence check

func (*RepositoryAuditLogger) LogFileList

func (l *RepositoryAuditLogger) LogFileList(ctx context.Context, repositoryID, pattern string, count int)

LogFileList logs a file listing event

func (*RepositoryAuditLogger) LogFileListFailure

func (l *RepositoryAuditLogger) LogFileListFailure(ctx context.Context, repositoryID, pattern string, err error)

LogFileListFailure logs a failed file listing event

func (*RepositoryAuditLogger) LogGetLastModified

func (l *RepositoryAuditLogger) LogGetLastModified(ctx context.Context, repositoryID, filePath string, modTime time.Time)

LogGetLastModified logs a last modified time check

func (*RepositoryAuditLogger) LogGetLastModifiedFailure

func (l *RepositoryAuditLogger) LogGetLastModifiedFailure(ctx context.Context, repositoryID, filePath string, err error)

LogGetLastModifiedFailure logs a failed last modified time check

func (*RepositoryAuditLogger) LogRepositoryConnect

func (l *RepositoryAuditLogger) LogRepositoryConnect(ctx context.Context, repositoryID string)

LogRepositoryConnect logs a repository connection event

func (*RepositoryAuditLogger) LogRepositoryConnectFailure

func (l *RepositoryAuditLogger) LogRepositoryConnectFailure(ctx context.Context, repositoryID string, err error)

LogRepositoryConnectFailure logs a failed repository connection event

func (*RepositoryAuditLogger) LogRepositoryConnectSuccess

func (l *RepositoryAuditLogger) LogRepositoryConnectSuccess(ctx context.Context, repositoryID string)

LogRepositoryConnectSuccess logs a successful repository connection event

func (*RepositoryAuditLogger) LogRepositoryDeleteFile

func (l *RepositoryAuditLogger) LogRepositoryDeleteFile(ctx context.Context, repoURL, path string)

LogRepositoryDeleteFile logs a file deletion operation

func (*RepositoryAuditLogger) LogRepositoryDisconnect

func (l *RepositoryAuditLogger) LogRepositoryDisconnect(ctx context.Context, repositoryID string)

LogRepositoryDisconnect logs a repository disconnection event

func (*RepositoryAuditLogger) LogRepositoryFileExists

func (l *RepositoryAuditLogger) LogRepositoryFileExists(ctx context.Context, repoURL, path string)

LogRepositoryFileExists logs a file existence check operation

func (*RepositoryAuditLogger) LogRepositoryGetFile

func (l *RepositoryAuditLogger) LogRepositoryGetFile(ctx context.Context, repoURL, path string)

LogRepositoryGetFile logs a file retrieval operation

func (*RepositoryAuditLogger) LogRepositoryGetLastModified

func (l *RepositoryAuditLogger) LogRepositoryGetLastModified(ctx context.Context, repoURL, path string)

LogRepositoryGetLastModified logs a last modified time retrieval operation

func (*RepositoryAuditLogger) LogRepositoryListFiles

func (l *RepositoryAuditLogger) LogRepositoryListFiles(ctx context.Context, repoURL, pattern string)

LogRepositoryListFiles logs a file listing operation in a repository

func (*RepositoryAuditLogger) LogRepositoryStoreFile

func (l *RepositoryAuditLogger) LogRepositoryStoreFile(ctx context.Context, repoURL, path string)

LogRepositoryStoreFile logs a file storage operation

type RepositoryCreator

type RepositoryCreator func(config *Config) (Repository, error)

RepositoryCreator is a function that creates a repository instance

type RepositoryInfo

type RepositoryInfo struct {
	// Type is the repository type
	Type RepositoryType
	// Name is the repository name
	Name string
	// URL is the repository URL
	URL string
	// Branch is the repository branch
	Branch string
	// LocalPath is the local path where the repository is stored
	LocalPath string
	// CurrentVersion is the current version (commit hash or tag)
	CurrentVersion string
	// LatestVersion is the latest available version
	LatestVersion string
	// Description is a description of the repository
	Description string
	// LastSynced is the time the repository was last synced
	LastSynced time.Time
}

RepositoryInfo represents information about a repository

type RepositoryType

type RepositoryType string

RepositoryType represents the type of repository

const (
	// GitHub repository type
	GitHub RepositoryType = "github"
	// GitLab repository type
	GitLab RepositoryType = "gitlab"
	// LocalFS repository type (local file system)
	LocalFS RepositoryType = "local"
	// HTTP repository type (generic HTTP/HTTPS)
	HTTP RepositoryType = "http"
	// Database repository type
	Database RepositoryType = "database"
	// S3 repository type
	S3 RepositoryType = "s3"
)

type S3Repository

type S3Repository struct {
	*BaseRepository
	// contains filtered or unexported fields
}

S3Repository implements the Repository interface for AWS S3 repositories

func (*S3Repository) Connect

func (r *S3Repository) Connect(ctx context.Context) error

Connect establishes a connection to the S3 repository

func (*S3Repository) DeleteFile

func (r *S3Repository) DeleteFile(ctx context.Context, path string) error

DeleteFile deletes a file from the S3 repository

func (*S3Repository) Disconnect

func (r *S3Repository) Disconnect() error

Disconnect closes the connection to the S3 repository

func (*S3Repository) FileExists

func (r *S3Repository) FileExists(ctx context.Context, path string) (bool, error)

FileExists checks if a file exists in the S3 repository

func (*S3Repository) GetBranch

func (r *S3Repository) GetBranch() string

GetBranch returns the branch of the repository S3 repositories don't have branches, so this returns an empty string

func (*S3Repository) GetFile

func (r *S3Repository) GetFile(ctx context.Context, path string) (io.ReadCloser, error)

GetFile retrieves a file from the S3 repository

func (*S3Repository) GetLastModified

func (r *S3Repository) GetLastModified(ctx context.Context, path string) (time.Time, error)

GetLastModified gets the last modified time of a file in the S3 repository

func (*S3Repository) ListFiles

func (r *S3Repository) ListFiles(ctx context.Context, pattern string) ([]FileInfo, error)

ListFiles lists files in the S3 repository matching the pattern

func (*S3Repository) StoreFile

func (r *S3Repository) StoreFile(ctx context.Context, path string, content []byte) error

StoreFile stores a file in the S3 repository

Directories

Path Synopsis
Package interfaces defines interfaces for repository operations
Package interfaces defines interfaces for repository operations

Jump to

Keyboard shortcuts

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