@@ -25,31 +25,37 @@ var pushCmd = cli.Command{
2525 ArgsUsage : "IMAGE [TARGET]" ,
2626 Description : `Push images between Docker, Hypeman, and remote registries.
2727
28- hypeman push IMAGE
29- Upload IMAGE from the local Docker daemon into Hypeman.
28+ hypeman push TARGET
29+ Push TARGET to its remote registry. If TARGET exists in local Docker,
30+ stage it in Hypeman first.
3031
3132 hypeman push IMAGE TARGET
3233 Push an image already in Hypeman to TARGET. Waits for completion.
3334
34- hypeman push --detach IMAGE TARGET
35+ hypeman push --detach TARGET
3536 Queue a remote push and return its ID.
3637
37- Use "hypeman push local IMAGE [TARGET]" to make the local-upload flow explicit.
38- The --detach flag applies to remote pushes, not local uploads.
38+ Use "hypeman push local IMAGE [TARGET]" for Docker-daemon uploads that should
39+ only go to Hypeman. The --detach flag applies to remote pushes, not local
40+ uploads.
3941
4042Push jobs can be inspected while they run:
4143 hypeman push ls
4244 hypeman push inspect <id>
4345
4446Examples:
45- # Push a cached image to ECR
47+ # Push a local Docker tag to ECR
48+ docker tag alpine:latest 123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:v1
49+ hypeman push 123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:v1
50+
51+ # Push a cached Hypeman image to ECR
4652 hypeman push alpine:latest 123456789.dkr.ecr.us-east-1.amazonaws.com/myapp:v1
4753
4854 # Push with credentials read from stdin
49- echo "$ECR_PASSWORD" | hypeman push alpine:latest registry.example.com/app:v1 \
55+ echo "$ECR_PASSWORD" | hypeman push registry.example.com/app:v1 \
5056 --username AWS --password-stdin
5157
52- # Upload a local Docker image into Hypeman
58+ # Upload a local Docker image into Hypeman only
5359 hypeman push local nginx:latest` ,
5460 Flags : pushRemoteFlags (),
5561 Commands : []* cli.Command {& pushLocalCmd , & pushCreateCmd , & pushListCmd , & pushGetCmd },
@@ -69,12 +75,11 @@ func handlePush(ctx context.Context, cmd *cli.Command) error {
6975 args := cmd .Args ().Slice ()
7076 switch len (args ) {
7177 case 1 :
72- // Keep the old one-argument form working for existing scripts.
73- return handleLocalPush (ctx , cmd )
78+ return handleRemotePushTarget (ctx , cmd , args [0 ])
7479 case 2 :
7580 return runRemotePush (ctx , cmd , args [0 ], args [1 ])
7681 default :
77- return fmt .Errorf ("image reference required\n Usage: hypeman push <image> [ target] " )
82+ return fmt .Errorf ("image reference required\n Usage: hypeman push <target> or hypeman push < image> < target> " )
7883 }
7984}
8085
@@ -90,6 +95,10 @@ func handleLocalPush(ctx context.Context, cmd *cli.Command) error {
9095 targetName = args [1 ]
9196 }
9297
98+ return pushLocalImage (ctx , cmd , sourceImage , targetName , nil )
99+ }
100+
101+ func pushLocalImage (ctx context.Context , cmd * cli.Command , sourceImage , targetName string , img v1.Image ) error {
93102 baseURL := resolveBaseURL (cmd )
94103
95104 parsedURL , err := url .Parse (baseURL )
@@ -123,10 +132,12 @@ func handleLocalPush(ctx context.Context, cmd *cli.Command) error {
123132 return fmt .Errorf ("invalid target: %w" , err )
124133 }
125134
126- fmt .Fprintf (os .Stderr , "Loading image %s from Docker...\n " , sourceImage )
127- img , err := daemon .Image (srcRef )
128- if err != nil {
129- return fmt .Errorf ("load image: %w" , err )
135+ if img == nil {
136+ fmt .Fprintf (os .Stderr , "Loading image %s from Docker...\n " , sourceImage )
137+ img , err = daemon .Image (srcRef )
138+ if err != nil {
139+ return fmt .Errorf ("load image: %w" , err )
140+ }
130141 }
131142
132143 fmt .Fprintf (os .Stderr , "The push refers to repository [%s]\n " , dstRef .Context ().Name ())
0 commit comments