forked from mubashiroliyantakath/gitlab-metadata
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
58 lines (50 loc) · 1.47 KB
/
main.go
File metadata and controls
58 lines (50 loc) · 1.47 KB
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
package main
import (
"os"
"os/exec"
"strings"
"github.com/mubashiroliyantakath/gitlab-metadata/app/global"
"github.com/mubashiroliyantakath/gitlab-metadata/app/lib"
"github.com/mubashiroliyantakath/gitlab-metadata/app/models"
"github.com/mubashiroliyantakath/gitlab-metadata/app/utils"
log "github.com/sirupsen/logrus"
)
func init() {
log.SetFormatter(&log.TextFormatter{FullTimestamp: true})
log.SetOutput(os.Stdout)
logLevel, err := log.ParseLevel(os.Getenv("LOG_LEVEL"))
if err != nil {
logLevel = log.InfoLevel
}
log.SetLevel(logLevel)
log.Debug("Log level set to ", logLevel)
gitPath, err := exec.LookPath("git")
if err != nil {
log.Fatal("Git is not installed or not found in PATH: ", err)
}
log.Debug("Git path: ", gitPath)
err = utils.NewAppConfig()
if err != nil {
log.Fatal("Failed to load configuration: ", err)
}
projectDir, envExists := os.LookupEnv("CI_PROJECT_DIR")
if !envExists {
log.Warn("CI_PROJECT_DIR not set. Using current directory as project directory.")
} else {
log.Info("Project directory set to: ", projectDir)
global.CiProjectDir = projectDir
}
}
func main() {
inputs := utils.ParseInputs(strings.Fields(utils.AppConfig.Input))
tags := utils.GenerateTags(inputs)
log.Info("Tags generated: ", tags)
tags = lib.DeleteEmptyFromList(tags)
global.Tags = tags
log.Info("tags: ", global.Tags)
outputFile := models.NewOutputEnvFile()
err := outputFile.Write()
if err != nil {
log.Fatal("Failed to write output file: ", err)
}
}