Skip to content

Commit edc3c7f

Browse files
authored
Shorten "identifier(s)" in variable names & function arguments (#8066)
For consistency, and to prevent confusion with the `identifier` package, use "ident(s)" instead. Part of #7311
1 parent 767c5d1 commit edc3c7f

File tree

11 files changed

+89
-87
lines changed

11 files changed

+89
-87
lines changed

cmd/admin/pause_identifier.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ func (p *subcommandPauseIdentifier) Run(ctx context.Context, a *admin) error {
3939
return errors.New("the -batch-file flag is required")
4040
}
4141

42-
identifiers, err := a.readPausedAccountFile(p.batchFile)
42+
idents, err := a.readPausedAccountFile(p.batchFile)
4343
if err != nil {
4444
return err
4545
}
4646

47-
_, err = a.pauseIdentifiers(ctx, identifiers, p.parallelism)
47+
_, err = a.pauseIdentifiers(ctx, idents, p.parallelism)
4848
if err != nil {
4949
return err
5050
}
@@ -60,19 +60,19 @@ func (a *admin) pauseIdentifiers(ctx context.Context, entries []pauseCSVData, pa
6060
return nil, errors.New("cannot pause identifiers because no pauseData was sent")
6161
}
6262

63-
accountToIdentifiers := make(map[int64][]*corepb.Identifier)
63+
accountToIdents := make(map[int64][]*corepb.Identifier)
6464
for _, entry := range entries {
65-
accountToIdentifiers[entry.accountID] = append(accountToIdentifiers[entry.accountID], &corepb.Identifier{
65+
accountToIdents[entry.accountID] = append(accountToIdents[entry.accountID], &corepb.Identifier{
6666
Type: string(entry.identifierType),
6767
Value: entry.identifierValue,
6868
})
6969
}
7070

7171
var errCount atomic.Uint64
72-
respChan := make(chan *sapb.PauseIdentifiersResponse, len(accountToIdentifiers))
72+
respChan := make(chan *sapb.PauseIdentifiersResponse, len(accountToIdents))
7373
work := make(chan struct {
74-
accountID int64
75-
identifiers []*corepb.Identifier
74+
accountID int64
75+
idents []*corepb.Identifier
7676
}, parallelism)
7777

7878
var wg sync.WaitGroup
@@ -83,23 +83,23 @@ func (a *admin) pauseIdentifiers(ctx context.Context, entries []pauseCSVData, pa
8383
for data := range work {
8484
response, err := a.sac.PauseIdentifiers(ctx, &sapb.PauseRequest{
8585
RegistrationID: data.accountID,
86-
Identifiers: data.identifiers,
86+
Identifiers: data.idents,
8787
})
8888
if err != nil {
8989
errCount.Add(1)
90-
a.log.Errf("error pausing identifier(s) %q for account %d: %v", data.identifiers, data.accountID, err)
90+
a.log.Errf("error pausing identifier(s) %q for account %d: %v", data.idents, data.accountID, err)
9191
} else {
9292
respChan <- response
9393
}
9494
}
9595
}()
9696
}
9797

98-
for accountID, identifiers := range accountToIdentifiers {
98+
for accountID, idents := range accountToIdents {
9999
work <- struct {
100-
accountID int64
101-
identifiers []*corepb.Identifier
102-
}{accountID, identifiers}
100+
accountID int64
101+
idents []*corepb.Identifier
102+
}{accountID, idents}
103103
}
104104
close(work)
105105
wg.Wait()

core/util_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func TestUniqueLowerNames(t *testing.T) {
256256
}
257257

258258
func TestNormalizeIdentifiers(t *testing.T) {
259-
identifiers := []identifier.ACMEIdentifier{
259+
idents := []identifier.ACMEIdentifier{
260260
{Type: "DNS", Value: "foobar.com"},
261261
{Type: "DNS", Value: "fooBAR.com"},
262262
{Type: "DNS", Value: "baz.com"},
@@ -271,7 +271,7 @@ func TestNormalizeIdentifiers(t *testing.T) {
271271
{Type: "DNS", Value: "baz.com"},
272272
{Type: "DNS", Value: "foobar.com"},
273273
}
274-
u := NormalizeIdentifiers(identifiers)
274+
u := NormalizeIdentifiers(idents)
275275
test.AssertDeepEquals(t, expected, u)
276276
}
277277

csr/csr_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
type mockPA struct{}
2424

25-
func (pa *mockPA) ChallengeTypesFor(identifier identifier.ACMEIdentifier) ([]core.AcmeChallenge, error) {
25+
func (pa *mockPA) ChallengeTypesFor(ident identifier.ACMEIdentifier) ([]core.AcmeChallenge, error) {
2626
return []core.AcmeChallenge{}, nil
2727
}
2828

grpc/pb-marshalling_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func TestRegistration(t *testing.T) {
227227

228228
func TestAuthz(t *testing.T) {
229229
exp := time.Now().AddDate(0, 0, 1).UTC()
230-
identifier := identifier.NewDNS("example.com")
230+
ident := identifier.NewDNS("example.com")
231231
challA := core.Challenge{
232232
Type: core.ChallengeTypeDNS01,
233233
Status: core.StatusPending,
@@ -240,7 +240,7 @@ func TestAuthz(t *testing.T) {
240240
}
241241
inAuthz := core.Authorization{
242242
ID: "1",
243-
Identifier: identifier,
243+
Identifier: ident,
244244
RegistrationID: 5,
245245
Status: core.StatusPending,
246246
Expires: &exp,
@@ -254,7 +254,7 @@ func TestAuthz(t *testing.T) {
254254

255255
inAuthzNilExpires := core.Authorization{
256256
ID: "1",
257-
Identifier: identifier,
257+
Identifier: ident,
258258
RegistrationID: 5,
259259
Status: core.StatusPending,
260260
Expires: nil,

pkcs11helpers/helpers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ const (
235235

236236
// Hash identifiers required for PKCS#11 RSA signing. Only support SHA-256, SHA-384,
237237
// and SHA-512
238-
var hashIdentifiers = map[crypto.Hash][]byte{
238+
var hashIdents = map[crypto.Hash][]byte{
239239
crypto.SHA256: {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20},
240240
crypto.SHA384: {0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30},
241241
crypto.SHA512: {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40},
@@ -250,7 +250,7 @@ func (s *Session) Sign(object pkcs11.ObjectHandle, keyType keyType, digest []byt
250250
switch keyType {
251251
case RSAKey:
252252
mech[0] = pkcs11.NewMechanism(pkcs11.CKM_RSA_PKCS, nil)
253-
prefix, ok := hashIdentifiers[hash]
253+
prefix, ok := hashIdents[hash]
254254
if !ok {
255255
return nil, errors.New("unsupported hash function")
256256
}

sa/sa.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -1324,17 +1324,17 @@ func (ssa *SQLStorageAuthority) PauseIdentifiers(ctx context.Context, req *sapb.
13241324
}
13251325

13261326
// Marshal the identifier now that we've crossed the RPC boundary.
1327-
identifiers, err := newIdentifierModelsFromPB(req.Identifiers)
1327+
idents, err := newIdentifierModelsFromPB(req.Identifiers)
13281328
if err != nil {
13291329
return nil, err
13301330
}
13311331

13321332
response := &sapb.PauseIdentifiersResponse{}
13331333
_, err = db.WithTransaction(ctx, ssa.dbMap, func(tx db.Executor) (interface{}, error) {
1334-
for _, identifier := range identifiers {
1334+
for _, ident := range idents {
13351335
pauseError := func(op string, err error) error {
13361336
return fmt.Errorf("while %s identifier %s for registration ID %d: %w",
1337-
op, identifier.Value, req.RegistrationID, err,
1337+
op, ident.Value, req.RegistrationID, err,
13381338
)
13391339
}
13401340

@@ -1347,8 +1347,8 @@ func (ssa *SQLStorageAuthority) PauseIdentifiers(ctx context.Context, req *sapb.
13471347
identifierType = ? AND
13481348
identifierValue = ?`,
13491349
req.RegistrationID,
1350-
identifier.Type,
1351-
identifier.Value,
1350+
ident.Type,
1351+
ident.Value,
13521352
)
13531353

13541354
switch {
@@ -1362,8 +1362,8 @@ func (ssa *SQLStorageAuthority) PauseIdentifiers(ctx context.Context, req *sapb.
13621362
RegistrationID: req.RegistrationID,
13631363
PausedAt: ssa.clk.Now().Truncate(time.Second),
13641364
identifierModel: identifierModel{
1365-
Type: identifier.Type,
1366-
Value: identifier.Value,
1365+
Type: ident.Type,
1366+
Value: ident.Value,
13671367
},
13681368
})
13691369
if err != nil && !db.IsDuplicate(err) {
@@ -1395,8 +1395,8 @@ func (ssa *SQLStorageAuthority) PauseIdentifiers(ctx context.Context, req *sapb.
13951395
unpausedAt IS NOT NULL`,
13961396
ssa.clk.Now().Truncate(time.Second),
13971397
req.RegistrationID,
1398-
identifier.Type,
1399-
identifier.Value,
1398+
ident.Type,
1399+
ident.Value,
14001400
)
14011401
if err != nil {
14021402
return nil, pauseError("repausing", err)
@@ -1409,7 +1409,7 @@ func (ssa *SQLStorageAuthority) PauseIdentifiers(ctx context.Context, req *sapb.
14091409
default:
14101410
// This indicates a database state which should never occur.
14111411
return nil, fmt.Errorf("impossible database state encountered while pausing identifier %s",
1412-
identifier.Value,
1412+
ident.Value,
14131413
)
14141414
}
14151415
}

sa/saro.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -1155,19 +1155,19 @@ func (ssa *SQLStorageAuthorityRO) CheckIdentifiersPaused(ctx context.Context, re
11551155
return nil, errIncompleteRequest
11561156
}
11571157

1158-
identifiers, err := newIdentifierModelsFromPB(req.Identifiers)
1158+
idents, err := newIdentifierModelsFromPB(req.Identifiers)
11591159
if err != nil {
11601160
return nil, err
11611161
}
11621162

1163-
if len(identifiers) == 0 {
1163+
if len(idents) == 0 {
11641164
// No identifier values to check.
11651165
return nil, nil
11661166
}
11671167

1168-
identifiersByType := map[uint8][]string{}
1169-
for _, id := range identifiers {
1170-
identifiersByType[id.Type] = append(identifiersByType[id.Type], id.Value)
1168+
identsByType := map[uint8][]string{}
1169+
for _, id := range idents {
1170+
identsByType[id.Type] = append(identsByType[id.Type], id.Value)
11711171
}
11721172

11731173
// Build a query to retrieve up to 15 paused identifiers using OR clauses
@@ -1187,7 +1187,7 @@ func (ssa *SQLStorageAuthorityRO) CheckIdentifiersPaused(ctx context.Context, re
11871187

11881188
var conditions []string
11891189
args := []interface{}{req.RegistrationID}
1190-
for idType, values := range identifiersByType {
1190+
for idType, values := range identsByType {
11911191
conditions = append(conditions,
11921192
fmt.Sprintf("identifierType = ? AND identifierValue IN (%s)",
11931193
db.QuestionMarks(len(values)),

sfe/sfe.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (sfe *SelfServiceFrontEndImpl) BuildID(response http.ResponseWriter, reques
152152
func (sfe *SelfServiceFrontEndImpl) UnpauseForm(response http.ResponseWriter, request *http.Request) {
153153
incomingJWT := request.URL.Query().Get("jwt")
154154

155-
accountID, identifiers, err := sfe.parseUnpauseJWT(incomingJWT)
155+
accountID, idents, err := sfe.parseUnpauseJWT(incomingJWT)
156156
if err != nil {
157157
if errors.Is(err, jwt.ErrExpired) {
158158
// JWT expired before the Subscriber visited the unpause page.
@@ -170,14 +170,14 @@ func (sfe *SelfServiceFrontEndImpl) UnpauseForm(response http.ResponseWriter, re
170170
}
171171

172172
type tmplData struct {
173-
PostPath string
174-
JWT string
175-
AccountID int64
176-
Identifiers []string
173+
PostPath string
174+
JWT string
175+
AccountID int64
176+
Idents []string
177177
}
178178

179179
// Present the unpause form to the Subscriber.
180-
sfe.renderTemplate(response, "unpause-form.html", tmplData{unpausePostForm, incomingJWT, accountID, identifiers})
180+
sfe.renderTemplate(response, "unpause-form.html", tmplData{unpausePostForm, incomingJWT, accountID, idents})
181181
}
182182

183183
// UnpauseSubmit serves a page showing the result of the unpause form submission.

unpause/unpause.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/go-jose/go-jose/v4"
1111
"github.com/go-jose/go-jose/v4/jwt"
1212
"github.com/jmhodges/clock"
13+
1314
"github.com/letsencrypt/boulder/cmd"
1415
)
1516

@@ -70,7 +71,7 @@ type JWTClaims struct {
7071
}
7172

7273
// GenerateJWT generates a serialized unpause JWT with the provided claims.
73-
func GenerateJWT(signer JWTSigner, regID int64, identifiers []string, lifetime time.Duration, clk clock.Clock) (string, error) {
74+
func GenerateJWT(signer JWTSigner, regID int64, idents []string, lifetime time.Duration, clk clock.Clock) (string, error) {
7475
claims := JWTClaims{
7576
Claims: jwt.Claims{
7677
Issuer: defaultIssuer,
@@ -81,7 +82,7 @@ func GenerateJWT(signer JWTSigner, regID int64, identifiers []string, lifetime t
8182
Expiry: jwt.NewNumericDate(clk.Now().Add(lifetime)),
8283
},
8384
V: APIVersion,
84-
I: strings.Join(identifiers, ","),
85+
I: strings.Join(idents, ","),
8586
}
8687

8788
serialized, err := jwt.Signed(signer).Claims(&claims).Serialize()

0 commit comments

Comments
 (0)