diff --git a/cmd/notary/keys.go b/cmd/notary/keys.go index e78d1a992..0625f3e19 100644 --- a/cmd/notary/keys.go +++ b/cmd/notary/keys.go @@ -21,7 +21,6 @@ import ( "github.com/docker/notary/trustmanager" "github.com/docker/notary/tuf/data" tufutils "github.com/docker/notary/tuf/utils" - "github.com/docker/notary/utils" ) var cmdKeyTemplate = usageTemplate{ @@ -524,7 +523,7 @@ func (k *keyCommander) importKeys(cmd *cobra.Command, args []string) error { return err } defer from.Close() - if err = utils.ImportKeys(from, importers, k.importRole, k.keysImportGUN, k.getRetriever()); err != nil { + if err = trustmanager.ImportKeys(from, importers, k.importRole, k.keysImportGUN, k.getRetriever()); err != nil { return err } } @@ -566,15 +565,15 @@ func (k *keyCommander) exportKeys(cmd *cobra.Command, args []string) error { return fmt.Errorf("Only the --gun or --key flag may be provided, not a mix of the two flags") } for _, gun := range k.exportGUNs { - return utils.ExportKeysByGUN(out, fileStore, gun) + return trustmanager.ExportKeysByGUN(out, fileStore, gun) } } else if len(k.exportKeyIDs) > 0 { - return utils.ExportKeysByID(out, fileStore, k.exportKeyIDs) + return trustmanager.ExportKeysByID(out, fileStore, k.exportKeyIDs) } // export everything keys := fileStore.ListFiles() for _, k := range keys { - err := utils.ExportKeys(out, fileStore, k) + err := trustmanager.ExportKeys(out, fileStore, k) if err != nil { return err } diff --git a/cmd/notary/keys_nonpkcs11.go b/cmd/notary/keys_nonpkcs11.go index eaa1e6411..cba9e4bd7 100644 --- a/cmd/notary/keys_nonpkcs11.go +++ b/cmd/notary/keys_nonpkcs11.go @@ -8,17 +8,16 @@ import ( "github.com/docker/notary" store "github.com/docker/notary/storage" "github.com/docker/notary/trustmanager" - "github.com/docker/notary/utils" ) func getYubiStore(fileKeyStore trustmanager.KeyStore, ret notary.PassRetriever) (trustmanager.KeyStore, error) { return nil, errors.New("Not built with hardware support") } -func getImporters(baseDir string, _ notary.PassRetriever) ([]utils.Importer, error) { +func getImporters(baseDir string, _ notary.PassRetriever) ([]trustmanager.Importer, error) { fileStore, err := store.NewPrivateKeyFileStorage(baseDir, notary.KeyExtension) if err != nil { return nil, err } - return []utils.Importer{fileStore}, nil + return []trustmanager.Importer{fileStore}, nil } diff --git a/cmd/notary/keys_pkcs11.go b/cmd/notary/keys_pkcs11.go index b47234558..b8545153b 100644 --- a/cmd/notary/keys_pkcs11.go +++ b/cmd/notary/keys_pkcs11.go @@ -7,16 +7,15 @@ import ( store "github.com/docker/notary/storage" "github.com/docker/notary/trustmanager" "github.com/docker/notary/trustmanager/yubikey" - "github.com/docker/notary/utils" ) func getYubiStore(fileKeyStore trustmanager.KeyStore, ret notary.PassRetriever) (*yubikey.YubiStore, error) { return yubikey.NewYubiStore(fileKeyStore, ret) } -func getImporters(baseDir string, ret notary.PassRetriever) ([]utils.Importer, error) { +func getImporters(baseDir string, ret notary.PassRetriever) ([]trustmanager.Importer, error) { - var importers []utils.Importer + var importers []trustmanager.Importer if yubikey.IsAccessible() { yubiStore, err := getYubiStore(nil, ret) if err == nil { diff --git a/utils/importLogic.md b/trustmanager/importLogic.md similarity index 100% rename from utils/importLogic.md rename to trustmanager/importLogic.md diff --git a/utils/keys.go b/trustmanager/keys.go similarity index 99% rename from utils/keys.go rename to trustmanager/keys.go index fc20f342f..e90e4c9a3 100644 --- a/utils/keys.go +++ b/trustmanager/keys.go @@ -1,4 +1,4 @@ -package utils +package trustmanager import ( "encoding/pem" diff --git a/utils/keys_test.go b/trustmanager/keys_test.go similarity index 97% rename from utils/keys_test.go rename to trustmanager/keys_test.go index ee9579e2a..585afdc9d 100644 --- a/utils/keys_test.go +++ b/trustmanager/keys_test.go @@ -1,4 +1,4 @@ -package utils +package trustmanager import ( "bytes" @@ -16,16 +16,6 @@ import ( "github.com/stretchr/testify/require" ) -const cannedPassphrase = "passphrase" - -var passphraseRetriever = func(keyID string, alias string, createNew bool, numAttempts int) (string, bool, error) { - if numAttempts > 5 { - giveup := true - return "", giveup, errors.New("passPhraseRetriever failed after too many requests") - } - return cannedPassphrase, false, nil -} - type TestImportStore struct { data map[string][]byte }