Documentation
¶
Overview ¶
Package adapters provides interfaces and implementations for external dependencies.
Package adapters provides concrete implementations of infrastructure ports.
Index ¶
- func ParseLogLevel(level string) slog.Level
- func WrapDirEntry(entry fs.DirEntry) domain.DirEntry
- func WrapFileInfo(info fs.FileInfo) domain.FileInfo
- type AuthMethod
- type CloneOptions
- type GitCloner
- type GoGitCloner
- type MemFS
- func (f *MemFS) Exists(ctx context.Context, name string) bool
- func (f *MemFS) IsDir(ctx context.Context, name string) (bool, error)
- func (f *MemFS) IsSymlink(ctx context.Context, name string) (bool, error)
- func (f *MemFS) Lstat(ctx context.Context, name string) (domain.FileInfo, error)
- func (f *MemFS) Mkdir(ctx context.Context, name string, perm fs.FileMode) error
- func (f *MemFS) MkdirAll(ctx context.Context, name string, perm fs.FileMode) error
- func (f *MemFS) ReadDir(ctx context.Context, name string) ([]domain.DirEntry, error)
- func (f *MemFS) ReadFile(ctx context.Context, name string) ([]byte, error)
- func (f *MemFS) ReadLink(ctx context.Context, name string) (string, error)
- func (f *MemFS) Remove(ctx context.Context, name string) error
- func (f *MemFS) RemoveAll(ctx context.Context, name string) error
- func (f *MemFS) Rename(ctx context.Context, oldname, newname string) error
- func (f *MemFS) Stat(ctx context.Context, name string) (domain.FileInfo, error)
- func (f *MemFS) Symlink(ctx context.Context, oldname, newname string) error
- func (f *MemFS) WriteFile(ctx context.Context, name string, data []byte, perm fs.FileMode) error
- type NoAuth
- type NoopCounter
- type NoopGauge
- type NoopHistogram
- type NoopLogger
- func (l *NoopLogger) Debug(ctx context.Context, msg string, args ...any)
- func (l *NoopLogger) Error(ctx context.Context, msg string, args ...any)
- func (l *NoopLogger) Info(ctx context.Context, msg string, args ...any)
- func (l *NoopLogger) Warn(ctx context.Context, msg string, args ...any)
- func (l *NoopLogger) With(args ...any) domain.Logger
- type NoopMetrics
- type NoopSpan
- type NoopTracer
- type OSFilesystem
- func (f *OSFilesystem) Exists(ctx context.Context, name string) bool
- func (f *OSFilesystem) IsDir(ctx context.Context, name string) (bool, error)
- func (f *OSFilesystem) IsSymlink(ctx context.Context, name string) (bool, error)
- func (f *OSFilesystem) Lstat(ctx context.Context, name string) (domain.FileInfo, error)
- func (f *OSFilesystem) Mkdir(ctx context.Context, name string, perm fs.FileMode) error
- func (f *OSFilesystem) MkdirAll(ctx context.Context, name string, perm fs.FileMode) error
- func (f *OSFilesystem) ReadDir(ctx context.Context, name string) ([]domain.DirEntry, error)
- func (f *OSFilesystem) ReadFile(ctx context.Context, name string) ([]byte, error)
- func (f *OSFilesystem) ReadLink(ctx context.Context, name string) (string, error)
- func (f *OSFilesystem) Remove(ctx context.Context, name string) error
- func (f *OSFilesystem) RemoveAll(ctx context.Context, name string) error
- func (f *OSFilesystem) Rename(ctx context.Context, oldname, newname string) error
- func (f *OSFilesystem) Stat(ctx context.Context, name string) (domain.FileInfo, error)
- func (f *OSFilesystem) Symlink(ctx context.Context, oldname, newname string) error
- func (f *OSFilesystem) WriteFile(ctx context.Context, name string, data []byte, perm fs.FileMode) error
- type SSHAuth
- type SlogLogger
- func (l *SlogLogger) Debug(ctx context.Context, msg string, args ...any)
- func (l *SlogLogger) Error(ctx context.Context, msg string, args ...any)
- func (l *SlogLogger) Info(ctx context.Context, msg string, args ...any)
- func (l *SlogLogger) Warn(ctx context.Context, msg string, args ...any)
- func (l *SlogLogger) With(args ...any) domain.Logger
- type TokenAuth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseLogLevel ¶
ParseLogLevel converts a string log level to slog.Level.
func WrapDirEntry ¶
WrapDirEntry wraps a standard fs.DirEntry.
Types ¶
type AuthMethod ¶
type AuthMethod interface {
// contains filtered or unexported methods
}
AuthMethod represents a git authentication method.
This is a sealed interface implemented only by:
- NoAuth
- TokenAuth
- SSHAuth
func ResolveAuth ¶
func ResolveAuth(ctx context.Context, repoURL string) (AuthMethod, error)
ResolveAuth determines the appropriate authentication method for a repository URL.
Resolution priority:
- GITHUB_TOKEN environment variable → TokenAuth
- GIT_TOKEN environment variable → TokenAuth
- SSH keys in ~/.ssh/ → SSHAuth (for SSH URLs)
- GitHub CLI (gh) authenticated token → TokenAuth (for HTTPS GitHub URLs)
- NoAuth (public repositories)
The function inspects the URL to determine authentication needs. For SSH URLs (git@... or ssh://...), SSH key auth is preferred. For GitHub HTTPS URLs, checks gh CLI if environment tokens not set. This ensures SSH URLs use SSH keys as users expect.
type CloneOptions ¶
type CloneOptions struct {
// Auth specifies the authentication method.
// If nil, no authentication is used (public repos only).
Auth AuthMethod
// Branch specifies which branch to clone.
// If empty, the default branch is cloned.
Branch string
// Depth specifies how many commits to fetch.
// If 0, full history is cloned.
// If 1, only the latest commit is fetched (shallow clone).
Depth int
// Progress is an optional writer for clone progress output.
// If nil, no progress is reported.
Progress io.Writer
}
CloneOptions configures repository cloning behavior.
type GitCloner ¶
type GitCloner interface {
// Clone clones a repository from the specified URL to the target path.
//
// Returns an error if:
// - URL is invalid
// - Target path already exists
// - Authentication fails
// - Network errors occur
// - Repository is not accessible
Clone(ctx context.Context, url string, path string, opts CloneOptions) error
}
GitCloner defines the interface for cloning git repositories.
type GoGitCloner ¶
type GoGitCloner struct{}
GoGitCloner implements GitCloner using go-git library.
func NewGoGitCloner ¶
func NewGoGitCloner() *GoGitCloner
NewGoGitCloner creates a new go-git based cloner.
func (*GoGitCloner) Clone ¶
func (g *GoGitCloner) Clone(ctx context.Context, url string, path string, opts CloneOptions) error
Clone clones a git repository using go-git.
type MemFS ¶
type MemFS struct {
// contains filtered or unexported fields
}
MemFS implements an in-memory filesystem for testing. It is not thread-safe and should only be used in tests.
type NoopCounter ¶
type NoopCounter struct{}
NoopCounter is a counter that does nothing.
func (*NoopCounter) Add ¶
func (c *NoopCounter) Add(delta float64, labels ...string)
func (*NoopCounter) Inc ¶
func (c *NoopCounter) Inc(labels ...string)
type NoopHistogram ¶
type NoopHistogram struct{}
NoopHistogram is a histogram that does nothing.
func (*NoopHistogram) Observe ¶
func (h *NoopHistogram) Observe(value float64, labels ...string)
type NoopLogger ¶
type NoopLogger struct{}
NoopLogger is a logger that does nothing. Useful for testing and when logging is disabled.
type NoopMetrics ¶
type NoopMetrics struct{}
NoopMetrics is a metrics collector that does nothing. Useful for testing and when metrics are disabled.
func NewNoopMetrics ¶
func NewNoopMetrics() *NoopMetrics
NewNoopMetrics creates a new no-op metrics collector.
type NoopSpan ¶
type NoopSpan struct{}
NoopSpan is a span that does nothing.
func (*NoopSpan) RecordError ¶
func (*NoopSpan) SetAttributes ¶
type NoopTracer ¶
type NoopTracer struct{}
NoopTracer is a tracer that does nothing. Useful for testing and when tracing is disabled.
type OSFilesystem ¶
type OSFilesystem struct{}
OSFilesystem implements the FS interface using the os package.
func NewOSFilesystem ¶
func NewOSFilesystem() *OSFilesystem
NewOSFilesystem creates a new OS filesystem adapter.
func (*OSFilesystem) Exists ¶
func (f *OSFilesystem) Exists(ctx context.Context, name string) bool
Exists checks if a path exists.
func (*OSFilesystem) Remove ¶
func (f *OSFilesystem) Remove(ctx context.Context, name string) error
Remove removes a file or empty directory.
func (*OSFilesystem) RemoveAll ¶
func (f *OSFilesystem) RemoveAll(ctx context.Context, name string) error
RemoveAll removes a directory tree.
func (*OSFilesystem) Rename ¶
func (f *OSFilesystem) Rename(ctx context.Context, oldname, newname string) error
Rename moves or renames a file.
type SSHAuth ¶
type SSHAuth struct {
// PrivateKeyPath is the filesystem path to the SSH private key.
PrivateKeyPath string
// Password is an optional passphrase for encrypted keys.
Password string
}
SSHAuth represents SSH key-based authentication.
type SlogLogger ¶
type SlogLogger struct {
// contains filtered or unexported fields
}
SlogLogger implements the Logger interface using log/slog.
func NewConsoleLogger ¶
func NewConsoleLogger(w io.Writer, level string) *SlogLogger
NewConsoleLogger creates a logger with console-slog for human-readable output.
func NewSlogLogger ¶
func NewSlogLogger(logger *slog.Logger) *SlogLogger
NewSlogLogger creates a new slog logger adapter.
func (*SlogLogger) Debug ¶
func (l *SlogLogger) Debug(ctx context.Context, msg string, args ...any)
Debug logs a debug-level message.
func (*SlogLogger) Error ¶
func (l *SlogLogger) Error(ctx context.Context, msg string, args ...any)
Error logs an error-level message.
func (*SlogLogger) Info ¶
func (l *SlogLogger) Info(ctx context.Context, msg string, args ...any)
Info logs an info-level message.
type TokenAuth ¶
type TokenAuth struct {
// Token is the authentication token.
Token string
}
TokenAuth represents token-based authentication (HTTPS).
The token is transmitted using HTTP Basic Authentication with "git" as the username and the token as the password. This format is compatible with:
- GitHub personal access tokens
- GitHub fine-grained tokens
- GitLab personal access tokens
- Gitea tokens
- Azure DevOps personal access tokens