Skip to content

Commit 8d725bb

Browse files
author
Ananth Bhaskararaman
committed
Close -> Stop
1 parent 1e3d5d5 commit 8d725bb

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

cmd/bf/ca.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ var caServeCmd = &cli.Command{
103103
bifrost.Logger().ErrorContext(ctx, "error creating CA", "error", err)
104104
return cli.Exit("Error creating CA", 1)
105105
}
106-
defer ca.Close()
106+
defer ca.Stop()
107107

108108
mux := http.NewServeMux()
109109
ca.AddRoutes(mux, exposeMetrics)
@@ -184,7 +184,7 @@ var caIssueCmd = &cli.Command{
184184
bifrost.Logger().ErrorContext(ctx, "error creating CA", "error", err)
185185
return cli.Exit("Error creating CA", 1)
186186
}
187-
defer ca.Close()
187+
defer ca.Stop()
188188

189189
clientKey, err := cafiles.GetPrivateKey(ctx, clientPrivKeyUri)
190190
if err != nil {

cmd/bf/proxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func issueTLSCert(
195195
if err != nil {
196196
return nil, err
197197
}
198-
defer ca.Close()
198+
defer ca.Stop()
199199

200200
caNs := caCert.Namespace
201201
csr := x509.CertificateRequest{

tinyca/ca.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ const (
3838
// The CA issues client certificates signed by a root certificate and private key.
3939
// The CA provides an HTTP handler to issue certificates.
4040
// The CA also provides a [Gauntlet] function to customize the certificate template.
41-
// Call Close to release resources when done.
41+
// Call Stop to release resources when done.
4242
type CA struct {
43-
io.Closer
44-
4543
cert *bifrost.Certificate
4644
key *bifrost.PrivateKey
4745
gh *gauntletThrower
@@ -254,10 +252,11 @@ func (ca *CA) IssueCertificate(asn1CSR []byte, notBefore, notAfter time.Time) ([
254252
return certBytes, nil
255253
}
256254

257-
// Close releases resources held by the CA.
258-
// Multiple calls to Close are safe.
259-
func (ca *CA) Close() error {
260-
return ca.gh.Close()
255+
// Stop releases resources held by the CA.
256+
func (ca *CA) Stop() {
257+
if ca.gh != nil {
258+
ca.gh.wg.Wait()
259+
}
261260
}
262261

263262
func readCsr(contentType string, body []byte) ([]byte, error) {

tinyca/ca_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func TestCA_ServeHTTP(t *testing.T) {
217217
if err != nil {
218218
t.Fatal(err)
219219
}
220-
defer ca.Close()
220+
defer ca.Stop()
221221

222222
method := http.MethodPost
223223
if tc.requestMethod != "" {
@@ -309,7 +309,7 @@ func TestCA_gauntlet_panic(t *testing.T) {
309309
if err != nil {
310310
t.Fatal(err)
311311
}
312-
defer ca.Close()
312+
defer ca.Stop()
313313

314314
rr := httptest.NewRecorder()
315315
req, err := http.NewRequest(http.MethodPost, "/", bytes.NewReader([]byte(validCsr)))

tinyca/gauntlet.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,3 @@ func (gh *gauntletThrower) throw(csr *bifrost.CertificateRequest) (*x509.Certifi
156156
return tmpl, nil
157157
}
158158
}
159-
160-
func (gh *gauntletThrower) Close() error {
161-
if gh.wg != nil {
162-
gh.wg.Wait()
163-
}
164-
165-
return nil
166-
}

0 commit comments

Comments
 (0)