Skip to content

Commit d34f0f6

Browse files
authored
Fix linter warnings (#1634)
1 parent 31ba1b3 commit d34f0f6

File tree

7 files changed

+43
-22
lines changed

7 files changed

+43
-22
lines changed

acme/common.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,17 @@ func ProvisionerFromContext(ctx context.Context) (v Provisioner, ok bool) {
9393
return
9494
}
9595

96-
// MustLinkerFromContext returns the current provisioner from the given context.
96+
// MustProvisionerFromContext returns the current provisioner from the given context.
9797
// It will panic if it's not in the context.
9898
func MustProvisionerFromContext(ctx context.Context) Provisioner {
99-
if v, ok := ProvisionerFromContext(ctx); !ok {
99+
var (
100+
v Provisioner
101+
ok bool
102+
)
103+
if v, ok = ProvisionerFromContext(ctx); !ok {
100104
panic("acme provisioner is not the context")
101-
} else {
102-
return v
103105
}
106+
return v
104107
}
105108

106109
// MockProvisioner for testing

acme/db.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ func DatabaseFromContext(ctx context.Context) (db DB, ok bool) {
7171
// MustDatabaseFromContext returns the current database from the given context.
7272
// It will panic if it's not in the context.
7373
func MustDatabaseFromContext(ctx context.Context) DB {
74-
if db, ok := DatabaseFromContext(ctx); !ok {
74+
var (
75+
db DB
76+
ok bool
77+
)
78+
if db, ok = DatabaseFromContext(ctx); !ok {
7579
panic("acme database is not in the context")
76-
} else {
77-
return db
7880
}
81+
return db
7982
}
8083

8184
// MockDB is an implementation of the DB interface that should only be used as

acme/linker.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,14 @@ func LinkerFromContext(ctx context.Context) (v Linker, ok bool) {
142142
// MustLinkerFromContext returns the current linker from the given context. It
143143
// will panic if it's not in the context.
144144
func MustLinkerFromContext(ctx context.Context) Linker {
145-
if v, ok := LinkerFromContext(ctx); !ok {
145+
var (
146+
v Linker
147+
ok bool
148+
)
149+
if v, ok = LinkerFromContext(ctx); !ok {
146150
panic("acme linker is not the context")
147-
} else {
148-
return v
149151
}
152+
return v
150153
}
151154

152155
type baseURLKey struct{}

authority/admin/db.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,14 @@ func FromContext(ctx context.Context) (db DB, ok bool) {
9292
// MustFromContext returns the current admin database from the given context. It
9393
// will panic if it's not in the context.
9494
func MustFromContext(ctx context.Context) DB {
95-
if db, ok := FromContext(ctx); !ok {
95+
var (
96+
db DB
97+
ok bool
98+
)
99+
if db, ok = FromContext(ctx); !ok {
96100
panic("admin database is not in the context")
97-
} else {
98-
return db
99101
}
102+
return db
100103
}
101104

102105
// MockDB is an implementation of the DB interface that should only be used as

authority/authority.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,14 @@ func FromContext(ctx context.Context) (a *Authority, ok bool) {
201201
// MustFromContext returns the current authority from the given context. It will
202202
// panic if the authority is not in the context.
203203
func MustFromContext(ctx context.Context) *Authority {
204-
if a, ok := FromContext(ctx); !ok {
204+
var (
205+
a *Authority
206+
ok bool
207+
)
208+
if a, ok = FromContext(ctx); !ok {
205209
panic("authority is not in the context")
206-
} else {
207-
return a
208210
}
211+
return a
209212
}
210213

211214
// ReloadAdminResources reloads admins and provisioners from the DB.

db/db.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ func FromContext(ctx context.Context) (db AuthDB, ok bool) {
7878
// MustFromContext returns the current database from the given context. It
7979
// will panic if it's not in the context.
8080
func MustFromContext(ctx context.Context) AuthDB {
81-
if db, ok := FromContext(ctx); !ok {
81+
var (
82+
db AuthDB
83+
ok bool
84+
)
85+
if db, ok = FromContext(ctx); !ok {
8286
panic("authority database is not in the context")
83-
} else {
84-
return db
8587
}
88+
return db
8689
}
8790

8891
// CertificateStorer is an extension of AuthDB that allows to store

scep/authority.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,14 @@ func FromContext(ctx context.Context) (a *Authority, ok bool) {
4848
// MustFromContext returns the current authority from the given context. It will
4949
// panic if the authority is not in the context.
5050
func MustFromContext(ctx context.Context) *Authority {
51-
if a, ok := FromContext(ctx); !ok {
51+
var (
52+
a *Authority
53+
ok bool
54+
)
55+
if a, ok = FromContext(ctx); !ok {
5256
panic("scep authority is not in the context")
53-
} else {
54-
return a
5557
}
58+
return a
5659
}
5760

5861
// SignAuthority is the interface for a signing authority

0 commit comments

Comments
 (0)