-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupport.go
executable file
·91 lines (74 loc) · 1.67 KB
/
support.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package main
import (
"fmt"
"log"
"os"
"os/user"
"strings"
_ "github.com/denisenkom/go-mssqldb"
"github.com/google/uuid"
core "github.com/mt1976/mwt-goToolkit/core"
)
func wrapVariable(in string) string {
return "{{." + in + "}}"
}
func wrapTemplate(in string) string {
return "{{template " + enquote(in) + " .}}"
}
func enquote(in string) string {
return "\"" + in + "\""
}
func getUsername() string {
usr, err := user.Current()
if err != nil {
log.Fatal(err)
}
if usr.Name != "" {
return usr.Username + " (" + usr.Name + ")"
}
return usr.Username
}
func genUUID() string {
id := uuid.New()
//fmt.Printf("github.com/google/uuid: %s\n", id.String())
return id.String()
}
func genReleaseName() string {
return fmt.Sprintf("%s [r%s-%s]",
core.Properties["releaseid"],
core.Properties["releaselevel"],
core.Properties["releasenumber"])
}
func getHostName() string {
host, _ := os.Hostname()
return host
}
func getPWD() string {
thisPwd, _ := os.Getwd()
return thisPwd
}
func data_out() string {
do := ""
if core.Properties["deliverto"] != "" {
do = core.Properties["deliverto"]
} else {
do = getPWD() + core.Properties["data_out"]
}
return do
}
func data_in() string {
//fmt.Printf("core.Properties: %v\n", core.Properties)
return strings.TrimSpace(core.Properties["data_in"])
}
func enrichmentType(inSource string, inType string) bool {
return strings.EqualFold(inSource, inType)
}
func tf(in bool) string {
if in {
return "Y"
}
return ""
}
func getProperty(name string, props map[string]string) bool {
return strings.EqualFold(props[name], "Y")
}