revendor notary for updated import/export packages, update with rebase

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
Upstream-commit: b4ef2ddb8b
Component: cli
This commit is contained in:
Riyaz Faizullabhoy
2017-10-30 16:55:59 +01:00
parent aeaef10882
commit 80651d6c61
108 changed files with 128 additions and 17203 deletions
+4 -4
View File
@@ -11,8 +11,8 @@ import (
"github.com/docker/cli/cli/trust"
"github.com/docker/notary"
"github.com/docker/notary/storage"
"github.com/docker/notary/trustmanager"
tufutils "github.com/docker/notary/tuf/utils"
"github.com/docker/notary/utils"
"github.com/spf13/cobra"
)
@@ -46,7 +46,7 @@ func loadPrivKey(streams command.Streams, keyPath string, options keyLoadOptions
if err != nil {
return err
}
privKeyImporters := []utils.Importer{keyFileStore}
privKeyImporters := []trustmanager.Importer{keyFileStore}
fmt.Fprintf(streams.Out(), "\nLoading key from \"%s\"...\n", keyPath)
@@ -85,10 +85,10 @@ func getPrivKeyBytesFromPath(keyPath string) ([]byte, error) {
return keyBytes, nil
}
func loadPrivKeyBytesToStore(privKeyBytes []byte, privKeyImporters []utils.Importer, keyPath, keyName string, passRet notary.PassRetriever) error {
func loadPrivKeyBytesToStore(privKeyBytes []byte, privKeyImporters []trustmanager.Importer, keyPath, keyName string, passRet notary.PassRetriever) error {
if _, _, err := tufutils.ExtractPrivateKeyAttributes(privKeyBytes); err != nil {
return fmt.Errorf("provided file %s is not a supported private key - to add a signer's public key use docker trust signer add", keyPath)
}
// Make a reader, rewind the file pointer
return utils.ImportKeys(bytes.NewReader(privKeyBytes), privKeyImporters, keyName, "", passRet)
return trustmanager.ImportKeys(bytes.NewReader(privKeyBytes), privKeyImporters, keyName, "", passRet)
}
@@ -14,8 +14,8 @@ import (
"github.com/docker/notary"
"github.com/docker/notary/passphrase"
"github.com/docker/notary/storage"
"github.com/docker/notary/trustmanager"
tufutils "github.com/docker/notary/tuf/utils"
"github.com/docker/notary/utils"
"github.com/stretchr/testify/assert"
)
@@ -125,7 +125,7 @@ func testLoadKeyFromPath(t *testing.T, privKeyID string, privKeyFixture []byte)
cannedPasswordRetriever := passphrase.ConstantRetriever(passwd)
keyFileStore, err := storage.NewPrivateKeyFileStorage(keyStorageDir, notary.KeyExtension)
assert.NoError(t, err)
privKeyImporters := []utils.Importer{keyFileStore}
privKeyImporters := []trustmanager.Importer{keyFileStore}
// get the privKeyBytes
privKeyBytes, err := getPrivKeyBytesFromPath(privKeyFilepath)
@@ -226,7 +226,7 @@ func TestLoadPubKeyFailure(t *testing.T) {
cannedPasswordRetriever := passphrase.ConstantRetriever(passwd)
keyFileStore, err := storage.NewPrivateKeyFileStorage(keyStorageDir, notary.KeyExtension)
assert.NoError(t, err)
privKeyImporters := []utils.Importer{keyFileStore}
privKeyImporters := []trustmanager.Importer{keyFileStore}
pubKeyBytes, err := getPrivKeyBytesFromPath(pubKeyFilepath)
assert.NoError(t, err)
@@ -11,10 +11,9 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/image"
"github.com/docker/cli/cli/trust"
"github.com/docker/cli/opts"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/notary/client"
"github.com/docker/notary/tuf/data"
tufutils "github.com/docker/notary/tuf/utils"
@@ -80,15 +79,12 @@ func addSignerToImage(cli command.Cli, signerName string, imageName string, keyP
fmt.Fprintf(cli.Out(), "\nAdding signer \"%s\" to %s...\n", signerName, imageName)
ctx := context.Background()
authResolver := func(ctx context.Context, index *registrytypes.IndexInfo) types.AuthConfig {
return command.ResolveAuthConfig(ctx, cli, index)
}
imgRefAndAuth, err := trust.GetImageReferencesAndAuth(ctx, authResolver, imageName)
imgRefAndAuth, err := trust.GetImageReferencesAndAuth(ctx, image.AuthResolver(cli), imageName)
if err != nil {
return err
}
notaryRepo, err := cli.NotaryClient(*imgRefAndAuth, trust.ActionsPushAndPull)
notaryRepo, err := cli.NotaryClient(imgRefAndAuth, trust.ActionsPushAndPull)
if err != nil {
return trust.NotaryError(imgRefAndAuth.Reference().Name(), err)
}
@@ -8,9 +8,8 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/image"
"github.com/docker/cli/cli/trust"
"github.com/docker/docker/api/types"
registrytypes "github.com/docker/docker/api/types/registry"
"github.com/docker/notary/client"
"github.com/docker/notary/tuf/data"
"github.com/spf13/cobra"
@@ -75,14 +74,11 @@ func isLastSignerForReleases(roleWithSig data.Role, allRoles []client.RoleWithSi
return counter < releasesRoleWithSigs.Threshold, nil
}
func removeSingleSigner(cli command.Cli, image, signerName string, forceYes bool) error {
fmt.Fprintf(cli.Out(), "\nRemoving signer \"%s\" from %s...\n", signerName, image)
func removeSingleSigner(cli command.Cli, imageName, signerName string, forceYes bool) error {
fmt.Fprintf(cli.Out(), "\nRemoving signer \"%s\" from %s...\n", signerName, imageName)
ctx := context.Background()
authResolver := func(ctx context.Context, index *registrytypes.IndexInfo) types.AuthConfig {
return command.ResolveAuthConfig(ctx, cli, index)
}
imgRefAndAuth, err := trust.GetImageReferencesAndAuth(ctx, authResolver, image)
imgRefAndAuth, err := trust.GetImageReferencesAndAuth(ctx, image.AuthResolver(cli), imageName)
if err != nil {
return err
}
@@ -91,13 +87,13 @@ func removeSingleSigner(cli command.Cli, image, signerName string, forceYes bool
if signerDelegation == releasesRoleTUFName {
return fmt.Errorf("releases is a reserved keyword and cannot be removed")
}
notaryRepo, err := cli.NotaryClient(*imgRefAndAuth, trust.ActionsPushAndPull)
notaryRepo, err := cli.NotaryClient(imgRefAndAuth, trust.ActionsPushAndPull)
if err != nil {
return trust.NotaryError(imgRefAndAuth.Reference().Name(), err)
}
delegationRoles, err := notaryRepo.GetDelegationRoles()
if err != nil {
return fmt.Errorf("Error retrieving signers for %s", image)
return fmt.Errorf("Error retrieving signers for %s", imageName)
}
var role data.Role
for _, delRole := range delegationRoles {
@@ -107,7 +103,7 @@ func removeSingleSigner(cli command.Cli, image, signerName string, forceYes bool
}
}
if role.Name == "" {
return fmt.Errorf("No signer %s for image %s", signerName, image)
return fmt.Errorf("No signer %s for image %s", signerName, imageName)
}
allRoles, err := notaryRepo.ListRoles()
if err != nil {
@@ -117,7 +113,7 @@ func removeSingleSigner(cli command.Cli, image, signerName string, forceYes bool
removeSigner := command.PromptForConfirmation(os.Stdin, cli.Out(), fmt.Sprintf("The signer \"%s\" signed the last released version of %s. "+
"Removing this signer will make %s unpullable. "+
"Are you sure you want to continue?",
signerName, image, image,
signerName, imageName, imageName,
))
if !removeSigner {
@@ -136,6 +132,6 @@ func removeSingleSigner(cli command.Cli, image, signerName string, forceYes bool
if err = notaryRepo.Publish(); err != nil {
return err
}
fmt.Fprintf(cli.Out(), "Successfully removed %s from %s\n", signerName, image)
fmt.Fprintf(cli.Out(), "Successfully removed %s from %s\n", signerName, imageName)
return nil
}