def setup(dockerfile=None): '''Any initial setup''' # load the cache cache.load() # load dockerfile if present if dockerfile: docker.load_docker_commands(dockerfile)
def setup(dockerfile=None, image_tag_string=None): '''Any initial setup''' # generate random names for image, container, and tag general.initialize_names() # load the cache cache.load() # load dockerfile if present if dockerfile: docker.load_docker_commands(dockerfile) # check if the docker image is present if image_tag_string: if not container.check_image(image_tag_string): logger.fatal(errors.cannot_find_image.format( imagetag=image_tag_string)) sys.exit() # create temporary working directory if not os.path.exists(constants.temp_folder): os.mkdir(constants.temp_folder) # set up folders for rootfs operations rootfs.set_up()
def get_base_obj(base_image_tag): '''Get a list of layers with their associated packages: 1. Check if the base image exists on the host machine 2. Get the layers 3. For each layer check if there is a list of packages associated with it in the cache 4. If there are no packages return a list of empty layer objects''' obj_list = [] if not check_base_image(base_image_tag): # the base image cannot be found locally nor remotely # at this point there is no context for Tern to use so raise an # exception to exit gracefully logger.error(base_image_not_found) sys.exit(1) else: cache.load() # get the history with diff ids # tuples look like this: (history command, diff_id) layer_history = get_layer_history(get_image_tag_string(base_image_tag)) for layer_tuple in layer_history: layer_obj = get_layer_obj(layer_tuple[1]) obj_list.append(layer_obj) return obj_list