mirror of
https://github.com/outbackdingo/certificates.git
synced 2026-01-27 10:18:34 +00:00
Fix linter warnings (#1634)
This commit is contained in:
@@ -93,14 +93,17 @@ func ProvisionerFromContext(ctx context.Context) (v Provisioner, ok bool) {
|
||||
return
|
||||
}
|
||||
|
||||
// MustLinkerFromContext returns the current provisioner from the given context.
|
||||
// MustProvisionerFromContext returns the current provisioner from the given context.
|
||||
// It will panic if it's not in the context.
|
||||
func MustProvisionerFromContext(ctx context.Context) Provisioner {
|
||||
if v, ok := ProvisionerFromContext(ctx); !ok {
|
||||
var (
|
||||
v Provisioner
|
||||
ok bool
|
||||
)
|
||||
if v, ok = ProvisionerFromContext(ctx); !ok {
|
||||
panic("acme provisioner is not the context")
|
||||
} else {
|
||||
return v
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// MockProvisioner for testing
|
||||
|
||||
@@ -71,11 +71,14 @@ func DatabaseFromContext(ctx context.Context) (db DB, ok bool) {
|
||||
// MustDatabaseFromContext returns the current database from the given context.
|
||||
// It will panic if it's not in the context.
|
||||
func MustDatabaseFromContext(ctx context.Context) DB {
|
||||
if db, ok := DatabaseFromContext(ctx); !ok {
|
||||
var (
|
||||
db DB
|
||||
ok bool
|
||||
)
|
||||
if db, ok = DatabaseFromContext(ctx); !ok {
|
||||
panic("acme database is not in the context")
|
||||
} else {
|
||||
return db
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
// MockDB is an implementation of the DB interface that should only be used as
|
||||
|
||||
@@ -142,11 +142,14 @@ func LinkerFromContext(ctx context.Context) (v Linker, ok bool) {
|
||||
// MustLinkerFromContext returns the current linker from the given context. It
|
||||
// will panic if it's not in the context.
|
||||
func MustLinkerFromContext(ctx context.Context) Linker {
|
||||
if v, ok := LinkerFromContext(ctx); !ok {
|
||||
var (
|
||||
v Linker
|
||||
ok bool
|
||||
)
|
||||
if v, ok = LinkerFromContext(ctx); !ok {
|
||||
panic("acme linker is not the context")
|
||||
} else {
|
||||
return v
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
type baseURLKey struct{}
|
||||
|
||||
@@ -92,11 +92,14 @@ func FromContext(ctx context.Context) (db DB, ok bool) {
|
||||
// MustFromContext returns the current admin database from the given context. It
|
||||
// will panic if it's not in the context.
|
||||
func MustFromContext(ctx context.Context) DB {
|
||||
if db, ok := FromContext(ctx); !ok {
|
||||
var (
|
||||
db DB
|
||||
ok bool
|
||||
)
|
||||
if db, ok = FromContext(ctx); !ok {
|
||||
panic("admin database is not in the context")
|
||||
} else {
|
||||
return db
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
// MockDB is an implementation of the DB interface that should only be used as
|
||||
|
||||
@@ -201,11 +201,14 @@ func FromContext(ctx context.Context) (a *Authority, ok bool) {
|
||||
// MustFromContext returns the current authority from the given context. It will
|
||||
// panic if the authority is not in the context.
|
||||
func MustFromContext(ctx context.Context) *Authority {
|
||||
if a, ok := FromContext(ctx); !ok {
|
||||
var (
|
||||
a *Authority
|
||||
ok bool
|
||||
)
|
||||
if a, ok = FromContext(ctx); !ok {
|
||||
panic("authority is not in the context")
|
||||
} else {
|
||||
return a
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// ReloadAdminResources reloads admins and provisioners from the DB.
|
||||
|
||||
9
db/db.go
9
db/db.go
@@ -78,11 +78,14 @@ func FromContext(ctx context.Context) (db AuthDB, ok bool) {
|
||||
// MustFromContext returns the current database from the given context. It
|
||||
// will panic if it's not in the context.
|
||||
func MustFromContext(ctx context.Context) AuthDB {
|
||||
if db, ok := FromContext(ctx); !ok {
|
||||
var (
|
||||
db AuthDB
|
||||
ok bool
|
||||
)
|
||||
if db, ok = FromContext(ctx); !ok {
|
||||
panic("authority database is not in the context")
|
||||
} else {
|
||||
return db
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
// CertificateStorer is an extension of AuthDB that allows to store
|
||||
|
||||
@@ -48,11 +48,14 @@ func FromContext(ctx context.Context) (a *Authority, ok bool) {
|
||||
// MustFromContext returns the current authority from the given context. It will
|
||||
// panic if the authority is not in the context.
|
||||
func MustFromContext(ctx context.Context) *Authority {
|
||||
if a, ok := FromContext(ctx); !ok {
|
||||
var (
|
||||
a *Authority
|
||||
ok bool
|
||||
)
|
||||
if a, ok = FromContext(ctx); !ok {
|
||||
panic("scep authority is not in the context")
|
||||
} else {
|
||||
return a
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// SignAuthority is the interface for a signing authority
|
||||
|
||||
Reference in New Issue
Block a user