| 47 | } |
| 48 | |
| 49 | func (cmd *tagCommand) Run(args []string) (err error) { |
| 50 | reexec() |
| 51 | |
| 52 | // Get the specified image and target. |
| 53 | cmd.image = args[0] |
| 54 | cmd.target = args[1] |
| 55 | |
| 56 | // Create the context. |
| 57 | id := identity.NewID() |
| 58 | ctx := session.NewContext(context.Background(), id) |
| 59 | ctx = namespaces.WithNamespace(ctx, "buildkit") |
| 60 | |
| 61 | // Create the client. |
| 62 | c, err := client.New(stateDir, backend, nil) |
| 63 | if err != nil { |
| 64 | return err |
| 65 | } |
| 66 | defer c.Close() |
| 67 | |
| 68 | if err := c.TagImage(ctx, cmd.image, cmd.target); err != nil { |
| 69 | return err |
| 70 | } |
| 71 | |
| 72 | fmt.Printf("Successfully tagged %s as %s\n", cmd.image, cmd.target) |
| 73 | |
| 74 | return nil |
| 75 | } |