88 "github.com/distribution/reference"
99 "github.com/docker/cli/cli"
1010 "github.com/docker/cli/cli/command"
11- "github.com/docker/cli/cli/command/image"
1211 "github.com/docker/cli/internal/jsonstream"
1312 "github.com/docker/cli/internal/prompt"
1413 "github.com/docker/cli/internal/registry"
@@ -17,7 +16,6 @@ import (
1716 "github.com/moby/moby/client"
1817 "github.com/pkg/errors"
1918 "github.com/spf13/cobra"
20- "github.com/spf13/pflag"
2119)
2220
2321type pluginOptions struct {
@@ -27,12 +25,6 @@ type pluginOptions struct {
2725 disable bool
2826 args []string
2927 skipRemoteCheck bool
30- untrusted bool
31- }
32-
33- func loadPullFlags (dockerCli command.Cli , opts * pluginOptions , flags * pflag.FlagSet ) {
34- flags .BoolVar (& opts .grantPerms , "grant-all-permissions" , false , "Grant all permissions necessary to run the plugin" )
35- command .AddTrustVerificationFlags (flags , & opts .untrusted , dockerCli .ContentTrustEnabled ())
3628}
3729
3830func newInstallCommand (dockerCli command.Cli ) * cobra.Command {
@@ -51,13 +43,15 @@ func newInstallCommand(dockerCli command.Cli) *cobra.Command {
5143 }
5244
5345 flags := cmd .Flags ()
54- loadPullFlags ( dockerCli , & options , flags )
46+ flags . BoolVar ( & options . grantPerms , "grant-all-permissions" , false , "Grant all permissions necessary to run the plugin" )
5547 flags .BoolVar (& options .disable , "disable" , false , "Do not enable the plugin on install" )
5648 flags .StringVar (& options .localName , "alias" , "" , "Local name for plugin" )
49+ flags .Bool ("disable-content-trust" , dockerCli .ContentTrustEnabled (), "Skip image verification (deprecated)" )
50+ _ = flags .MarkHidden ("disable-content-trust" )
5751 return cmd
5852}
5953
60- func buildPullConfig (ctx context. Context , dockerCli command.Cli , opts pluginOptions ) (client.PluginInstallOptions , error ) {
54+ func buildPullConfig (dockerCLI command.Cli , opts pluginOptions ) (client.PluginInstallOptions , error ) {
6155 // Names with both tag and digest will be treated by the daemon
6256 // as a pull by digest with a local name for the tag
6357 // (if no local name is provided).
@@ -66,40 +60,21 @@ func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOpti
6660 return client.PluginInstallOptions {}, err
6761 }
6862
69- indexInfo := registry .NewIndexInfo (ref )
70- remote := ref .String ()
71-
72- _ , isCanonical := ref .(reference.Canonical )
73- if ! opts .untrusted && ! isCanonical {
74- ref = reference .TagNameOnly (ref )
75- nt , ok := ref .(reference.NamedTagged )
76- if ! ok {
77- return client.PluginInstallOptions {}, errors .Errorf ("invalid name: %s" , ref .String ())
78- }
79-
80- trusted , err := image .TrustedReference (ctx , dockerCli , nt )
81- if err != nil {
82- return client.PluginInstallOptions {}, err
83- }
84- remote = reference .FamiliarString (trusted )
85- }
86-
87- authConfig := command .ResolveAuthConfig (dockerCli .ConfigFile (), indexInfo )
63+ authConfig := command .ResolveAuthConfig (dockerCLI .ConfigFile (), registry .NewIndexInfo (ref ))
8864 encodedAuth , err := registrytypes .EncodeAuthConfig (authConfig )
8965 if err != nil {
9066 return client.PluginInstallOptions {}, err
9167 }
9268
93- options := client.PluginInstallOptions {
69+ return client.PluginInstallOptions {
9470 RegistryAuth : encodedAuth ,
95- RemoteRef : remote ,
71+ RemoteRef : ref . String () ,
9672 Disabled : opts .disable ,
9773 AcceptAllPermissions : opts .grantPerms ,
98- AcceptPermissionsFunc : acceptPrivileges (dockerCli , opts .remote ),
74+ AcceptPermissionsFunc : acceptPrivileges (dockerCLI , opts .remote ),
9975 PrivilegeFunc : nil ,
10076 Args : opts .args ,
101- }
102- return options , nil
77+ }, nil
10378}
10479
10580func runInstall (ctx context.Context , dockerCLI command.Cli , opts pluginOptions ) error {
@@ -115,7 +90,7 @@ func runInstall(ctx context.Context, dockerCLI command.Cli, opts pluginOptions)
11590 localName = reference .FamiliarString (reference .TagNameOnly (aref ))
11691 }
11792
118- options , err := buildPullConfig (ctx , dockerCLI , opts )
93+ options , err := buildPullConfig (dockerCLI , opts )
11994 if err != nil {
12095 return err
12196 }
0 commit comments