forked from TrueCloudLab/certificates
Merge pull request #106 from smallstep/lint
Added a staticcheck and unused linters and trying to clear up new errors
This commit is contained in:
commit
9f0d8545a3
14 changed files with 14 additions and 53 deletions
|
@ -49,6 +49,8 @@ linters:
|
|||
- misspell
|
||||
- ineffassign
|
||||
- deadcode
|
||||
- staticcheck
|
||||
- unused
|
||||
|
||||
run:
|
||||
skip-dirs:
|
||||
|
@ -60,10 +62,9 @@ issues:
|
|||
- declaration of "err" shadows declaration at line
|
||||
- should have a package comment, unless it's in another file for this package
|
||||
- error strings should not be capitalized or end with punctuation or a newline
|
||||
- declaration of "authz" shadows declaration at line
|
||||
# golangci.com configuration
|
||||
# https://github.com/golangci/golangci/wiki/Configuration
|
||||
service:
|
||||
golangci-lint-version: 1.17.x # use the fixed version to not introduce new linters unexpectedly
|
||||
golangci-lint-version: 1.18.x # use the fixed version to not introduce new linters unexpectedly
|
||||
prepare:
|
||||
- echo "here I can run custom commands, but no preparation needed for this repo"
|
||||
|
|
|
@ -214,18 +214,18 @@ func (a *Authority) FinalizeOrder(p provisioner.Interface, accID, orderID string
|
|||
// GetAuthz retrieves and attempts to update the status on an ACME authz
|
||||
// before returning.
|
||||
func (a *Authority) GetAuthz(p provisioner.Interface, accID, authzID string) (*Authz, error) {
|
||||
authz, err := getAuthz(a.db, authzID)
|
||||
az, err := getAuthz(a.db, authzID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if accID != authz.getAccountID() {
|
||||
if accID != az.getAccountID() {
|
||||
return nil, UnauthorizedErr(errors.New("account does not own authz"))
|
||||
}
|
||||
authz, err = authz.updateStatus(a.db)
|
||||
az, err = az.updateStatus(a.db)
|
||||
if err != nil {
|
||||
return nil, Wrap(err, "error updating authz status")
|
||||
}
|
||||
return authz.toACME(a.db, a.dir, p)
|
||||
return az.toACME(a.db, a.dir, p)
|
||||
}
|
||||
|
||||
// ValidateChallenge attempts to validate the challenge.
|
||||
|
|
|
@ -195,13 +195,6 @@ func (ba *baseAuthz) clone() *baseAuthz {
|
|||
return &u
|
||||
}
|
||||
|
||||
func (ba *baseAuthz) storeAndReturnError(db nosql.DB, err *Error) error {
|
||||
clone := ba.clone()
|
||||
clone.Error = err
|
||||
clone.save(db, ba)
|
||||
return err
|
||||
}
|
||||
|
||||
func (ba *baseAuthz) parent() authz {
|
||||
return &dnsAuthz{ba}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,6 @@ func TestDirectoryGetLink(t *testing.T) {
|
|||
prov := newProv()
|
||||
provID := URLSafeProvisionerName(prov)
|
||||
|
||||
type newTest struct {
|
||||
actual, expected string
|
||||
}
|
||||
assert.Equals(t, dir.getLink(NewNonceLink, provID, true), fmt.Sprintf("https://ca.smallstep.com/acme/%s/new-nonce", provID))
|
||||
assert.Equals(t, dir.getLink(NewNonceLink, provID, false), fmt.Sprintf("/%s/new-nonce", provID))
|
||||
|
||||
|
|
|
@ -74,7 +74,6 @@ func Test_caHandler_Revoke(t *testing.T) {
|
|||
input string
|
||||
auth Authority
|
||||
tls *tls.ConnectionState
|
||||
err error
|
||||
statusCode int
|
||||
expected []byte
|
||||
}
|
||||
|
|
|
@ -260,13 +260,6 @@ func Test_caHandler_SignSSH(t *testing.T) {
|
|||
})
|
||||
assert.FatalError(t, err)
|
||||
|
||||
type fields struct {
|
||||
Authority Authority
|
||||
}
|
||||
type args struct {
|
||||
w http.ResponseWriter
|
||||
r *http.Request
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
req []byte
|
||||
|
|
|
@ -26,7 +26,6 @@ type Authority struct {
|
|||
intermediateIdentity *x509util.Identity
|
||||
sshCAUserCertSignKey crypto.Signer
|
||||
sshCAHostCertSignKey crypto.Signer
|
||||
validateOnce bool
|
||||
certificates *sync.Map
|
||||
startTime time.Time
|
||||
provisioners *provisioner.Collection
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
type MockAuthDB struct {
|
||||
err error
|
||||
ret1, ret2 interface{}
|
||||
ret1 interface{}
|
||||
init func(*db.Config) (db.AuthDB, error)
|
||||
isRevoked func(string) (bool, error)
|
||||
revoke func(rci *db.RevokedCertificateInfo) error
|
||||
|
|
|
@ -248,10 +248,6 @@ func TestTimeDuration_Unix(t *testing.T) {
|
|||
func TestTimeDuration_String(t *testing.T) {
|
||||
tm, fn := mockNow()
|
||||
defer fn()
|
||||
type fields struct {
|
||||
t time.Time
|
||||
d time.Duration
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
timeDuration *TimeDuration
|
||||
|
|
|
@ -212,7 +212,6 @@ type RevokeOptions struct {
|
|||
MTLS bool
|
||||
Crt *x509.Certificate
|
||||
OTT string
|
||||
errCtxt map[string]interface{}
|
||||
}
|
||||
|
||||
// Revoke revokes a certificate.
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
|
||||
func TestNewACMEClient(t *testing.T) {
|
||||
type test struct {
|
||||
endpoint string
|
||||
ops []ClientOption
|
||||
r1, r2 interface{}
|
||||
rc1, rc2 int
|
||||
|
@ -357,8 +356,6 @@ func TestACMEClient_post(t *testing.T) {
|
|||
|
||||
func TestACMEClient_NewOrder(t *testing.T) {
|
||||
type test struct {
|
||||
payload []byte
|
||||
jwk *jose.JSONWebKey
|
||||
ops []withHeaderOption
|
||||
r1, r2 interface{}
|
||||
rc1, rc2 int
|
||||
|
|
|
@ -570,8 +570,8 @@ func TestBootstrapListener(t *testing.T) {
|
|||
return
|
||||
}
|
||||
wg := new(sync.WaitGroup)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
wg.Add(1)
|
||||
http.Serve(lis, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("ok"))
|
||||
}))
|
||||
|
|
11
ca/ca.go
11
ca/ca.go
|
@ -63,12 +63,11 @@ func WithDatabase(db db.AuthDB) Option {
|
|||
// CA is the type used to build the complete certificate authority. It builds
|
||||
// the HTTP server, set ups the middlewares and the HTTP handlers.
|
||||
type CA struct {
|
||||
auth *authority.Authority
|
||||
acmeAuth *acme.Authority
|
||||
config *authority.Config
|
||||
srv *server.Server
|
||||
opts *options
|
||||
renewer *TLSRenewer
|
||||
auth *authority.Authority
|
||||
config *authority.Config
|
||||
srv *server.Server
|
||||
opts *options
|
||||
renewer *TLSRenewer
|
||||
}
|
||||
|
||||
// New creates and initializes the CA with the given configuration and options.
|
||||
|
|
|
@ -30,9 +30,6 @@ func NewResponseLogger(w http.ResponseWriter) ResponseLogger {
|
|||
|
||||
func wrapLogger(w http.ResponseWriter) (rw ResponseLogger) {
|
||||
rw = &rwDefault{w, 200, 0, nil}
|
||||
if c, ok := w.(http.CloseNotifier); ok {
|
||||
rw = &rwCloseNotifier{rw, c}
|
||||
}
|
||||
if f, ok := w.(http.Flusher); ok {
|
||||
rw = &rwFlusher{rw, f}
|
||||
}
|
||||
|
@ -88,15 +85,6 @@ func (r *rwDefault) WithFields(fields map[string]interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
type rwCloseNotifier struct {
|
||||
ResponseLogger
|
||||
c http.CloseNotifier
|
||||
}
|
||||
|
||||
func (r *rwCloseNotifier) CloseNotify() <-chan bool {
|
||||
return r.CloseNotify()
|
||||
}
|
||||
|
||||
type rwFlusher struct {
|
||||
ResponseLogger
|
||||
f http.Flusher
|
||||
|
|
Loading…
Reference in a new issue