Commit 23507b05 authored by Sebastien Luttringer's avatar Sebastien Luttringer
Browse files

add -f to copy and better copying plan confirmation

parent 1d2c507b
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -216,11 +216,20 @@ def c_copy(args):
    '''
    repoman = load_repositories(args)
    dstrepo = repoman[args.repository]
    for srcimg, srcrepo in get_images(args.pattern, repoman, local=False, min=1):
        arrow("Copying %s v%s from repository %s to %s" % (srcimg.name,
                                                           srcimg.version,
                                                           srcrepo.config.name,
                                                           dstrepo.config.name))
    todo = list(get_images(args.pattern, repoman, local=False, min=1))
    # check user really want to this
    if not args.force:
        out("You will copy the following images:")
        for img, repo in todo:
            out("  %s/%s:%s" % (repo.config.name, img.name, img.version))
        out("Inside repository: #l##b#%s#R#" % dstrepo.config.name)
        if not confirm():
            raise Exception("Aborted!")
    # copy it for real
    for srcimg, srcrepo in todo:
        arrow("Copying %s v%s from repository %s to %s" %
              (srcimg.name, srcimg.version,
               srcrepo.config.name, dstrepo.config.name))
        arrowlevel(1)
        dstrepo.add(srcimg)
        arrowlevel(-1)
@@ -509,6 +518,8 @@ def arg_parser_init():
    p.set_defaults(func=c_clean)
    # copy command parser
    p = subparser.add_parser("copy", help=c_copy.__doc__.lower())
    p.add_argument("-f", "--force", action="store_true",
                   help="copy image without confirmation")
    p.add_argument("pattern", nargs="+",
                   help="[repository/]image[:version]")
    p.add_argument("repository", help="destination repository")
+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ _is() {
         _local_repo
      ;;
      copy)
         [[ "$cur" == -* ]] && _opt '-h --help' && return 0
         [[ "$cur" == -* ]] && _opt '-h --help -f --force' && return 0
         _count_args
         (( args == 2 )) && _remote_image
         (( args > 2 )) && _remote_image && _local_repo