forked from orbitalci/orbital
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.go
44 lines (35 loc) · 907 Bytes
/
util.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
package common
import (
"encoding/base64"
"strings"
"github.com/shankj3/ocelot/models/pb"
)
func NCErr(msg string) *NoCreds {
return &NoCreds{msg: msg}
}
type NoCreds struct {
msg string
}
func (n *NoCreds) Error() string {
return n.msg
}
func BitzToBase64(bits []byte) string {
return base64.StdEncoding.EncodeToString(bits)
}
func StrToBase64(str string) string {
return base64.StdEncoding.EncodeToString([]byte(str))
}
func Base64ToBitz(b64string string) ([]byte, error) {
return base64.StdEncoding.DecodeString(b64string)
}
// BuildScriptsContainString will check all stages' script lines for the existence of the specified desiredString
func BuildScriptsContainString(wc *pb.BuildConfig, desiredString string) bool {
for _, stage := range wc.Stages {
for _, script := range stage.Script {
if strings.Contains(script, desiredString) {
return true
}
}
}
return false
}