@@ -92,9 +92,11 @@ To push the complete multi-platform image, remove the --platform flag.
9292 }
9393
9494 ref , err := reference .ParseNormalizedNamed (opts .remote )
95- switch {
96- case err != nil :
95+ if err != nil {
9796 return err
97+ }
98+
99+ switch {
98100 case opts .all && ! reference .IsNameOnly (ref ):
99101 return errors .New ("tag can't be used with --all-tags/-a" )
100102 case ! opts .all && reference .IsNameOnly (ref ):
@@ -113,34 +115,32 @@ To push the complete multi-platform image, remove the --platform flag.
113115 if err != nil {
114116 return err
115117 }
116- options := image.PushOptions {
118+
119+ responseBody , err := dockerCli .Client ().ImagePush (ctx , reference .FamiliarString (ref ), image.PushOptions {
117120 All : opts .all ,
118121 RegistryAuth : encodedAuth ,
119122 PrivilegeFunc : nil ,
120123 Platform : platform ,
121- }
122-
123- responseBody , err := dockerCli .Client ().ImagePush (ctx , reference .FamiliarString (ref ), options )
124+ })
124125 if err != nil {
125126 return err
126127 }
127128
128129 defer func () {
130+ _ = responseBody .Close ()
129131 for _ , note := range notes {
130132 out .PrintNote (note )
131133 }
132134 }()
133135
134- defer responseBody .Close ()
135136 if ! opts .untrusted {
136- // TODO pushTrustedReference currently doesn't respect `--quiet`
137137 return pushTrustedReference (ctx , dockerCli , indexInfo , ref , authConfig , responseBody )
138138 }
139139
140140 if opts .quiet {
141141 err = jsonstream .Display (ctx , responseBody , streams .NewOut (io .Discard ), jsonstream .WithAuxCallback (handleAux ()))
142142 if err == nil {
143- fmt .Fprintln (dockerCli .Out (), ref .String ())
143+ _ , _ = fmt .Fprintln (dockerCli .Out (), ref .String ())
144144 }
145145 return err
146146 }
0 commit comments