Skip to content

Commit

Permalink
Do not use trailing punctuation in errors, also no caps where possible
Browse files Browse the repository at this point in the history
Signed-off-by: Riyaz Faizullabhoy <[email protected]>
  • Loading branch information
riyazdf authored and David Lawrence committed Nov 14, 2016
1 parent 3657629 commit 43aaf08
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cmd/notary-server/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func bootstrap(ctx context.Context) error {
}
store, ok := s.(storage.Bootstrapper)
if !ok {
return fmt.Errorf("Store does not support bootstrapping.")
return fmt.Errorf("store does not support bootstrapping")
}
return store.Bootstrap()
}
2 changes: 1 addition & 1 deletion cmd/notary-signer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func getAddrAndTLSConfig(configuration *viper.Viper) (string, *tls.Config, error
func bootstrap(s interface{}) error {
store, ok := s.(storage.Bootstrapper)
if !ok {
return fmt.Errorf("Store does not support bootstrapping.")
return fmt.Errorf("store does not support bootstrapping")
}
return store.Bootstrap()
}
8 changes: 4 additions & 4 deletions cmd/notary/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package main
import (
"fmt"
"io"
"os"
"path/filepath"
"strconv"
"strings"

"github.com/docker/notary"
notaryclient "github.com/docker/notary/client"
"github.com/docker/notary/cryptoservice"
store "github.com/docker/notary/storage"
"github.com/docker/notary/trustmanager"
"github.com/docker/notary/tuf/data"
"github.com/docker/notary/utils"

"github.com/docker/notary"
"github.com/docker/notary/tuf/data"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
)

var cmdKeyTemplate = usageTemplate{
Expand Down Expand Up @@ -264,7 +264,7 @@ func removeKeyInteractively(keyStores []trustmanager.KeyStore, keyID string,
}

if len(foundKeys) == 0 {
return fmt.Errorf("No key with ID %s found.", keyID)
return fmt.Errorf("No key with ID %s found", keyID)
}

if len(foundKeys) > 1 {
Expand Down
2 changes: 1 addition & 1 deletion cryptoservice/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
func GenerateCertificate(rootKey data.PrivateKey, gun string, startTime, endTime time.Time) (*x509.Certificate, error) {
signer := rootKey.CryptoSigner()
if signer == nil {
return nil, fmt.Errorf("key type not supported for Certificate generation: %s\n", rootKey.Algorithm())
return nil, fmt.Errorf("key type not supported for Certificate generation: %s", rootKey.Algorithm())
}

return generateCertificate(signer, gun, startTime, endTime)
Expand Down
4 changes: 2 additions & 2 deletions signer/keydbstore/cachedcryptoservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type unAddableKeyService struct {
}

func (u unAddableKeyService) AddKey(_, _ string, _ data.PrivateKey) error {
return fmt.Errorf("Can't add to keyservice!")
return fmt.Errorf("can't add to keyservice")
}

type unRemoveableKeyService struct {
Expand All @@ -60,7 +60,7 @@ type unRemoveableKeyService struct {

func (u unRemoveableKeyService) RemoveKey(keyID string) error {
if u.failToRemove {
return fmt.Errorf("Can't remove from keystore!")
return fmt.Errorf("can't remove from keystore")
}
return u.CryptoService.RemoveKey(keyID)
}
Expand Down
6 changes: 3 additions & 3 deletions trustmanager/yubikey/yubikeystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (y *YubiPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts
return sig, nil
}
}
return nil, errors.New("Failed to generate signature on Yubikey.")
return nil, errors.New("failed to generate signature on Yubikey")
}

// If a byte array is less than the number of bytes specified by
Expand Down Expand Up @@ -460,7 +460,7 @@ func yubiListKeys(ctx IPKCS11Ctx, session pkcs11.SessionHandle) (keys map[string
}

if len(objs) == 0 {
return nil, errors.New("No keys found in yubikey.")
return nil, errors.New("no keys found in yubikey")
}
logrus.Debugf("Found %d objects matching list filters", len(objs))
for _, obj := range objs {
Expand Down Expand Up @@ -621,7 +621,7 @@ func getNextEmptySlot(ctx IPKCS11Ctx, session pkcs11.SessionHandle) ([]byte, err
return []byte{byte(loc)}, nil
}
}
return nil, errors.New("Yubikey has no available slots.")
return nil, errors.New("yubikey has no available slots")
}

// YubiStore is a KeyStore for private keys inside a Yubikey
Expand Down
2 changes: 1 addition & 1 deletion trustmanager/yubikey/yubikeystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ type nonworkingBackup struct {

// AddKey stores the contents of a PEM-encoded private key as a PEM block
func (s *nonworkingBackup) AddKey(keyInfo trustmanager.KeyInfo, privKey data.PrivateKey) error {
return errors.New("Nope!")
return errors.New("nope")
}

// If, when adding a key to the Yubikey, we can't back up the key, it should
Expand Down
5 changes: 3 additions & 2 deletions trustpinning/trustpin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package trustpinning
import (
"crypto/x509"
"fmt"
"strings"

"github.com/Sirupsen/logrus"
"github.com/docker/notary/tuf/utils"
"strings"
)

// TrustPinConfig represents the configuration under the trust_pinning section of the config file
Expand Down Expand Up @@ -115,7 +116,7 @@ func getPinnedCAFilepathByPrefix(gun string, t TrustPinConfig) (string, error) {
}
}
if !foundCA {
return "", fmt.Errorf("could not find pinned CA for GUN: %s\n", gun)
return "", fmt.Errorf("could not find pinned CA for GUN: %s", gun)
}
return specificCAFilepath, nil
}
8 changes: 4 additions & 4 deletions tuf/data/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func NewECDSAPrivateKey(public PublicKey, private []byte) (*ECDSAPrivateKey, err
switch public.(type) {
case *ECDSAPublicKey, *ECDSAx509PublicKey:
default:
return nil, errors.New("Invalid public key type provided to NewECDSAPrivateKey")
return nil, errors.New("invalid public key type provided to NewECDSAPrivateKey")
}
ecdsaPrivKey, err := x509.ParseECPrivateKey(private)
if err != nil {
Expand All @@ -394,7 +394,7 @@ func NewRSAPrivateKey(public PublicKey, private []byte) (*RSAPrivateKey, error)
switch public.(type) {
case *RSAPublicKey, *RSAx509PublicKey:
default:
return nil, errors.New("Invalid public key type provided to NewRSAPrivateKey")
return nil, errors.New("invalid public key type provided to NewRSAPrivateKey")
}
rsaPrivKey, err := x509.ParsePKCS1PrivateKey(private)
if err != nil {
Expand Down Expand Up @@ -445,7 +445,7 @@ type ecdsaSig struct {
func (k ECDSAPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) {
ecdsaPrivKey, ok := k.CryptoSigner().(*ecdsa.PrivateKey)
if !ok {
return nil, errors.New("Signer was based on the wrong key type")
return nil, errors.New("signer was based on the wrong key type")
}
hashed := sha256.Sum256(msg)
sigASN1, err := ecdsaPrivKey.Sign(rand, hashed[:], opts)
Expand Down Expand Up @@ -492,7 +492,7 @@ func (k ED25519PrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOp
// Sign on an UnknownPrivateKey raises an error because the client does not
// know how to sign with this key type.
func (k UnknownPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) (signature []byte, err error) {
return nil, errors.New("Unknown key type, cannot sign.")
return nil, errors.New("unknown key type, cannot sign")
}

// SignatureAlgorithm returns the SigAlgorithm for a ECDSAPrivateKey
Expand Down
4 changes: 2 additions & 2 deletions tuf/signed/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ func VerifySignature(msg []byte, sig *data.Signature, pk data.PublicKey) error {
method := sig.Method
verifier, ok := Verifiers[method]
if !ok {
return fmt.Errorf("signing method is not supported: %s\n", sig.Method)
return fmt.Errorf("signing method is not supported: %s", sig.Method)
}

if err := verifier.Verify(pk, sig.Signature, msg); err != nil {
return fmt.Errorf("signature was invalid\n")
return fmt.Errorf("signature was invalid")
}
sig.IsValid = true
return nil
Expand Down

0 comments on commit 43aaf08

Please sign in to comment.