func (cli *DogestryCli) CmdPull(args ...string) error { cmd := cli.Subcmd("push", "REMOTE IMAGE[:TAG]", "pull IMAGE from the REMOTE and load it into docker. TAG defaults to 'latest'") if err := cmd.Parse(args); err != nil { return nil } if len(cmd.Args()) < 2 { return fmt.Errorf("Error: REMOTE and IMAGE not specified") } remoteDef := cmd.Arg(0) image := cmd.Arg(1) imageRoot, err := cli.WorkDir(image) if err != nil { return err } r, err := remote.NewRemote(remoteDef, cli.Config) if err != nil { return err } fmt.Println("remote", r.Desc()) fmt.Println("resolving image id") id, err := r.ResolveImageNameToId(image) if err != nil { return err } fmt.Printf("image '%s' resolved on remote id '%s'\n", image, id.Short()) fmt.Println("preparing images") if err := cli.preparePullImage(id, imageRoot, r); err != nil { return err } fmt.Println("preparing repositories file") if err := prepareRepositories(image, imageRoot, r); err != nil { return err } fmt.Println("sending tar to docker") if err := cli.sendTar(imageRoot); err != nil { return err } return nil }
func (cli *DogestryCli) CmdRemote(args ...string) error { cmd := cli.Subcmd("remote", "REMOTE", "describes a remote") if err := cmd.Parse(args); err != nil { return nil } if len(cmd.Args()) < 1 { return fmt.Errorf("Error: REMOTE not specified") } remoteDef := cmd.Arg(0) r, err := remote.NewRemote(remoteDef, cli.Config) if err != nil { return err } fmt.Println("remote: ", r.Desc()) return nil }
func (cli *DogestryCli) CmdPush(args ...string) error { cmd := cli.Subcmd("push", "REMOTE IMAGE[:TAG]", "push IMAGE to the REMOTE. TAG defaults to 'latest'") if err := cmd.Parse(args); err != nil { return nil } if len(cmd.Args()) < 2 { return fmt.Errorf("Error: IMAGE and REMOTE not specified") } remoteDef := cmd.Arg(0) image := cmd.Arg(1) imageRoot, err := cli.WorkDir(image) if err != nil { return err } remote, err := remote.NewRemote(remoteDef, cli.Config) if err != nil { return err } fmt.Println("remote", remote.Desc()) fmt.Println("preparing image") if err := cli.prepareImage(image, imageRoot); err != nil { return err } fmt.Println("pushing image to remote") if err := remote.Push(image, imageRoot); err != nil { return err } return nil }