-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.go
73 lines (51 loc) · 1.7 KB
/
utils.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
/*
* Copyright contributors to the IBM Security Verify Operator project
*/
package main
/*****************************************************************************/
import (
"errors"
"fmt"
"strings"
"github.com/go-logr/logr"
apiv1 "k8s.io/api/core/v1"
)
/*****************************************************************************/
/*
* Logging information.
*/
type LogInfo struct {
log *logr.Logger
currentLevel int
attributes []interface{}
}
/*****************************************************************************/
/*
* Add some debug trace based on the specified level and the current level.
*/
func (l *LogInfo)Log(level int, msg string, kvList ...interface{}) {
if (l.currentLevel >= level) {
(*l.log).Info(msg, append(l.attributes, kvList...)...)
}
}
/*****************************************************************************/
/*
* Add some debug trace based on the specified level and the current level.
*/
func (l *LogInfo)Error(err error, msg string, kvList ...interface{}) {
(*l.log).Error(err, msg, append(l.attributes, kvList...)...)
}
/*****************************************************************************/
/*
* Retrieve the base64 decoded piece of data from the supplied secret.
*/
func GetSecretData(secret *apiv1.Secret, name string) (string, error) {
value, ok := secret.Data[name]
if !ok {
return "", errors.New(
fmt.Sprintf("The field, %s, is not available in the " +
"secret: %s", name, secret.Name))
}
return strings.TrimSuffix(string(value), "\n"), nil
}
/*****************************************************************************/