Documentation
¶
Index ¶
- Constants
- func CreateMultiCommit(ctx context.Context, branchName, message string, quantity int) (err error)
- func CreateNewBranch(ctx context.Context, branchName string) (err error)
- func CreateNewCommit(ctx context.Context, branchName, message string) (commitId string, err error)
- func CreateNewTag(ctx context.Context, branchName, message, tag string) (err error)
- func InitRepo(ctx context.Context, repoUrl, username, password string) (repoPath string, err error)
- func RestoreDirectories(fs embed.FS, dirName string, targetDir string)
- type ScriptBuilder
- func (r *ScriptBuilder) Error() error
- func (r *ScriptBuilder) Result() *ScriptResult
- func (r *ScriptBuilder) WithErrorOutput(writer io.Writer) *ScriptBuilder
- func (r *ScriptBuilder) WithLocalRepoPath() *ScriptBuilder
- func (r *ScriptBuilder) WithOutput(writer io.Writer, prefix ...string) *ScriptBuilder
- func (r *ScriptBuilder) WithRepoPath(repoPath string) *ScriptBuilder
- func (r *ScriptBuilder) WithRootFolder(rootFolder string) *ScriptBuilder
- func (r *ScriptBuilder) WithScript(scriptName string, args ...string) *ScriptBuilder
- type ScriptResult
Constants ¶
const ( // ScriptInitRepo script path for init repo script ScriptInitRepo = "git/init_repo.sh" // ScriptCreateBranch script path for create branch script ScriptCreateBranch = "git/create_branch.sh" // ScriptCreateCommit script path for create commit script ScriptCreateCommit = "git/create_commit.sh" // ScriptCreateMultiCommit script path for create multi commit script ScriptCreateMultiCommit = "git/create_multi_commit.sh" // ScriptCreateTag script path for create tag script ScriptCreateTag = "git/create_tag.sh" )
const DefaultScriptOutputPrefix = "##output##"
DefaultScriptOutputPrefix the prefix of script output
Variables ¶
This section is empty.
Functions ¶
func CreateMultiCommit ¶
CreateMultiCommit create new commit using a bash script and vanila git cli returns an error if any
func CreateNewBranch ¶
CreateNewBranch create new branch using a bash script and vanila git cli returns an error if any
func CreateNewCommit ¶
CreateNewCommit create new commit using a bash script and vanila git cli returns an error if any
func CreateNewTag ¶
CreateNewTag create new tag using a bash script and vanila git cli returns an error if any
Types ¶
type ScriptBuilder ¶
type ScriptBuilder struct {
// contains filtered or unexported fields
}
ScriptBuilder script runner for easier initializing of data using scripts while providing option for asserting and processing the result
func NewScript ¶
func NewScript(ctx context.Context, scriptName string, args ...string) *ScriptBuilder
NewScript starts creating a script runner for the given script and args which can be customized by chaining other methods and be finally executed by calling the Result or Error methods
func (*ScriptBuilder) Error ¶
func (r *ScriptBuilder) Error() error
Error runs the script and returns an error if any. This method will discard the ScriptResult object but the output can be written providing a writer using WithOutput method
func (*ScriptBuilder) Result ¶
func (r *ScriptBuilder) Result() *ScriptResult
Result runs the script and returns a ScriptResult object. If and output writer was provided will automatically write the output of the script into the writer.
func (*ScriptBuilder) WithErrorOutput ¶
func (r *ScriptBuilder) WithErrorOutput(writer io.Writer) *ScriptBuilder
WithErrorOutput
func (*ScriptBuilder) WithLocalRepoPath ¶
func (r *ScriptBuilder) WithLocalRepoPath() *ScriptBuilder
WithLocalRepoPath set the repo path from the LocalRepoPathFromCtx function, which normally is already present inside context when adding repo conditions like
func (*ScriptBuilder) WithOutput ¶
func (r *ScriptBuilder) WithOutput(writer io.Writer, prefix ...string) *ScriptBuilder
WithOutput adds an output writer to write text output from script into. The second argument accepts an output prefix from the script which defaults to "##output##
func (*ScriptBuilder) WithRepoPath ¶
func (r *ScriptBuilder) WithRepoPath(repoPath string) *ScriptBuilder
WithRepoPath changes the repository path. By default this value is already initiated using WithLocalRepoPath which will fetch a LocalRepoPath from the context
func (*ScriptBuilder) WithRootFolder ¶
func (r *ScriptBuilder) WithRootFolder(rootFolder string) *ScriptBuilder
WithRootFolder changes the root folder of the scripts. By default this value is already initiated using a variable that can be customized using the E2E_TEMP_DIR environment variable
func (*ScriptBuilder) WithScript ¶
func (r *ScriptBuilder) WithScript(scriptName string, args ...string) *ScriptBuilder
WithScript changes the script initialized by the builder
type ScriptResult ¶
type ScriptResult struct {
OutputDataPrefix string
// contains filtered or unexported fields
}
ScriptResult the result of script execution
func ExecBashScript ¶
func ExecBashScript(script string, params ...string) *ScriptResult
ExecBashScript exec bash script with params
func ExecScript ¶
func ExecScript(name string, arg ...string) *ScriptResult
ExecScript exec script with params
func (*ScriptResult) Error ¶
func (p *ScriptResult) Error() error
Error get the error of a script execution
func (*ScriptResult) ExitCode ¶
func (p *ScriptResult) ExitCode() int
ExitCode get the exit code of a script execution
func (*ScriptResult) ExitMessage ¶
func (p *ScriptResult) ExitMessage() string
ExitMessage get the exit message of a script execution
func (*ScriptResult) OutputData ¶
func (p *ScriptResult) OutputData(dataPrefix string) string
OutputData get the output of a script execution, it can be a structured data, e.g: json string
func (*ScriptResult) Stderr ¶
func (p *ScriptResult) Stderr() string
Stderr get the error output of a script execution
func (*ScriptResult) Stdout ¶
func (p *ScriptResult) Stdout() string
Stdout get the output of a script execution