Skip to content

Commit

Permalink
Merge pull request #1179 from riyazdf/import-key-warning
Browse files Browse the repository at this point in the history
Bump up default log level, key import/export logs
  • Loading branch information
riyazdf authored Jun 8, 2017
2 parents 7d3a3c3 + c13f5e0 commit 7c74907
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd/notary/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1725,12 +1725,12 @@ func TestLogLevelFlags(t *testing.T) {
// Test default to fatal
n := notaryCommander{}
n.setVerbosityLevel()
require.Equal(t, "fatal", logrus.GetLevel().String())
require.Equal(t, "warning", logrus.GetLevel().String())

// Test that verbose (-v) sets to error
n.verbose = true
n.setVerbosityLevel()
require.Equal(t, "error", logrus.GetLevel().String())
require.Equal(t, "info", logrus.GetLevel().String())

// Test that debug (-D) sets to debug
n.debug = true
Expand Down
6 changes: 3 additions & 3 deletions cmd/notary/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ func getPassphraseRetriever() notary.PassRetriever {
}
}

// Set the logging level to fatal on default, or the most specific level the user specified (debug or error)
// Set the logging level to warn on default, or the most verbose level the user specified (debug, info)
func (n *notaryCommander) setVerbosityLevel() {
if n.debug {
logrus.SetLevel(logrus.DebugLevel)
} else if n.verbose {
logrus.SetLevel(logrus.ErrorLevel)
logrus.SetLevel(logrus.InfoLevel)
} else {
logrus.SetLevel(logrus.FatalLevel)
logrus.SetLevel(logrus.WarnLevel)
}
logrus.SetOutput(os.Stderr)
}
6 changes: 3 additions & 3 deletions utils/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ExportKeysByGUN(to io.Writer, s Exporter, gun string) error {
for _, loc := range keys {
keyFile, err := s.Get(loc)
if err != nil {
logrus.Info("Could not parse key file at ", loc)
logrus.Warn("Could not parse key file at ", loc)
continue
}
block, _ := pem.Decode(keyFile)
Expand Down Expand Up @@ -203,7 +203,7 @@ func checkValidity(block *pem.Block) (string, error) {
case tufdata.CanonicalSnapshotRole.String(), tufdata.CanonicalTargetsRole.String(), tufdata.CanonicalTimestampRole.String():
// check if the key is missing a gun header or has an empty gun and error out since we don't know what gun it belongs to
if block.Headers["gun"] == "" {
logrus.Infof("failed to import key (%s) to store: Cannot have canonical role key without a gun, don't know what gun it belongs to", block.Headers["path"])
logrus.Warnf("failed to import key (%s) to store: Cannot have canonical role key without a gun, don't know what gun it belongs to", block.Headers["path"])
return "", errors.New("invalid key pem block")
}
default:
Expand All @@ -219,7 +219,7 @@ func checkValidity(block *pem.Block) (string, error) {

decodedKey, err := utils.ParsePEMPrivateKey(pem.EncodeToMemory(block), "")
if err != nil {
logrus.Info("failed to import key to store: Invalid key generated, key may be encrypted and does not contain path header")
logrus.Warn("failed to import key to store: Invalid key generated, key may be encrypted and does not contain path header")
return "", errors.New("invalid key pem block")
}
loc = decodedKey.ID()
Expand Down

0 comments on commit 7c74907

Please sign in to comment.