Documentation
¶
Index ¶
- Constants
- Variables
- func AllModules(directory string) *[]string
- func CaptureOutput(f func()) string
- func ChangelogList(repository string, rules Changelog) ([]string, error)
- func CheckContext(ctx context.Context) error
- func CheckPath(path string) error
- func CheckStages(module *Module) error
- func Choose(items *[]string, value *string, title string) error
- func Cleanup(resource io.Closer, ch chan<- error)
- func CommitFilter(message string, conditions TypeValue[ChangelogConditionType, []string]) bool
- func DefaultYAML() string
- func GetModulesDir() (string, error)
- func HandleStages(stages []string, m *Module, wg *sync.WaitGroup, errCh chan<- error, ...) error
- func IsDir(path string) (bool, error)
- func OpenRepository(repository string) (*git.Repository, error)
- func ReplaceVariables(input string, variables map[string]string, depth int) (string, error)
- func ResultMessage(format string, a ...any)
- func ValidateArgument(arg string) bool
- func ValidateBuilds(m *Module) error
- func ValidateCallbacks(m *Module) error
- func ValidateLastVersion(m *Module) error
- func ValidateModuleName(name, directory string) error
- func ValidatePassword(password string) error
- func ValidateRules(rules []string, name string) error
- func ValidateRun(m *Module) error
- func ValidateStages(m *Module) error
- func ValidateVariables(m *Module) error
- func ValidateVersion(version string) error
- type BuildLogger
- type BuildType
- type Builder
- type Builds
- type Callback
- type CallbackParameters
- type Cfg
- type Changelog
- type ChangelogConditionType
- type ChangelogSort
- type ChangelogType
- type Changes
- type Client
- type CommitFilterFunc
- type FileExistsAction
- type HTTPClient
- type Module
- func (m *Module) FindStage(name string) (Stage, error)
- func (m *Module) GetChanges() *Changes
- func (m *Module) GetVersion() string
- func (m *Module) IsValid() error
- func (m *Module) NormalizeStages() error
- func (m *Module) PasswordEnv() string
- func (m *Module) StageCallback(stageName string) (Runnable, error)
- func (m *Module) ToYAML() ([]byte, error)
- func (m *Module) ValidateChangelog() error
- func (m *Module) ZipPath() (string, error)
- type ModuleBuilder
- type Runnable
- type Stage
- type TypeValue
- type ZeroLogger
Constants ¶
const ( ExternalType = "external" CommandType = "command" )
const ( Replace FileExistsAction = "replace" Skip FileExistsAction = "skip" ReplaceIfNewer FileExistsAction = "replace_if_newer" Commit ChangelogType = "commit" Tag ChangelogType = "tag" Include ChangelogConditionType = "include" Exclude ChangelogConditionType = "exclude" Asc ChangelogSort = "asc" Desc ChangelogSort = "desc" )
Variables ¶
var ( NilModuleError = errors.New("module is nil") NoItemsError = errors.New("no items") NoCommandSpecifiedError = errors.New("no command specified") NilCookieError = errors.New("cookie is nil") EmptySessionError = errors.New("empty session") EmptyLoginError = errors.New("empty login") EmptyPasswordError = errors.New("empty password") PasswordTooShortError = errors.New("password is too short") AuthenticationError = errors.New("authentication failed") EmptyModuleNameError = errors.New("empty module name") NameContainsSpaceError = errors.New("name must not contain spaces") EmptyAccountNameError = errors.New("empty account name") StageCallbackNotFoundError = errors.New("stage callback not found") InvalidChangelogSettingsError = errors.New("invalid changelog settings") ChangelogFromValueError = errors.New("changelog from: value is required") ChangelogToValueError = errors.New("changelog to: value is required") ChangelogConditionValueError = errors.New("changelog condition: value is required") InvalidFilepathError = errors.New("invalid filepath") SmallDepthError = errors.New("depth cannot be less than 0") LargeDepthError = errors.New("depth cannot be greater than 5") ReplacementError = errors.New("replacement variable is empty") EmptyVersionError = errors.New("empty version") InvalidStagesError = errors.New("stages is not valid") InvalidRunError = errors.New("run is required") NilRepositoryError = errors.New("repository is nil") NoChangesError = errors.New("no changes detected. version directory is empty") CallbackStageError = errors.New("callback stage is required") CallbackPrePostError = errors.New("callback pre or post is required") CallbackTypeError = errors.New("callback type is required") CallbackMethodError = errors.New("callback method is required") CallbackActionError = errors.New("callback action is required") CallbackActionSchemeError = errors.New( "callback action url scheme is invalid. allowed values are 'http' or 'https'", ) FileExcludedByIgnoreRuleError = errors.New("file excluded by ignore rule") FileExcludedByFilterRuleError = errors.New("file excluded by filter rule") NilCmdError = errors.New("cmd is nil") NilClientError = errors.New("client is nil") TODOContextError = errors.New("todo context is prohibited") InvalidRootDirError = errors.New("invalid root directory") )
Functions ¶
func AllModules ¶
AllModules returns a list of module names found in the specified directory.
The function reads the directory, checks for files (skipping directories), and attempts to read each file as a module using the ReadModule function. If a file can be successfully read as a module, its name is added to the list.
Parameters:
- directory (string): The path to the directory to scan for modules.
Returns:
- *[]string: A pointer to a slice of strings containing the names of all successfully read modules.
func CaptureOutput ¶
func CaptureOutput(f func()) string
func ChangelogList ¶ added in v1.3.1
ChangelogList generates a list of commits between two specified points in a Git repository, applying given changelog rules.
Parameters:
- repository: The file system path to the Git repository.
- rules: A `Changelog` struct defining the range of commits and sorting rules.
Returns:
- A slice of commit hashes as strings.
- An error if the repository cannot be opened or commit retrieval fails.
Behavior:
- If `rules.From` or `rules.To` are not properly set, it returns an empty list with no error.
- Opens the specified Git repository using `OpenRepository`.
- Retrieves commits within the specified range using `listOfCommits`.
- Sorts commits if `rules.Sort` is set to `Asc` (ascending) or `Desc` (descending).
Example:
rules := Changelog{
From: Tag{"v1.0.0"},
To: Tag{"v2.0.0"},
Sort: Desc,
}
commits, err := ChangelogList("/path/to/repo", rules)
if err != nil {
log.Fatalf("Failed to generate changelog: %v", err)
}
fmt.Println("Commits:", commits)
Notes:
- Sorting is applied only if `rules.Sort` is explicitly set.
- Uses `listOfCommits` with a predefined `CommitFilter` function.
- The function does not modify the repository; it only queries commit history.
func CheckContext ¶
CheckContext checks whether the provided context has been canceled or expired.
This function checks if the context has been canceled or the deadline exceeded. If the context is done, it returns an error indicating the cancellation or expiration. If the context is still active, it returns nil.
Parameters:
- ctx (context.Context): The context to check.
Returns:
- error: Returns an error if the context is done (canceled or expired), otherwise nil.
func CheckPath ¶
CheckPath checks if a given path is valid and exists on the filesystem.
This function cleans the provided path and verifies its validity using the `isValidPath` function. It then checks if the file or directory exists using `os.Stat`. If the file or directory does not exist or is not valid, an appropriate error is returned.
Parameters:
- path (string): The path to be validated and checked for existence.
Returns:
- error: An error if the path is invalid or does not exist, otherwise returns nil.
func CheckStages ¶
CheckStages validates the paths in the stages of the given module.
This function iterates over the stages in the provided module and concurrently checks the paths defined in each stage using goroutines. If any errors are encountered, they are collected in a channel and returned as a combined error.
Parameters:
- module (*Module): The module containing stages to be validated.
Returns:
- error: Returns an error if any validation fails in any stage's paths. If no errors are found, it returns nil.
func Cleanup ¶ added in v1.3.6
Cleanup closes the provided resource and handles any errors that occur during closure.
If the resource is nil, the function returns immediately without taking any action. If resource is not nil, its Close() method is called. If Close() returns an error and the provided
channel ch is not nil, the error is sent to ch.
Parameters:
- resource: an object that implements the io.Closer interface, representing the resource to be closed.
- ch: a channel for reporting errors. If ch is nil, any errors from resource.Close() are ignored.
func CommitFilter ¶ added in v1.3.1
func CommitFilter(message string, conditions TypeValue[ChangelogConditionType, []string]) bool
CommitFilter checks whether a commit message matches a set of conditions.
Parameters:
- message: The commit message to evaluate.
- conditions: A `TypeValue` struct containing a list of regex conditions and a filter type (`Include` or `Exclude`).
Returns:
- true if the commit message satisfies the filtering conditions.
- false if the message does not match an `Include` condition or matches an `Exclude` condition.
Behavior:
- If `conditions.Value` is empty, it returns `true` (no filtering applied).
- Iterates through all regex conditions in `conditions.Value`.
- If `conditions.Type` is `Include`, returns `true` on the first match.
- If `conditions.Type` is `Exclude`, returns `false` on the first match.
- If no matches are found, returns `false` for `Include` and `true` for `Exclude`.
Example:
conditions := TypeValue[ChangelogConditionType, []string]{
Type: Include,
Value: []string{".*fix.*", ".*feature.*"},
}
fmt.Println(CommitFilter("fix: bug fixed", conditions)) // true
fmt.Println(CommitFilter("chore: update docs", conditions)) // false
Notes:
- Regular expressions are compiled dynamically; invalid regex patterns are ignored.
- If regex compilation fails, the loop breaks, and filtering may be incomplete.
- Ensures `matched` is set correctly for both `Include` and `Exclude` conditions.
func DefaultYAML ¶
func DefaultYAML() string
func GetModulesDir ¶
func HandleStages ¶ added in v1.3.2
func IsDir ¶
IsDir checks if the given path points to a directory.
This function first checks if the path is valid using the `CheckPath` function. Then, it retrieves the file information using `os.Stat` to determine whether the given path is a directory or not.
Parameters:
- path (string): The path to be checked.
Returns:
- bool: `true` if the path is a directory, `false` otherwise.
- error: An error if the path is invalid or if there is an issue retrieving the file information.
func OpenRepository ¶ added in v1.3.1
func OpenRepository(repository string) (*git.Repository, error)
OpenRepository opens an existing Git repository at the specified path.
Parameters:
- repository: The file system path to the Git repository.
Returns:
- A pointer to a `git.Repository` instance if the repository is successfully opened.
- An error if the repository cannot be opened.
Behavior:
- Uses `git.PlainOpen` to open the repository.
- Wraps the error with additional context if opening fails.
Example:
repo, err := OpenRepository("/path/to/repo")
if err != nil {
log.Fatalf("Failed to open repository: %v", err)
}
fmt.Println("Repository opened:", repo)
Notes:
- The function does not initialize a new repository; it only opens an existing one.
- Ensure that the provided path is a valid Git repository.
func ReplaceVariables ¶
ReplaceVariables recursively replaces variables in the input string with their corresponding values from the provided map of variables.
The function supports up to 5 levels of recursion (controlled by the `depth` parameter) to allow nested variable replacements. If the depth exceeds 5 or if the depth is less than 0, an error will be returned.
Parameters:
- input (string): The input string containing variables in the format `{variableName}` to replace.
- variables (map[string]string): A map containing variable names as keys and their replacement values as strings.
- depth (int): The current recursion depth, which should start from 0. The function supports up to 5 levels of recursion.
Returns:
- string: The updated string with variables replaced by their corresponding values, or an error if no replacement could be made.
- error: An error is returned if the depth exceeds 5, if the depth is negative, or if the replacement results in an empty string.
func ResultMessage ¶
func ValidateArgument ¶ added in v1.3.0
ValidateArgument checks if the provided argument contains only alphanumeric characters, underscores, slashes, or hyphens.
Parameters:
- arg (string): The argument to validate.
Returns:
- bool: True if the argument is valid, otherwise false.
func ValidateBuilds ¶ added in v1.3.1
func ValidateCallbacks ¶ added in v1.3.1
func ValidateLastVersion ¶ added in v1.3.1
func ValidateModuleName ¶
ValidateModuleName checks if a module with the given name already exists in the specified directory.
The function constructs the expected file path for the module definition using the format "<directory>/<name>.yaml". It then checks if the file exists:
- If the file does not exist, the function returns nil (indicating the module name is available).
- If the file exists, it returns an error indicating that the module name is already taken.
- If an error occurs while checking the file, it is returned.
Returns nil if the module name is available, otherwise returns an error.
func ValidatePassword ¶
ValidatePassword checks if the given password meets basic validation criteria.
The function performs the following checks:
- Trims any leading and trailing whitespace.
- Ensures the password is not empty.
- Ensures the password is at least 6 characters long.
Returns an error if the password is invalid, otherwise returns nil.
func ValidateRules ¶ added in v1.3.5
func ValidateRun ¶ added in v1.3.2
func ValidateStages ¶ added in v1.3.1
func ValidateVariables ¶ added in v1.3.1
func ValidateVersion ¶
ValidateVersion checks if the given module version is valid.
The function performs the following checks:
- Trims any leading and trailing whitespace.
- Ensures the version is not empty.
- Validates the version format using a predefined regex.
Returns nil if the version is valid, otherwise returns an error.
Types ¶
type BuildLogger ¶ added in v1.3.5
type Builder ¶
func NewModuleBuilder ¶ added in v1.3.5
func NewModuleBuilder(m *Module, logger BuildLogger) Builder
type Callback ¶ added in v1.3.0
type Callback struct {
Stage string `yaml:"stage"`
Pre CallbackParameters `yaml:"pre,omitempty"`
Post CallbackParameters `yaml:"post,omitempty"`
}
func (*Callback) IsValid ¶ added in v1.3.0
IsValid checks if the Callback structure is valid. It ensures that the stage name is provided and that either pre or post parameters exist. Additionally, it validates the pre and post parameters if they are set.
Returns:
- error: An error if validation fails, otherwise nil.
type CallbackParameters ¶ added in v1.3.0
type CallbackParameters struct {
Type string `yaml:"type"`
Action string `yaml:"action"`
Method string `yaml:"method,omitempty"`
Parameters []string `yaml:"parameters,omitempty"`
}
func (*CallbackParameters) IsValid ¶ added in v1.3.0
func (c *CallbackParameters) IsValid() error
IsValid checks if the CallbackParameters structure is valid. It performs type, method, action, and parameters validation.
Returns:
- error: An error if validation fails, otherwise nil.
func (*CallbackParameters) Run ¶ added in v1.3.0
func (c *CallbackParameters) Run(ctx context.Context, logger BuildLogger) error
Run executes the callback based on its type (external or command). It first validates the callback parameters, then either runs an external HTTP request or a system command depending on the `Type` of the callback.
Parameters:
- ctx (context.Context): The context for the execution, used for cancellation and timeouts.
- logger (BuildLogger): The logger to record any logs or errors during execution.
Returns:
- error: Returns an error if validation fails or if execution of the callback fails.
type Changelog ¶ added in v1.3.1
type Changelog struct {
From TypeValue[ChangelogType, string] `yaml:"from"`
To TypeValue[ChangelogType, string] `yaml:"to"`
Sort ChangelogSort `yaml:"sort,omitempty"`
Condition TypeValue[ChangelogConditionType, []string] `yaml:"condition,omitempty"`
}
type ChangelogConditionType ¶ added in v1.3.1
type ChangelogConditionType string
type ChangelogSort ¶ added in v1.3.1
type ChangelogSort string
type ChangelogType ¶ added in v1.3.1
type ChangelogType string
type Changes ¶ added in v1.3.4
func ChangesList ¶ added in v1.3.4
ChangesList generates a list of file changes between two commits in a Git repository.
Parameters:
- repository: The file system path to the Git repository.
- rules: A `Changelog` struct defining the commit range for comparison.
Returns:
- A pointer to a `Changes` struct containing lists of added, modified, and deleted files.
- An error if the repository cannot be opened, commit hashes cannot be resolved, or patch generation fails.
Behavior:
- Opens the Git repository using `OpenRepository`.
- Resolves the start and end commit hashes using `hashes`.
- Retrieves the commit objects corresponding to these hashes.
- Generates a diff (`Patch`) between the two commits.
- Iterates through the `FilePatches()` to categorize files as added, modified, or deleted.
Example:
changes, err := ChangesList("/path/to/repo", rules)
if err != nil {
log.Fatalf("Failed to generate changes list: %v", err)
}
fmt.Println("Added files:", changes.Added)
fmt.Println("Modified files:", changes.Modified)
fmt.Println("Deleted files:", changes.Deleted)
Notes:
- If `from == nil`, the file was newly added.
- If `to == nil`, the file was deleted.
- Otherwise, the file was modified.
- The function does not modify the repository; it only analyzes commit differences.
func (*Changes) IsChangedFile ¶ added in v1.3.4
IsChangedFile checks whether the given file path corresponds to a file that has been added or modified.
Parameters:
- path: The file path to check.
Returns:
- true if the file is in the list of added or modified files.
- false otherwise.
Behavior:
- Iterates through the `Added` and `Modified` slices of the `Changes` struct.
- Uses `strings.HasSuffix` to check if the provided path ends with any of the added or modified file names.
- Returns true on the first match, otherwise false.
Notes:
- This method assumes that `o.Added` and `o.Modified` contain relative or base file names.
- If files are stored with full paths in `o.Added` and `o.Modified`, this method may produce false negatives.
Example:
changes := Changes{
Added: []string{"file1.txt", "dir/file2.go"},
Modified: []string{"config.yaml"},
}
fmt.Println(changes.IsChangedFile("project/dir/file2.go")) // true
fmt.Println(changes.IsChangedFile("config.yaml")) // true
fmt.Println(changes.IsChangedFile("untracked.txt")) // false
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Authorization ¶
Authorization performs user authentication by sending login credentials to the Bitrix Partner Portal.
It sends a POST request with the login and password as form data and checks the response for authentication success by verifying the presence of a "BITRIX_SM_LOGIN" cookie.
Returns a slice of cookies if authentication is successful or an error if authentication fails or an issue occurs during the request.
func (*Client) SessionId ¶
SessionId retrieves the session ID for a given module from the Bitrix Partner Portal.
The function sends a GET request to the edit page of the module, then parses the HTML response to extract the session ID. The session ID is needed for later operations like uploading data to the portal.
Parameters:
- module: The module for which the session ID is being retrieved.
- cookies: The cookies containing the authentication information.
Returns:
- The session ID as a string if found, otherwise returns an empty string.
func (*Client) UploadZIP ¶
UploadZIP uploads a ZIP file containing the module's data to the Bitrix Partner Portal.
This function first validates that the module and cookies are provided. It then retrieves the session ID and prepares the ZIP file for upload. The request is sent with the necessary form data, including the session ID, module name, and the ZIP file. The response body is checked for the result of the upload operation.
Parameters:
- module: The module whose ZIP file is being uploaded.
- cookies: The cookies containing the authentication information.
Returns:
- An error if any step fails (e.g., missing session, file errors, upload failure).
type CommitFilterFunc ¶ added in v1.3.1
type CommitFilterFunc func(string, TypeValue[ChangelogConditionType, []string]) bool
type FileExistsAction ¶
type FileExistsAction string
type Module ¶
type Module struct {
Ctx context.Context `yaml:"-"`
Variables map[string]string `yaml:"variables,omitempty"`
Run map[string][]string `yaml:"run,omitempty"`
Repository string `yaml:"repository,omitempty"`
Account string `yaml:"account"`
BuildDirectory string `yaml:"buildDirectory,omitempty"`
LogDirectory string `yaml:"logDirectory,omitempty"`
Version string `yaml:"version"`
Name string `yaml:"name"`
Changelog Changelog `yaml:"changelog,omitempty"`
Builds Builds `yaml:"builds"`
Stages []Stage `yaml:"stages"`
Ignore []string `yaml:"ignore"`
Callbacks []Callback `yaml:"callbacks,omitempty"`
LastVersion bool `yaml:"-"`
// contains filtered or unexported fields
}
func ReadModule ¶
ReadModule reads a module from a YAML file or directory path and returns a Module object.
This function attempts to read a module from the specified path. If the `file` flag is true, the function treats `path` as the file path directly. Otherwise, it expects a YAML file with the name of the module, combining the `path` and `name` parameters to form the file path.
Parameters:
- path (string): The directory or file path where the module file is located.
- name (string): The name of the module. Used to construct the file path when `file` is false.
- file (bool): Flag indicating whether the `path` is a direct file path or a directory where a module file should be looked for.
Returns:
- *Module: A pointer to a `Module` object if the file can be successfully read and unmarshalled.
- error: An error if reading or unmarshalling the file fails.
func ReadModuleFromFlags ¶ added in v1.3.2
func (*Module) FindStage ¶ added in v1.3.1
FindStage searches for a stage with the specified name in the module. It iterates through the module's stages and returns the matching stage if found. If no stage with the given name exists, it returns an empty Stage and an error with the message "stage not found".
name - the name of the stage to search for.
Returns:
- Stage: the stage with the matching name.
- error: nil if the stage is found; otherwise, an error indicating that the stage was not found.
func (*Module) GetChanges ¶ added in v1.3.4
func (*Module) GetVersion ¶ added in v1.3.1
func (*Module) IsValid ¶
IsValid validates the fields of the Module struct.
It checks the following conditions:
- The `Name` field must not be an empty string and must not contain spaces.
- The `Version` field must be a valid version, validated by the `ValidateVersion` function.
- The `Account` field must not be empty.
- If the `Variables` map is not nil, it checks that each key and value in the map is non-empty.
- The `Stages` field must contain at least one stage. Each stage must have a valid `Name`, `To` field, and an `ActionIfFileExists` field. Additionally, each `From` path in a stage must be non-empty.
- If the `Ignore` field is not empty, each rule must be non-empty.
- The `NormalizeStages` function is called to ensure the validity of the stages after other checks.
If any of these conditions are violated, the method returns an error with a detailed message. If all validations pass, it returns nil.
func (*Module) NormalizeStages ¶
NormalizeStages processes and normalizes the stages in the Module by replacing any variables within the stage fields (Name, To, From) with values from the Module's Variables map.
The method iterates over each stage in the Module's Stages slice, and for each field (Name, To, From), it uses the `ReplaceVariables` function to replace any placeholders with corresponding variable values.
If any error occurs while replacing variables or processing the stages, it returns the error. If no errors are encountered, it returns nil.
Returns:
- error: Any error that occurred during the variable replacement process. If successful, returns nil.
func (*Module) PasswordEnv ¶
PasswordEnv returns the environment variable name that stores the password for the module.
The variable name is generated based on the module's name:
- Converted to uppercase
- All dots (".") are replaced with underscores ("_")
- The suffix "_PASSWORD" is appended
For example, for a module named "my.module", the function will return "MY_MODULE_PASSWORD".
func (*Module) StageCallback ¶ added in v1.3.0
StageCallback returns the callback associated with the given stage. If no matching callback is found, an error is returned.
stageName - the name of the stage to find the callback for.
Returns:
- Runnable - the found callback if it exists.
- error - an error if the callback is not found.
func (*Module) ToYAML ¶
ToYAML converts the Module struct to its YAML representation.
It uses the `yaml.Marshal` function to serialize the `Module` struct into a YAML format. If the conversion is successful, it returns the resulting YAML as a byte slice. If an error occurs during marshaling, it returns the error.
Returns:
- []byte: The YAML representation of the Module struct.
- error: Any error that occurred during the marshaling process.
func (*Module) ValidateChangelog ¶ added in v1.3.1
ValidateChangelog validates the changelog configuration of the module. It checks for the presence and correctness of required fields:
- Ensures 'repository' is specified if 'from' or 'to' types are defined.
- Validates that 'from' and 'to' types are either 'commit' or 'tag'.
- Confirms 'from' and 'to' values are non-empty.
- If 'condition' is specified, checks that:
- a Condition type is either 'include' or 'exclude'.
- Condition values are non-empty and valid regular expressions.
Returns an error detailing the first encountered validation issue, or nil if the configuration is valid.
func (*Module) ZipPath ¶
ZipPath generates the absolute path for the ZIP file associated with the Module.
The method constructs a path by combining the Module's BuildDirectory and Version fields, appending the ".zip" extension. It then checks if the path exists and is valid using the `CheckPath` function.
If the path is valid, it returns the cleaned absolute path of the ZIP file. If any error occurs during path creation or validation, it returns an empty string along with the error.
Returns:
- string: The absolute path of the ZIP file.
- error: Any error encountered during path creation or validation, otherwise nil.
type ModuleBuilder ¶ added in v1.3.5
type ModuleBuilder struct {
// contains filtered or unexported fields
}
func (*ModuleBuilder) Build ¶ added in v1.3.5
func (m *ModuleBuilder) Build() error
Build orchestrates the entire build process for the module. It logs the progress of each phase, such as preparation, collection, and Cleanup. If any of these phases fails, the build will be rolled back to ensure a clean state.
The method returns an error if any of the steps (Prepare, Collect, or Cleanup) fail.
func (*ModuleBuilder) Cleanup ¶ added in v1.3.5
func (m *ModuleBuilder) Cleanup()
Cleanup removes any temporary files and directories created during the build process. It ensures the environment is cleaned up by deleting the version-specific build directory.
func (*ModuleBuilder) Collect ¶ added in v1.3.5
func (m *ModuleBuilder) Collect() error
Collect gathers the necessary files for the build. It processes each stage in parallel using goroutines to handle file copying. The function creates the necessary directories for each stage and copies files as defined in the stage configuration.
The method returns an error if any stage fails or if there are issues zipping the collected files.
func (*ModuleBuilder) Prepare ¶ added in v1.3.5
func (m *ModuleBuilder) Prepare() error
Prepare sets up the environment for the build process. It validates the module, checks the stages, and creates the necessary directories for the build output and logs. If any validation or directory creation fails, an error will be returned.
The method returns an error if the module is invalid or if directories cannot be created.
func (*ModuleBuilder) Rollback ¶ added in v1.3.5
func (m *ModuleBuilder) Rollback() error
Rollback reverts any changes made during the build process. It deletes the generated zip file and version-specific directories created during the build. This function ensures that any temporary build files are removed and that the environment is restored to its previous state.
The method returns an error if the rollback process fails.
type Runnable ¶ added in v1.3.0
type Runnable interface {
PreRun(ctx context.Context, wg *sync.WaitGroup, logger BuildLogger)
PostRun(ctx context.Context, wg *sync.WaitGroup, logger BuildLogger)
}
type ZeroLogger ¶ added in v1.3.5
type ZeroLogger struct {
// contains filtered or unexported fields
}
func NewFileZeroLogger ¶ added in v1.3.5
func NewFileZeroLogger(filePath, logDir string) *ZeroLogger
func (*ZeroLogger) Cleanup ¶ added in v1.3.5
func (l *ZeroLogger) Cleanup()
func (*ZeroLogger) Error ¶ added in v1.3.5
func (l *ZeroLogger) Error(message string, err error, args ...interface{})
func (*ZeroLogger) Info ¶ added in v1.3.5
func (l *ZeroLogger) Info(message string, args ...interface{})