@@ -13,12 +13,16 @@ import (
1313)
1414
1515var tagCmd = cli.Command {
16- Name : "tag" ,
17- Usage : "Create a local image tag" ,
18- ArgsUsage : "<source> <target>" ,
19- Description : `Create a local image tag in Hypeman. If the source is not already
20- cached in Hypeman, fall back to the matching image in the local Docker daemon.` ,
21- Action : handleTag ,
16+ Name : "tag" ,
17+ Usage : "Create a local image tag" ,
18+ ArgsUsage : "<source> <target>" ,
19+ Description : "Create a local image tag in Hypeman without pulling or converting the image." ,
20+ Action : handleTag ,
21+ HideHelpCommand : true ,
22+ }
23+
24+ type tagImageRequest struct {
25+ Target string `json:"target"`
2226}
2327
2428func handleTag (ctx context.Context , cmd * cli.Command ) error {
@@ -37,17 +41,18 @@ func handleTag(ctx context.Context, cmd *cli.Command) error {
3741
3842 var res []byte
3943 opts = append (opts , option .WithResponseBodyInto (& res ))
40- body := struct {
41- Target string `json:"target"`
42- }{Target : target }
4344 path := "/images/" + url .PathEscape (source ) + "/tag"
44- if err := client .Post (ctx , path , body , nil , opts ... ); err != nil {
45+ if err := client .Post (ctx , path , tagImageRequest { Target : target } , nil , opts ... ); err != nil {
4546 if ! isNotFoundError (err ) {
4647 return err
4748 }
49+
50+ // Keep the Docker fallback for sources that have not been imported into
51+ // Hypeman yet. Once staged, the image is available under the requested
52+ // target and can be pushed through the normal cached-image flow.
4853 staged , stageErr := stageDockerImage (ctx , cmd , & client , source , target )
4954 if stageErr != nil {
50- return fmt .Errorf ("image %q was not found in Hypeman or Docker: %w" , source , stageErr )
55+ return fmt .Errorf ("image %q was not found in Hypeman; stage it from Docker: %w" , source , stageErr )
5156 }
5257 res = []byte (staged .RawJSON ())
5358 }
0 commit comments