def do_main(args): """Execute according to subcommands""" # Set up environment if not args.quiet: # set up console logs global logger global console logger.addHandler(console) logger.debug("Starting...") prep.setup(args.working_dir) if args.clear_cache: logger.debug('Clearing cache...') cache.clear() if hasattr(args, 'name'): if args.name == 'lock': run.execute_dockerfile(args) elif args.name == 'report': if args.dockerfile: run.execute_dockerfile(args) elif args.docker_image: # Check if the image string is a tarball if general.check_tar(args.docker_image): logger.critical(errors.incorrect_raw_option) sys.exit(1) # Check if the image string has the right format if not check_image_string(args.docker_image): logger.critical(errors.incorrect_image_string_format) sys.exit(1) # If the checks are OK, execute for docker image run.execute_docker_image(args) # Tear down the environment prep.teardown(args.keep_wd) logger.debug('Finished')
def do_main(args): '''Execute according to subcommands''' # create working directory create_top_dir() if args.log_stream: # set up console logs global logger global console logger.addHandler(console) logger.debug('Starting...') if args.clear_cache: logger.debug('Clearing cache...') cache.clear() if hasattr(args, 'name') and args.name == 'report': if args.dockerfile: run.execute_dockerfile(args) if args.docker_image: if common.check_tar(args.docker_image): logger.error("%s", errors.incorrect_raw_option) else: run.execute_docker_image(args) logger.debug('Report completed.') if args.raw_image: if not common.check_tar(args.raw_image): logger.error("%s", errors.invalid_raw_image.format( image=args.raw_image)) else: run.execute_docker_image(args) logger.debug('Report completed.') logger.debug('Finished')
def do_main(args): '''Execute according to subcommands''' # set bind mount location if working in a container rootfs.set_mount_dir(args.bind_mount, args.working_dir) # create working directory create_top_dir(args.working_dir) if not args.quiet: # set up console logs global logger global console logger.addHandler(console) logger.debug('Starting...') if args.clear_cache: logger.debug('Clearing cache...') cache.clear() if hasattr(args, 'name') and (args.name == 'report' or args.name == 'lock'): if args.name == 'lock': run.execute_dockerfile(args) elif args.dockerfile: run.execute_dockerfile(args) elif args.docker_image: # Check if the image is of image:tag # or image@digest_type:digest format if not check_image_string(args.docker_image): sys.stderr.write('Error running Tern\n' 'Please provide docker image ' 'string in image:tag or ' 'image@digest_type:digest format\n') sys.exit(1) if general.check_tar(args.docker_image): logger.error("%s", errors.incorrect_raw_option) else: run.execute_docker_image(args) logger.debug('Report completed.') if args.name == 'report': if args.raw_image: if not general.check_tar(args.raw_image): logger.error( "%s", errors.invalid_raw_image.format(image=args.raw_image)) else: run.execute_docker_image(args) logger.debug('Report completed.') logger.debug('Finished')