Skip to content

Commit c6f456b

Browse files
committed
cli/command/image: deprecate and internalize TrustedPush
This function was only used by "docker trust sign"; inline the code and deprecate the function. This function has no known external consumers, so we should remove it on the first possible ocassion (which could be a minor release). Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent e558b91 commit c6f456b

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

cli/command/image/trust.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ func newNotaryClient(cli command.Streams, imgRefAndAuth trust.ImageRefAndAuth) (
4444
return trust.GetNotaryRepository(cli.In(), cli.Out(), command.UserAgent(), imgRefAndAuth.RepoInfo(), imgRefAndAuth.AuthConfig(), "pull")
4545
}
4646

47-
// TrustedPush handles content trust pushing of an image
47+
// TrustedPush handles content trust pushing of an image.
48+
//
49+
// Deprecated: this function was only used internally and will be removed in the next release.
4850
func TrustedPush(ctx context.Context, cli command.Cli, repoInfo *registry.RepositoryInfo, ref reference.Named, authConfig registrytypes.AuthConfig, options image.PushOptions) error {
4951
responseBody, err := cli.Client().ImagePush(ctx, reference.FamiliarString(ref), options)
5052
if err != nil {

cli/command/trust/sign.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"sort"
99
"strings"
1010

11+
"github.com/distribution/reference"
1112
"github.com/docker/cli/cli"
1213
"github.com/docker/cli/cli/command"
1314
"github.com/docker/cli/cli/command/image"
@@ -98,10 +99,15 @@ func runSignImage(ctx context.Context, dockerCLI command.Cli, options signOption
9899
if err != nil {
99100
return err
100101
}
101-
return image.TrustedPush(ctx, dockerCLI, imgRefAndAuth.RepoInfo(), imgRefAndAuth.Reference(), *imgRefAndAuth.AuthConfig(), imagetypes.PushOptions{
102+
responseBody, err := dockerCLI.Client().ImagePush(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), imagetypes.PushOptions{
102103
RegistryAuth: encodedAuth,
103104
PrivilegeFunc: requestPrivilege,
104105
})
106+
if err != nil {
107+
return err
108+
}
109+
defer responseBody.Close()
110+
return image.PushTrustedReference(ctx, dockerCLI, imgRefAndAuth.RepoInfo(), imgRefAndAuth.Reference(), authConfig, responseBody)
105111
default:
106112
return err
107113
}

0 commit comments

Comments
 (0)