/
api.go
71 lines (57 loc) · 1.54 KB
/
api.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
package logarchiver
import (
"io"
"time"
"github.com/Cloud-Foundations/Dominator/lib/log"
)
type BuildInfo struct {
Duration time.Duration `json:",omitempty"`
Error string `json:",omitempty"`
RequestorUsername string `json:",omitempty"`
}
type BuildLogArchiver interface {
AddBuildLog(string, BuildInfo, []byte) error
}
type BuildLogArchiveOptions struct {
Quota uint64
Topdir string
}
type BuildLogArchiveParams struct {
Logger log.DebugLogger
}
type BuildLogReporter interface {
GetBuildInfos(incGood, incBad bool) *BuildInfos
GetBuildInfosForRequestor(username string, incGood, incBad bool) *BuildInfos
GetBuildInfosForStream(streamName string, incGood, incBad bool) *BuildInfos
GetBuildLog(imageName string) (io.ReadCloser, error)
GetSummary() *Summary
}
type BuildLogger interface {
BuildLogArchiver
BuildLogReporter
}
type BuildInfos struct {
Builds map[string]BuildInfo // Key: image name.
ImagesByAge []string // May be empty.
}
type RequestorSummary struct {
NumBuilds uint64
NumGoodBuilds uint64
NumErrorBuilds uint64
}
type StreamSummary struct {
NumBuilds uint64
NumGoodBuilds uint64
NumErrorBuilds uint64
}
type Summary struct {
Requestors map[string]*RequestorSummary // Key: username.
Streams map[string]*StreamSummary // Key: stream name.
}
func New(options BuildLogArchiveOptions,
params BuildLogArchiveParams) (BuildLogger, error) {
return newBuildLogArchive(options, params)
}
func NewNullLogger() BuildLogArchiver {
return newNullLogger()
}