-
Notifications
You must be signed in to change notification settings - Fork 4
/
logging.go
65 lines (46 loc) · 2.33 KB
/
logging.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
package builderapi
import (
"context"
"github.com/estafette/estafette-ci-api/pkg/api"
contracts "github.com/estafette/estafette-ci-contracts"
batchv1 "k8s.io/api/batch/v1"
)
// NewLoggingClient returns a new instance of a logging Client.
func NewLoggingClient(c Client) Client {
return &loggingClient{c, "builderapi"}
}
type loggingClient struct {
Client Client
prefix string
}
func (c *loggingClient) CreateCiBuilderJob(ctx context.Context, params CiBuilderParams) (job *batchv1.Job, err error) {
defer func() { api.HandleLogError(c.prefix, "Client", "CreateCiBuilderJob", err) }()
return c.Client.CreateCiBuilderJob(ctx, params)
}
func (c *loggingClient) RemoveCiBuilderJob(ctx context.Context, jobName string) (err error) {
defer func() { api.HandleLogError(c.prefix, "Client", "RemoveCiBuilderJob", err) }()
return c.Client.RemoveCiBuilderJob(ctx, jobName)
}
func (c *loggingClient) CancelCiBuilderJob(ctx context.Context, jobName string) (err error) {
defer func() { api.HandleLogError(c.prefix, "Client", "CancelCiBuilderJob", err) }()
return c.Client.CancelCiBuilderJob(ctx, jobName)
}
func (c *loggingClient) RemoveCiBuilderConfigMap(ctx context.Context, configmapName string) (err error) {
defer func() { api.HandleLogError(c.prefix, "Client", "RemoveCiBuilderConfigMap", err) }()
return c.Client.RemoveCiBuilderConfigMap(ctx, configmapName)
}
func (c *loggingClient) RemoveCiBuilderSecret(ctx context.Context, secretName string) (err error) {
defer func() { api.HandleLogError(c.prefix, "Client", "RemoveCiBuilderSecret", err) }()
return c.Client.RemoveCiBuilderSecret(ctx, secretName)
}
func (c *loggingClient) RemoveCiBuilderImagePullSecret(ctx context.Context, secretName string) (err error) {
defer func() { api.HandleLogError(c.prefix, "Client", "RemoveCiBuilderImagePullSecret", err) }()
return c.Client.RemoveCiBuilderImagePullSecret(ctx, secretName)
}
func (c *loggingClient) TailCiBuilderJobLogs(ctx context.Context, jobName string, logChannel chan contracts.TailLogLine) (err error) {
defer func() { api.HandleLogError(c.prefix, "Client", "TailCiBuilderJobLogs", err) }()
return c.Client.TailCiBuilderJobLogs(ctx, jobName, logChannel)
}
func (c *loggingClient) GetJobName(ctx context.Context, jobType contracts.JobType, repoOwner, repoName, id string) string {
return c.Client.GetJobName(ctx, jobType, repoOwner, repoName, id)
}