Skip to content

Commit c57e1b4

Browse files
salesforce: Rename email package and pardort-test-srv
1 parent 3922886 commit c57e1b4

26 files changed

+652
-129
lines changed

Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ COPY --from=builder \
4646
/opt/boulder/bin/boulder \
4747
/opt/boulder/bin/chall-test-srv \
4848
/opt/boulder/bin/ct-test-srv \
49-
/opt/boulder/bin/pardot-test-srv \
49+
/opt/boulder/bin/salesforce-test-srv \
5050
/opt/boulder/bin/zendesk-test-srv \
5151
/opt/boulder/bin/
5252
COPY --from=builder /opt/boulder/data /opt/boulder/data

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ VERSION ?= 1.0.0
77
EPOCH ?= 1
88
MAINTAINER ?= "Community"
99

10-
CMDS = admin boulder ceremony ct-test-srv pardot-test-srv chall-test-srv zendesk-test-srv
10+
CMDS = admin boulder ceremony ct-test-srv salesforce-test-srv chall-test-srv zendesk-test-srv
1111
CMD_BINS = $(addprefix bin/, $(CMDS) )
1212
OBJECTS = $(CMD_BINS)
1313

cmd/boulder-wfe2/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414

1515
"github.com/letsencrypt/boulder/cmd"
1616
"github.com/letsencrypt/boulder/config"
17-
emailpb "github.com/letsencrypt/boulder/email/proto"
1817
"github.com/letsencrypt/boulder/features"
1918
"github.com/letsencrypt/boulder/goodkey"
2019
"github.com/letsencrypt/boulder/goodkey/sagoodkey"
@@ -26,6 +25,7 @@ import (
2625
"github.com/letsencrypt/boulder/ratelimits"
2726
bredis "github.com/letsencrypt/boulder/redis"
2827
sapb "github.com/letsencrypt/boulder/sa/proto"
28+
salesforcepb "github.com/letsencrypt/boulder/salesforce/proto"
2929
"github.com/letsencrypt/boulder/unpause"
3030
"github.com/letsencrypt/boulder/web"
3131
"github.com/letsencrypt/boulder/wfe2"
@@ -286,11 +286,11 @@ func main() {
286286
cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to SA")
287287
sac := sapb.NewStorageAuthorityReadOnlyClient(saConn)
288288

289-
var eec emailpb.ExporterClient
289+
var eec salesforcepb.ExporterClient
290290
if c.WFE.EmailExporter != nil {
291291
emailExporterConn, err := bgrpc.ClientSetup(c.WFE.EmailExporter, tlsConfig, stats, clk)
292292
cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to email-exporter")
293-
eec = emailpb.NewExporterClient(emailExporterConn)
293+
eec = salesforcepb.NewExporterClient(emailExporterConn)
294294
}
295295

296296
if c.WFE.RedeemNonceService == nil {

cmd/email-exporter/main.go

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import (
66
"os"
77

88
"github.com/jmhodges/clock"
9+
"google.golang.org/protobuf/types/known/emptypb"
910

1011
"github.com/letsencrypt/boulder/cmd"
11-
"github.com/letsencrypt/boulder/email"
12-
emailpb "github.com/letsencrypt/boulder/email/proto"
1312
bgrpc "github.com/letsencrypt/boulder/grpc"
13+
"github.com/letsencrypt/boulder/salesforce"
14+
emailpb "github.com/letsencrypt/boulder/salesforce/email/proto"
15+
salesforcepb "github.com/letsencrypt/boulder/salesforce/proto"
1416
)
1517

1618
// Config holds the configuration for the email-exporter service.
@@ -62,6 +64,34 @@ type Config struct {
6264
OpenTelemetry cmd.OpenTelemetryConfig
6365
}
6466

67+
// legacyEmailExporterServer adapts the salesforce exporter implementation to
68+
// the deprecated email.Exporter gRPC service.
69+
//
70+
// TODO(#8410): Remove legacyEmailExporterServer once fully migrated to
71+
// salesforcepb.Exporter.
72+
type legacyEmailExporterServer struct {
73+
emailpb.UnimplementedExporterServer
74+
delegate salesforcepb.ExporterServer
75+
}
76+
77+
func (s legacyEmailExporterServer) SendContacts(ctx context.Context, req *emailpb.SendContactsRequest) (*emptypb.Empty, error) {
78+
return s.delegate.SendContacts(ctx, &salesforcepb.SendContactsRequest{Emails: req.GetEmails()})
79+
}
80+
81+
func (s legacyEmailExporterServer) SendCase(ctx context.Context, req *emailpb.SendCaseRequest) (*emptypb.Empty, error) {
82+
return s.delegate.SendCase(ctx, &salesforcepb.SendCaseRequest{
83+
Origin: req.GetOrigin(),
84+
Subject: req.GetSubject(),
85+
Description: req.GetDescription(),
86+
ContactEmail: req.GetContactEmail(),
87+
Organization: req.GetOrganization(),
88+
AccountId: req.GetAccountId(),
89+
RateLimitName: req.GetRateLimitName(),
90+
RateLimitTier: req.GetRateLimitTier(),
91+
UseCase: req.GetUseCase(),
92+
})
93+
}
94+
6595
func main() {
6696
configFile := flag.String("config", "", "Path to configuration file")
6797
grpcAddr := flag.String("addr", "", "gRPC listen address override")
@@ -95,12 +125,12 @@ func main() {
95125
clientSecret, err := c.EmailExporter.ClientSecret.Pass()
96126
cmd.FailOnError(err, "Loading clientSecret")
97127

98-
var cache *email.EmailCache
128+
var cache *salesforce.EmailCache
99129
if c.EmailExporter.EmailCacheSize > 0 {
100-
cache = email.NewHashedEmailCache(c.EmailExporter.EmailCacheSize, scope)
130+
cache = salesforce.NewHashedEmailCache(c.EmailExporter.EmailCacheSize, scope)
101131
}
102132

103-
sfClient, err := email.NewSalesforceClientImpl(
133+
sfClient, err := salesforce.NewSalesforceClientImpl(
104134
clk,
105135
c.EmailExporter.PardotBusinessUnit,
106136
clientId,
@@ -109,21 +139,25 @@ func main() {
109139
c.EmailExporter.PardotBaseURL,
110140
)
111141
cmd.FailOnError(err, "Creating Pardot API client")
112-
exporterServer := email.NewExporterImpl(sfClient, cache, c.EmailExporter.PerDayLimit, c.EmailExporter.MaxConcurrentRequests, scope, logger)
142+
server := salesforce.NewExporterImpl(sfClient, cache, c.EmailExporter.PerDayLimit, c.EmailExporter.MaxConcurrentRequests, scope, logger)
113143

114144
tlsConfig, err := c.EmailExporter.TLS.Load(scope)
115145
cmd.FailOnError(err, "Loading email-exporter TLS config")
116146

117-
daemonCtx, shutdownExporterServer := context.WithCancel(context.Background())
118-
go exporterServer.Start(daemonCtx)
147+
daemonCtx, shutdown := context.WithCancel(context.Background())
148+
go server.Start(daemonCtx)
119149

120-
start, err := bgrpc.NewServer(c.EmailExporter.GRPC, logger).Add(
121-
&emailpb.Exporter_ServiceDesc, exporterServer).Build(tlsConfig, scope, clk)
150+
srv := bgrpc.NewServer(c.EmailExporter.GRPC, logger)
151+
srv = srv.Add(&salesforcepb.Exporter_ServiceDesc, server)
152+
// TODO(#8410): Remove emailpb.Exporter once fully migrated to
153+
// salesforcepb.Exporter.
154+
srv = srv.Add(&emailpb.Exporter_ServiceDesc, legacyEmailExporterServer{delegate: server})
155+
start, err := srv.Build(tlsConfig, scope, clk)
122156
cmd.FailOnError(err, "Configuring email-exporter gRPC server")
123157

124158
err = start()
125-
shutdownExporterServer()
126-
exporterServer.Drain()
159+
shutdown()
160+
server.Drain()
127161
cmd.FailOnError(err, "email-exporter gRPC service failed to start")
128162
}
129163

cmd/sfe/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import (
1111

1212
"github.com/letsencrypt/boulder/cmd"
1313
"github.com/letsencrypt/boulder/config"
14-
emailpb "github.com/letsencrypt/boulder/email/proto"
1514
"github.com/letsencrypt/boulder/features"
1615
bgrpc "github.com/letsencrypt/boulder/grpc"
1716
rapb "github.com/letsencrypt/boulder/ra/proto"
1817
"github.com/letsencrypt/boulder/ratelimits"
1918
bredis "github.com/letsencrypt/boulder/redis"
2019
sapb "github.com/letsencrypt/boulder/sa/proto"
20+
salesforcepb "github.com/letsencrypt/boulder/salesforce/proto"
2121
"github.com/letsencrypt/boulder/sfe"
2222
"github.com/letsencrypt/boulder/sfe/zendesk"
2323
"github.com/letsencrypt/boulder/web"
@@ -156,11 +156,11 @@ func main() {
156156
cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to SA")
157157
sac := sapb.NewStorageAuthorityReadOnlyClient(saConn)
158158

159-
var eec emailpb.ExporterClient
159+
var eec salesforcepb.ExporterClient
160160
if c.SFE.EmailExporter != nil {
161161
emailExporterConn, err := bgrpc.ClientSetup(c.SFE.EmailExporter, tlsConfig, stats, clk)
162162
cmd.FailOnError(err, "Failed to load credentials and create gRPC connection to email-exporter")
163-
eec = emailpb.NewExporterClient(emailExporterConn)
163+
eec = salesforcepb.NewExporterClient(emailExporterConn)
164164
}
165165

166166
var zendeskClient *zendesk.Client

mocks/emailexporter.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ import (
88
"google.golang.org/grpc"
99
"google.golang.org/protobuf/types/known/emptypb"
1010

11-
"github.com/letsencrypt/boulder/email"
12-
emailpb "github.com/letsencrypt/boulder/email/proto"
11+
"github.com/letsencrypt/boulder/salesforce"
12+
salesforcepb "github.com/letsencrypt/boulder/salesforce/proto"
1313
)
1414

15-
var _ email.SalesforceClient = (*MockSalesforceClientImpl)(nil)
15+
var _ salesforce.SalesforceClient = (*MockSalesforceClientImpl)(nil)
1616

17-
// MockSalesforceClientImpl is a mock implementation of email.SalesforceClient.
17+
// MockSalesforceClientImpl is a mock implementation of salesforce.SalesforceClient.
1818
type MockSalesforceClientImpl struct {
1919
sync.Mutex
2020
CreatedContacts []string
21-
CreatedCases []email.Case
21+
CreatedCases []salesforce.Case
2222
}
2323

2424
// NewMockSalesforceClientImpl returns a MockSalesforceClientImpl, which implements
@@ -48,7 +48,7 @@ func (m *MockSalesforceClientImpl) GetCreatedContacts() []string {
4848
}
4949

5050
// SendCase adds a case payload to CreatedCases.
51-
func (m *MockSalesforceClientImpl) SendCase(payload email.Case) error {
51+
func (m *MockSalesforceClientImpl) SendCase(payload salesforce.Case) error {
5252
m.Lock()
5353
defer m.Unlock()
5454

@@ -58,31 +58,31 @@ func (m *MockSalesforceClientImpl) SendCase(payload email.Case) error {
5858

5959
// GetCreatedCases is used for testing to retrieve the list of created cases in
6060
// a thread-safe manner.
61-
func (m *MockSalesforceClientImpl) GetCreatedCases() []email.Case {
61+
func (m *MockSalesforceClientImpl) GetCreatedCases() []salesforce.Case {
6262
m.Lock()
6363
defer m.Unlock()
6464

6565
// Return a copy to avoid race conditions.
6666
return slices.Clone(m.CreatedCases)
6767
}
6868

69-
var _ emailpb.ExporterClient = (*MockExporterClientImpl)(nil)
69+
var _ salesforcepb.ExporterClient = (*MockExporterClientImpl)(nil)
7070

7171
// MockExporterClientImpl is a mock implementation of ExporterClient.
7272
type MockExporterClientImpl struct {
73-
SalesforceClient email.SalesforceClient
73+
SalesforceClient salesforce.SalesforceClient
7474
}
7575

7676
// NewMockExporterImpl returns a MockExporterClientImpl as an ExporterClient.
77-
func NewMockExporterImpl(salesforceClient email.SalesforceClient) emailpb.ExporterClient {
77+
func NewMockExporterImpl(salesforceClient salesforce.SalesforceClient) salesforcepb.ExporterClient {
7878
return &MockExporterClientImpl{
7979
SalesforceClient: salesforceClient,
8080
}
8181
}
8282

83-
// SendContacts submits emails to the inner email.SalesforceClient, returning an
83+
// SendContacts submits emails to the inner salesforce.SalesforceClient, returning an
8484
// error if any fail.
85-
func (m *MockExporterClientImpl) SendContacts(ctx context.Context, req *emailpb.SendContactsRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
85+
func (m *MockExporterClientImpl) SendContacts(ctx context.Context, req *salesforcepb.SendContactsRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
8686
for _, e := range req.Emails {
8787
err := m.SalesforceClient.SendContact(e)
8888
if err != nil {
@@ -92,9 +92,9 @@ func (m *MockExporterClientImpl) SendContacts(ctx context.Context, req *emailpb.
9292
return &emptypb.Empty{}, nil
9393
}
9494

95-
// SendCase submits a Case using the inner email.SalesforceClient.
96-
func (m *MockExporterClientImpl) SendCase(ctx context.Context, req *emailpb.SendCaseRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
97-
return &emptypb.Empty{}, m.SalesforceClient.SendCase(email.Case{
95+
// SendCase submits a Case using the inner salesforce.SalesforceClient.
96+
func (m *MockExporterClientImpl) SendCase(ctx context.Context, req *salesforcepb.SendCaseRequest, _ ...grpc.CallOption) (*emptypb.Empty, error) {
97+
return &emptypb.Empty{}, m.SalesforceClient.SendCase(salesforce.Case{
9898
Origin: req.Origin,
9999
Subject: req.Subject,
100100
Description: req.Description,

email/cache.go renamed to salesforce/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package email
1+
package salesforce
22

33
import (
44
"crypto/sha256"

0 commit comments

Comments
 (0)