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,9 +43,11 @@ 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
@@ -69,37 +63,21 @@ func buildPullConfig(ctx context.Context, dockerCli command.Cli, opts pluginOpti
6963 repoInfo := registry .ParseRepositoryInfo (ref )
7064 remote := ref .String ()
7165
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-
8766 authConfig := command .ResolveAuthConfig (dockerCli .ConfigFile (), repoInfo .Index )
8867 encodedAuth , err := registrytypes .EncodeAuthConfig (authConfig )
8968 if err != nil {
9069 return client.PluginInstallOptions {}, err
9170 }
9271
93- options := client.PluginInstallOptions {
72+ return client.PluginInstallOptions {
9473 RegistryAuth : encodedAuth ,
9574 RemoteRef : remote ,
9675 Disabled : opts .disable ,
9776 AcceptAllPermissions : opts .grantPerms ,
9877 AcceptPermissionsFunc : acceptPrivileges (dockerCli , opts .remote ),
9978 PrivilegeFunc : nil ,
10079 Args : opts .args ,
101- }
102- return options , nil
80+ }, nil
10381}
10482
10583func runInstall (ctx context.Context , dockerCLI command.Cli , opts pluginOptions ) error {
0 commit comments