Copy dependencies into vendor dir, using dep
This commit is contained in:
1 parent
549ccff5eb
commit
b534ea60f5
2857 files changed
+945317
No files matched your search
+84
@@ -0,0 +1,84 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
type FmtMachineLogger struct {
|
||||
outWriter io.Writer
|
||||
errWriter io.Writer
|
||||
debug bool
|
||||
history *HistoryRecorder
|
||||
}
|
||||
|
||||
// NewFmtMachineLogger creates a MachineLogger implementation used by the drivers
|
||||
func NewFmtMachineLogger() MachineLogger {
|
||||
return &FmtMachineLogger{
|
||||
outWriter: os.Stdout,
|
||||
errWriter: os.Stderr,
|
||||
debug: false,
|
||||
history: NewHistoryRecorder(),
|
||||
}
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) SetDebug(debug bool) {
|
||||
ml.debug = debug
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) SetOutWriter(out io.Writer) {
|
||||
ml.outWriter = out
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) SetErrWriter(err io.Writer) {
|
||||
ml.errWriter = err
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) Debug(args ...interface{}) {
|
||||
ml.history.Record(args...)
|
||||
if ml.debug {
|
||||
fmt.Fprintln(ml.errWriter, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) Debugf(fmtString string, args ...interface{}) {
|
||||
ml.history.Recordf(fmtString, args...)
|
||||
if ml.debug {
|
||||
fmt.Fprintf(ml.errWriter, fmtString+"\n", args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) Error(args ...interface{}) {
|
||||
ml.history.Record(args...)
|
||||
fmt.Fprintln(ml.errWriter, args...)
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) Errorf(fmtString string, args ...interface{}) {
|
||||
ml.history.Recordf(fmtString, args...)
|
||||
fmt.Fprintf(ml.errWriter, fmtString+"\n", args...)
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) Info(args ...interface{}) {
|
||||
ml.history.Record(args...)
|
||||
fmt.Fprintln(ml.outWriter, args...)
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) Infof(fmtString string, args ...interface{}) {
|
||||
ml.history.Recordf(fmtString, args...)
|
||||
fmt.Fprintf(ml.outWriter, fmtString+"\n", args...)
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) Warn(args ...interface{}) {
|
||||
ml.history.Record(args...)
|
||||
fmt.Fprintln(ml.outWriter, args...)
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) Warnf(fmtString string, args ...interface{}) {
|
||||
ml.history.Recordf(fmtString, args...)
|
||||
fmt.Fprintf(ml.outWriter, fmtString+"\n", args...)
|
||||
}
|
||||
|
||||
func (ml *FmtMachineLogger) History() []string {
|
||||
return ml.history.records
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type HistoryRecorder struct {
|
||||
lock *sync.Mutex
|
||||
records []string
|
||||
}
|
||||
|
||||
func NewHistoryRecorder() *HistoryRecorder {
|
||||
return &HistoryRecorder{
|
||||
lock: &sync.Mutex{},
|
||||
records: []string{},
|
||||
}
|
||||
}
|
||||
|
||||
func (ml *HistoryRecorder) History() []string {
|
||||
return ml.records
|
||||
}
|
||||
|
||||
func (ml *HistoryRecorder) Record(args ...interface{}) {
|
||||
ml.lock.Lock()
|
||||
defer ml.lock.Unlock()
|
||||
ml.records = append(ml.records, fmt.Sprint(args...))
|
||||
}
|
||||
|
||||
func (ml *HistoryRecorder) Recordf(fmtString string, args ...interface{}) {
|
||||
ml.lock.Lock()
|
||||
defer ml.lock.Unlock()
|
||||
ml.records = append(ml.records, fmt.Sprintf(fmtString, args...))
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"io"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
const redactedText = "<REDACTED>"
|
||||
|
||||
var (
|
||||
logger = NewFmtMachineLogger()
|
||||
|
||||
// (?s) enables '.' to match '\n' -- see https://golang.org/pkg/regexp/syntax/
|
||||
certRegex = regexp.MustCompile("(?s)-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----")
|
||||
keyRegex = regexp.MustCompile("(?s)-----BEGIN RSA PRIVATE KEY-----.*-----END RSA PRIVATE KEY-----")
|
||||
)
|
||||
|
||||
func stripSecrets(original []string) []string {
|
||||
stripped := []string{}
|
||||
for _, line := range original {
|
||||
line = certRegex.ReplaceAllString(line, redactedText)
|
||||
line = keyRegex.ReplaceAllString(line, redactedText)
|
||||
stripped = append(stripped, line)
|
||||
}
|
||||
return stripped
|
||||
}
|
||||
|
||||
func Debug(args ...interface{}) {
|
||||
logger.Debug(args...)
|
||||
}
|
||||
|
||||
func Debugf(fmtString string, args ...interface{}) {
|
||||
logger.Debugf(fmtString, args...)
|
||||
}
|
||||
|
||||
func Error(args ...interface{}) {
|
||||
logger.Error(args...)
|
||||
}
|
||||
|
||||
func Errorf(fmtString string, args ...interface{}) {
|
||||
logger.Errorf(fmtString, args...)
|
||||
}
|
||||
|
||||
func Info(args ...interface{}) {
|
||||
logger.Info(args...)
|
||||
}
|
||||
|
||||
func Infof(fmtString string, args ...interface{}) {
|
||||
logger.Infof(fmtString, args...)
|
||||
}
|
||||
|
||||
func Warn(args ...interface{}) {
|
||||
logger.Warn(args...)
|
||||
}
|
||||
|
||||
func Warnf(fmtString string, args ...interface{}) {
|
||||
logger.Warnf(fmtString, args...)
|
||||
}
|
||||
|
||||
func SetDebug(debug bool) {
|
||||
logger.SetDebug(debug)
|
||||
}
|
||||
|
||||
func SetOutWriter(out io.Writer) {
|
||||
logger.SetOutWriter(out)
|
||||
}
|
||||
|
||||
func SetErrWriter(err io.Writer) {
|
||||
logger.SetErrWriter(err)
|
||||
}
|
||||
|
||||
func History() []string {
|
||||
return stripSecrets(logger.History())
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package log
|
||||
|
||||
import "io"
|
||||
|
||||
type MachineLogger interface {
|
||||
SetDebug(debug bool)
|
||||
|
||||
SetOutWriter(io.Writer)
|
||||
SetErrWriter(io.Writer)
|
||||
|
||||
Debug(args ...interface{})
|
||||
Debugf(fmtString string, args ...interface{})
|
||||
|
||||
Error(args ...interface{})
|
||||
Errorf(fmtString string, args ...interface{})
|
||||
|
||||
Info(args ...interface{})
|
||||
Infof(fmtString string, args ...interface{})
|
||||
|
||||
Warn(args ...interface{})
|
||||
Warnf(fmtString string, args ...interface{})
|
||||
|
||||
History() []string
|
||||
}
|
||||
Reference in new issue
Block a user