/
logging.go
138 lines (94 loc) · 5.18 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package rbac
import (
"context"
"github.com/estafette/estafette-ci-api/pkg/api"
contracts "github.com/estafette/estafette-ci-contracts"
)
// NewLoggingService returns a new instance of a logging Service.
func NewLoggingService(s Service) Service {
return &loggingService{s, "oauth"}
}
type loggingService struct {
Service Service
prefix string
}
func (s *loggingService) GetRoles(ctx context.Context) (roles []string, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "GetRoles", err) }()
return s.Service.GetRoles(ctx)
}
func (s *loggingService) GetProviders(ctx context.Context) (providers []*api.OAuthProvider, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "GetProviders", err) }()
return s.Service.GetProviders(ctx)
}
func (s *loggingService) GetProviderByName(ctx context.Context, organization, name string) (provider *api.OAuthProvider, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "GetProviderByName", err) }()
return s.Service.GetProviderByName(ctx, organization, name)
}
func (s *loggingService) GetUserByIdentity(ctx context.Context, identity contracts.UserIdentity) (user *contracts.User, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "GetUserByIdentity", err) }()
return s.Service.GetUserByIdentity(ctx, identity)
}
func (s *loggingService) CreateUserFromIdentity(ctx context.Context, identity contracts.UserIdentity) (user *contracts.User, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "CreateUserFromIdentity", err) }()
return s.Service.CreateUserFromIdentity(ctx, identity)
}
func (s *loggingService) CreateUser(ctx context.Context, user contracts.User) (insertedUser *contracts.User, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "CreateUser", err) }()
return s.Service.CreateUser(ctx, user)
}
func (s *loggingService) UpdateUser(ctx context.Context, user contracts.User) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "UpdateUser", err) }()
return s.Service.UpdateUser(ctx, user)
}
func (s *loggingService) DeleteUser(ctx context.Context, id string) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "DeleteUser", err) }()
return s.Service.DeleteUser(ctx, id)
}
func (s *loggingService) CreateGroup(ctx context.Context, group contracts.Group) (insertedGroup *contracts.Group, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "CreateGroup", err) }()
return s.Service.CreateGroup(ctx, group)
}
func (s *loggingService) UpdateGroup(ctx context.Context, group contracts.Group) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "UpdateGroup", err) }()
return s.Service.UpdateGroup(ctx, group)
}
func (s *loggingService) DeleteGroup(ctx context.Context, id string) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "DeleteGroup", err) }()
return s.Service.DeleteGroup(ctx, id)
}
func (s *loggingService) CreateOrganization(ctx context.Context, organization contracts.Organization) (insertedOrganization *contracts.Organization, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "CreateOrganization", err) }()
return s.Service.CreateOrganization(ctx, organization)
}
func (s *loggingService) UpdateOrganization(ctx context.Context, organization contracts.Organization) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "UpdateOrganization", err) }()
return s.Service.UpdateOrganization(ctx, organization)
}
func (s *loggingService) DeleteOrganization(ctx context.Context, id string) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "DeleteOrganization", err) }()
return s.Service.DeleteOrganization(ctx, id)
}
func (s *loggingService) CreateClient(ctx context.Context, client contracts.Client) (insertedClient *contracts.Client, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "CreateClient", err) }()
return s.Service.CreateClient(ctx, client)
}
func (s *loggingService) UpdateClient(ctx context.Context, client contracts.Client) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "UpdateClient", err) }()
return s.Service.UpdateClient(ctx, client)
}
func (s *loggingService) DeleteClient(ctx context.Context, id string) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "DeleteClient", err) }()
return s.Service.DeleteClient(ctx, id)
}
func (s *loggingService) UpdatePipeline(ctx context.Context, pipeline contracts.Pipeline) (err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "UpdatePipeline", err) }()
return s.Service.UpdatePipeline(ctx, pipeline)
}
func (s *loggingService) GetInheritedRolesForUser(ctx context.Context, user contracts.User) (roles []*string, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "GetInheritedRolesForUser", err) }()
return s.Service.GetInheritedRolesForUser(ctx, user)
}
func (s *loggingService) GetInheritedOrganizationsForUser(ctx context.Context, user contracts.User) (organizations []*contracts.Organization, err error) {
defer func() { api.HandleLogError(s.prefix, "Service", "GetInheritedOrganizationsForUser", err) }()
return s.Service.GetInheritedOrganizationsForUser(ctx, user)
}