Documentation
¶
Overview ¶
Package patch implements the patch command functionality
Package patch exposes the distribution patch flow to the app layer.
Index ¶
- Variables
- func InitFlags()
- type CommandHandler
- func (h *CommandHandler) BaseURL() string
- func (h *CommandHandler) Cleanup() error
- func (h *CommandHandler) DataProvider() repository.PatchProvider
- func (h *CommandHandler) DeleteDirectoryPaths() []string
- func (h *CommandHandler) DeletePaths() []string
- func (h *CommandHandler) DistributionName() string
- func (h *CommandHandler) DryRun() bool
- func (h *CommandHandler) DryRunMode() string
- func (h *CommandHandler) Execute(ctx context.Context) error
- func (h *CommandHandler) ExecutionSummary() ExecutionSummary
- func (h *CommandHandler) FilePaths() []string
- func (h *CommandHandler) Message() string
- func (h *CommandHandler) MovePaths() []string
- func (h *CommandHandler) PlannedChanges() map[string]*TargetChanges
- func (h *CommandHandler) Proposal(ctx context.Context) (bool, error)
- func (h *CommandHandler) Provider() string
- func (h *CommandHandler) SetDataProvider(provider repository.PatchProvider)
- func (h *CommandHandler) SetDryRun(dryRun bool)
- func (h *CommandHandler) SetDryRunMode(mode string)
- func (h *CommandHandler) SetWarnUnresolved(value string)
- func (h *CommandHandler) SetWorkingDir(dir string)
- func (h *CommandHandler) Setup(ctx context.Context) error
- func (h *CommandHandler) SkipConfirmation() bool
- func (h *CommandHandler) Token() string
- func (h *CommandHandler) UserInput() userinput.UserInput
- func (h *CommandHandler) Validate() error
- func (h *CommandHandler) Validated() bool
- func (h *CommandHandler) WarnUnresolved() string
- func (h *CommandHandler) WorkingDir() string
- type CommandHandlerOptions
- type Error
- func NewApplyChangesError(err error) *Error
- func NewCommitChangesError(targetName string, projectID int, uuid string, err error) *Error
- func NewConfigLoadError(err error) *Error
- func NewConfirmationPromptError(err error) *Error
- func NewCreateAdapterError() *Error
- func NewCreateProviderError(providerType string, err error) *Error
- func NewDataProviderConfigError(baseURL string) *Error
- func NewDataProviderNilError() *Error
- func NewDistributionNotFoundError(distributionName string) *Error
- func NewDistributionSelectionError(err error) *Error
- func NewError(errorType ErrorType, message string, err error) *Error
- func NewExecutionErrorsError(errorCount int) *Error
- func NewFindIndividualConfigError(uuid string, projectID int, err error) *Error
- func NewGetProjectError(err error) *Error
- func NewIndividualizationError(err error) *Error
- func NewIndividualizeContentError(targetName string, projectID int, uuid string, file string, err error) *Error
- func NewIndividualsConfigNotFoundError(configPath string) *Error
- func NewInitializeClientError(err error) *Error
- func NewInitializeProviderError(providerType string, err error) *Error
- func NewInvalidMoveSpecError(spec string) *Error
- func NewInvalidPatchPathError(path string, err error) *Error
- func NewListDistributionsError(err error) *Error
- func NewListLocalSnapshotsError(localRoot string, err error) *Error
- func NewLoadDistributionConfigError(configPath string, err error) *Error
- func NewLoadIndividualsConfigError(err error) *Error
- func NewLoadIndividualsConfigNotFoundError(configPath string, err error) *Error
- func NewLoadRemotesConfigError(err error) *Error
- func NewNoClientFoundError(targetName string) *Error
- func NewNoDistributionsFoundError(workingDir string) *Error
- func NewNoFilesSpecifiedError() *Error
- func NewNoIndividualFoundError(uuid string) *Error
- func NewNoLocalSnapshotFoundError(localRoot string) *Error
- func NewNoMemberFoundError(projectName string, uuid string) *Error
- func NewNoRemoteProjectsError() *Error
- func NewNoRemotesFoundError(targetName string) *Error
- func NewNoTargetsFoundError(configPath string) *Error
- func NewNoValidPatchFilesError() *Error
- func NewOriginConfigNotLoadedError() *Error
- func NewOriginConfigVersionMissingError() *Error
- func NewPatchCancelledError() *Error
- func NewPatchTargetError(targetName string, projectID int, err error) *Error
- func NewPathResolutionError(path string, err error) *Error
- func NewPlanCalculationError(file string, uuid string, err error) *Error
- func NewProposalCancelledError(msg string) *Error
- func NewProviderConnectionError(err error) *Error
- func NewReadFileError(filename string, err error) *Error
- func NewRemoteKeyMissingError(targetName string) *Error
- func NewResolveCredentialsError(targetName string, err error) *Error
- func NewUserCancelledError() *Error
- func NewUserConfirmationError(err error) *Error
- func NewWorkingDirAccessError(err error) *Error
- type ErrorType
- type ExecutionSummary
- type Handler
- type HandlerOptions
- type ProgressTracker
- type RemoteChanges
- type Request
- type Result
- type TargetChanges
Constants ¶
This section is empty.
Variables ¶
var (
DistributionFlag string
)
Re-export flags
Functions ¶
Types ¶
type CommandHandler ¶
type CommandHandler struct {
// contains filtered or unexported fields
}
CommandHandler manages the state and logic for the patch command
func NewCommandHandler ¶
func NewCommandHandler(opts *CommandHandlerOptions) *CommandHandler
NewCommandHandler creates a new patch handler
func (*CommandHandler) BaseURL ¶
func (h *CommandHandler) BaseURL() string
BaseURL returns the base URL.
func (*CommandHandler) Cleanup ¶
func (h *CommandHandler) Cleanup() error
Cleanup performs cleanup tasks
func (*CommandHandler) DataProvider ¶
func (h *CommandHandler) DataProvider() repository.PatchProvider
DataProvider returns the data provider from state.
func (*CommandHandler) DeleteDirectoryPaths ¶
func (h *CommandHandler) DeleteDirectoryPaths() []string
DeleteDirectoryPaths returns remote directory paths to delete recursively.
func (*CommandHandler) DeletePaths ¶
func (h *CommandHandler) DeletePaths() []string
DeletePaths returns remote paths to delete.
func (*CommandHandler) DistributionName ¶
func (h *CommandHandler) DistributionName() string
DistributionName returns the distribution name option.
func (*CommandHandler) DryRun ¶
func (h *CommandHandler) DryRun() bool
DryRun returns whether dry run mode is enabled.
func (*CommandHandler) DryRunMode ¶
func (h *CommandHandler) DryRunMode() string
DryRunMode returns the dry run mode string.
func (*CommandHandler) Execute ¶
func (h *CommandHandler) Execute(ctx context.Context) error
Execute performs the patch process using the DataProvider, delegating to PatchService.
func (*CommandHandler) ExecutionSummary ¶
func (h *CommandHandler) ExecutionSummary() ExecutionSummary
ExecutionSummary returns aggregate statistics from the latest execution.
func (*CommandHandler) FilePaths ¶
func (h *CommandHandler) FilePaths() []string
FilePaths returns the file paths to patch.
func (*CommandHandler) Message ¶
func (h *CommandHandler) Message() string
Message returns the commit message.
func (*CommandHandler) MovePaths ¶
func (h *CommandHandler) MovePaths() []string
MovePaths returns move specifications.
func (*CommandHandler) PlannedChanges ¶
func (h *CommandHandler) PlannedChanges() map[string]*TargetChanges
PlannedChanges returns the planned changes map.
func (*CommandHandler) Proposal ¶
func (h *CommandHandler) Proposal(ctx context.Context) (bool, error)
Proposal calculates the patch plan and asks for user confirmation
func (*CommandHandler) Provider ¶
func (h *CommandHandler) Provider() string
Provider returns the provider option.
func (*CommandHandler) SetDataProvider ¶
func (h *CommandHandler) SetDataProvider(provider repository.PatchProvider)
SetDataProvider sets the data provider (for testing).
func (*CommandHandler) SetDryRun ¶
func (h *CommandHandler) SetDryRun(dryRun bool)
SetDryRun sets the dry run mode (for testing).
func (*CommandHandler) SetDryRunMode ¶
func (h *CommandHandler) SetDryRunMode(mode string)
SetDryRunMode sets the dry run mode string (for testing).
func (*CommandHandler) SetWarnUnresolved ¶
func (h *CommandHandler) SetWarnUnresolved(value string)
SetWarnUnresolved sets the warn-unresolved setting (for testing).
func (*CommandHandler) SetWorkingDir ¶
func (h *CommandHandler) SetWorkingDir(dir string)
SetWorkingDir sets the working directory (for testing).
func (*CommandHandler) Setup ¶
func (h *CommandHandler) Setup(ctx context.Context) error
Setup initializes the patch process
func (*CommandHandler) SkipConfirmation ¶
func (h *CommandHandler) SkipConfirmation() bool
SkipConfirmation returns whether to skip user confirmation.
func (*CommandHandler) UserInput ¶
func (h *CommandHandler) UserInput() userinput.UserInput
UserInput returns the user input dependency.
func (*CommandHandler) Validate ¶
func (h *CommandHandler) Validate() error
Validate checks if the configuration is set and valid
func (*CommandHandler) Validated ¶
func (h *CommandHandler) Validated() bool
Validated returns whether the handler has been validated.
func (*CommandHandler) WarnUnresolved ¶
func (h *CommandHandler) WarnUnresolved() string
WarnUnresolved returns the warn-unresolved setting.
func (*CommandHandler) WorkingDir ¶
func (h *CommandHandler) WorkingDir() string
WorkingDir returns the working directory from state.
type CommandHandlerOptions ¶
type CommandHandlerOptions struct {
FilePaths []string
PatchContent repository.RepositoryContent
DeletePaths []string
DeleteDirectoryPaths []string
MovePaths []string
TargetNames []string
TargetUUIDs []string
TargetMembers []string
Token string
BaseURL string
Provider string
DistributionName string
WorkingDir string
Message string
DryRun bool
DryRunMode string
WarnUnresolved string
Force bool
SkipConfirmation bool
SuppressOutput bool
DisableEvalPagesUniqueDomain bool
// Worker pool overrides
WorkersOverride int
RateLimitOverride float64
TaskTimeoutOverride time.Duration
WorkersSet bool
RateLimitSet bool
TaskTimeoutSet bool
// Optional dependencies for testing
UserInput userinput.UserInput
PatchService patching.PatchService
TemplateService individualization.TemplateService
ProgressReporter svc.ProgressReporter
}
CommandHandlerOptions contains options for creating a new patch CommandHandler (public, for cmd/)
type Error ¶
type Error = apperror.CommandError[ErrorType]
Error is a type alias for the generic CommandError.
func NewApplyChangesError ¶
NewApplyChangesError creates an error for change application failures.
func NewCommitChangesError ¶
NewCommitChangesError creates an error for commit failures.
func NewConfigLoadError ¶
NewConfigLoadError creates an error for config loading failures.
func NewConfirmationPromptError ¶
NewConfirmationPromptError creates an error for confirmation prompt failures.
func NewCreateAdapterError ¶
func NewCreateAdapterError() *Error
NewCreateAdapterError creates an error for adapter creation failures.
func NewCreateProviderError ¶
NewCreateProviderError creates an error for provider creation failures.
func NewDataProviderConfigError ¶
NewDataProviderConfigError creates an error for data provider config failures.
func NewDataProviderNilError ¶
func NewDataProviderNilError() *Error
NewDataProviderNilError creates an error for nil data provider.
func NewDistributionNotFoundError ¶
NewDistributionNotFoundError creates an error for missing distribution.
func NewDistributionSelectionError ¶
NewDistributionSelectionError creates an error for distribution selection failures.
func NewExecutionErrorsError ¶
NewExecutionErrorsError creates an error for execution errors.
func NewFindIndividualConfigError ¶
NewFindIndividualConfigError creates an error for individual config finding failures.
func NewGetProjectError ¶
NewGetProjectError creates an error for project fetch failures.
func NewIndividualizationError ¶
NewIndividualizationError creates an error for individualization failures.
func NewIndividualizeContentError ¶
func NewIndividualizeContentError(targetName string, projectID int, uuid string, file string, err error) *Error
NewIndividualizeContentError creates an error for content individualization failures.
func NewIndividualsConfigNotFoundError ¶
NewIndividualsConfigNotFoundError creates an error for missing individuals config.
func NewInitializeClientError ¶
NewInitializeClientError creates an error for client initialization failures.
func NewInitializeProviderError ¶
NewInitializeProviderError creates an error for provider initialization failures.
func NewInvalidMoveSpecError ¶
NewInvalidMoveSpecError creates an error for invalid move specifications.
func NewInvalidPatchPathError ¶
NewInvalidPatchPathError creates an error for invalid remote patch paths.
func NewListDistributionsError ¶
NewListDistributionsError creates an error for distribution listing failures.
func NewListLocalSnapshotsError ¶
NewListLocalSnapshotsError creates an error for local snapshot discovery failures.
func NewLoadDistributionConfigError ¶
NewLoadDistributionConfigError creates an error for distribution config loading failures.
func NewLoadIndividualsConfigError ¶
NewLoadIndividualsConfigError creates an error for individuals config loading failures.
func NewLoadIndividualsConfigNotFoundError ¶
NewLoadIndividualsConfigNotFoundError creates an error for missing individuals config.
func NewLoadRemotesConfigError ¶
NewLoadRemotesConfigError creates an error for remotes config loading failures.
func NewNoClientFoundError ¶
NewNoClientFoundError creates an error for missing client.
func NewNoDistributionsFoundError ¶
NewNoDistributionsFoundError creates an error for missing distributions.
func NewNoFilesSpecifiedError ¶
func NewNoFilesSpecifiedError() *Error
NewNoFilesSpecifiedError creates an error when no files are specified.
func NewNoIndividualFoundError ¶
NewNoIndividualFoundError creates an error for missing individual.
func NewNoLocalSnapshotFoundError ¶
NewNoLocalSnapshotFoundError creates an error when no usable local snapshot exists.
func NewNoMemberFoundError ¶
NewNoMemberFoundError creates an error for missing member.
func NewNoRemoteProjectsError ¶
func NewNoRemoteProjectsError() *Error
NewNoRemoteProjectsError creates an error for missing remote projects.
func NewNoRemotesFoundError ¶
NewNoRemotesFoundError creates an error for missing remotes.
func NewNoTargetsFoundError ¶
NewNoTargetsFoundError creates an error for missing targets.
func NewNoValidPatchFilesError ¶
func NewNoValidPatchFilesError() *Error
NewNoValidPatchFilesError creates an error when no valid patch files are found.
func NewOriginConfigNotLoadedError ¶
func NewOriginConfigNotLoadedError() *Error
NewOriginConfigNotLoadedError creates an error for unloaded origin config.
func NewOriginConfigVersionMissingError ¶
func NewOriginConfigVersionMissingError() *Error
NewOriginConfigVersionMissingError creates an error for missing origin config version.
func NewPatchCancelledError ¶
func NewPatchCancelledError() *Error
NewPatchCancelledError creates an error for patch cancellation.
func NewPatchTargetError ¶
NewPatchTargetError creates an error for patch target failures.
func NewPathResolutionError ¶
NewPathResolutionError creates an error for path resolution failures.
func NewPlanCalculationError ¶
NewPlanCalculationError creates an error for plan calculation failures.
func NewProposalCancelledError ¶
NewProposalCancelledError creates an error for proposal cancellation.
func NewProviderConnectionError ¶
NewProviderConnectionError creates an error for provider connection failures.
func NewReadFileError ¶
NewReadFileError creates an error for file read failures.
func NewRemoteKeyMissingError ¶
NewRemoteKeyMissingError creates an error for missing remote key.
func NewResolveCredentialsError ¶
NewResolveCredentialsError creates an error for credential resolution failures.
func NewUserCancelledError ¶
func NewUserCancelledError() *Error
NewUserCancelledError creates an error for user cancellation.
func NewUserConfirmationError ¶
NewUserConfirmationError creates an error for user confirmation failures.
func NewWorkingDirAccessError ¶
NewWorkingDirAccessError creates an error for working directory access failures.
type ErrorType ¶
type ErrorType int
ErrorType defines domain-based error categories for the patch package. Consolidated from 41+ specific types to 8 semantic domains.
const ( // ErrValidation indicates input validation errors. ErrValidation ErrorType = iota // ErrUserCancelled indicates user-initiated cancellation. ErrUserCancelled // ErrFilesystem indicates file system operation errors. ErrFilesystem // ErrConfig indicates configuration loading errors. ErrConfig // ErrNotFound indicates missing resources. ErrNotFound // ErrProvider indicates provider/client errors. ErrProvider // ErrProcess indicates processing or execution errors. ErrProcess // ErrCredential indicates credential resolution errors. ErrCredential )
type ExecutionSummary ¶
type ExecutionSummary struct {
SuccessCount int
FailureCount int
SkippedCount int
FileCount int
GroupCount int
}
ExecutionSummary contains aggregate statistics from one patch execution.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler orchestrates patch execution.
func NewHandler ¶
func NewHandler(opts *HandlerOptions) *Handler
NewHandler constructs a patch handler with default dependencies.
type HandlerOptions ¶
type HandlerOptions struct {
NewInternalHandler newInternalHandlerFunc
}
HandlerOptions configures how the patch handler creates its internal command handler.
type ProgressTracker ¶
type ProgressTracker struct {
// contains filtered or unexported fields
}
ProgressTracker manages progress for patch operations with a single progress bar.
func NewProgressTracker ¶
func NewProgressTracker(targets map[string]*config.TargetRemotes) *ProgressTracker
NewProgressTracker creates a new progress tracker for patch operations
func (*ProgressTracker) Abort ¶
func (t *ProgressTracker) Abort()
Abort forcefully stops the progress bar
func (*ProgressTracker) CompleteTarget ¶
func (t *ProgressTracker) CompleteTarget(_ string, _ bool)
CompleteTarget is called when a target completes (no-op for single bar)
func (*ProgressTracker) IncrementTarget ¶
func (t *ProgressTracker) IncrementTarget(_ string, count int)
IncrementTarget increments the progress count
func (*ProgressTracker) StartTarget ¶
func (t *ProgressTracker) StartTarget(_ string)
StartTarget is called when a target starts processing (no-op for single bar)
type RemoteChanges ¶
type RemoteChanges struct {
ProjectID int
UUID string
Changes *TargetChanges
}
RemoteChanges represents changes for a single remote repository
type Request ¶
type Request struct {
FilePaths []string
PatchContent repoagg.RepositoryContent
DeletePaths []string
DeleteDirectoryPaths []string
MovePaths []string
TargetNames []string
TargetUUIDs []string
TargetMembers []string
Token string
BaseURL string
Provider string
DistributionName string
WorkingDir string
Message string
DryRun bool
DryRunMode string
WarnUnresolved string
Force bool
SkipConfirmation bool
SuppressOutput bool
DisableEvalPagesUniqueDomain bool
WorkersOverride int
RateLimitOverride float64
TaskTimeoutOverride time.Duration
WorkersSet bool
RateLimitSet bool
TaskTimeoutSet bool
UserInput userinput.UserInput
ProgressReporter svc.ProgressReporter
}
Request contains the input and overrides for a patch run.
type Result ¶
type Result struct {
Confirmed bool
SuccessCount int
FailureCount int
SkippedCount int
FileCount int
GroupCount int
}
Result reports whether the patch run was confirmed and executed.
type TargetChanges ¶
type TargetChanges struct {
Create map[string][]byte // Files to be created
Update map[string][]byte // Files to be updated
Delete []string // Files to be deleted
Move map[string]string // Files to be moved: source -> destination
Identical map[string]struct{} // Files that are identical after individualization
AdditionalActions []string // Non-file actions that will be applied
// DiffData stores the original content for files being updated (for diff display)
OriginalContent map[string][]byte
}
TargetChanges holds the planned changes for a target