-
Notifications
You must be signed in to change notification settings - Fork 47
/
main.go
60 lines (50 loc) · 1.59 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"os"
"github.com/bitrise-io/go-steputils/v2/stepconf"
"github.com/bitrise-io/go-utils/v2/command"
"github.com/bitrise-io/go-utils/v2/env"
"github.com/bitrise-io/go-utils/v2/errorutil"
. "github.com/bitrise-io/go-utils/v2/exitcode"
"github.com/bitrise-io/go-utils/v2/log"
"github.com/bitrise-io/go-utils/v2/pathutil"
"github.com/bitrise-steplib/steps-git-clone/gitclone/tracker"
"github.com/bitrise-steplib/steps-git-clone/step"
)
func main() {
exitCode := run()
os.Exit(int(exitCode))
}
func run() ExitCode {
logger := log.NewLogger()
gitCloneStep := createStep(logger)
cfg, err := gitCloneStep.ProcessConfig()
if err != nil {
logger.Println()
logger.Errorf("%s", errorutil.FormattedError(fmt.Errorf("Failed to process Step inputs: %w", err)))
return Failure
}
result, err := gitCloneStep.Run(cfg)
if err != nil {
logger.Println()
logger.Errorf("%s", errorutil.FormattedError(fmt.Errorf("Failed to execute Step: %w", err)))
return Failure
}
err = gitCloneStep.ExportOutputs(result)
if err != nil {
logger.Println()
logger.Errorf("%s", errorutil.FormattedError(fmt.Errorf("Failed to export Step outputs: %w", err)))
}
fmt.Println()
logger.Donef("Success")
return Success
}
func createStep(logger log.Logger) step.GitCloneStep {
envRepo := env.NewRepository()
tracker := tracker.NewStepTracker(envRepo, logger)
inputParser := stepconf.NewInputParser(envRepo)
cmdFactory := command.NewFactory(envRepo)
pathModififer := pathutil.NewPathModifier()
return step.NewGitCloneStep(logger, tracker, inputParser, envRepo, cmdFactory, pathModififer)
}