def main(): '''main is a wrapper for the client to hand the parser to the executable functions This makes it possible to set up a parser in test cases ''' bot.debug("\n*** STARTING SINGULARITY PYTHON PULL ****") from defaults import LAYERFILE, DISABLE_CACHE, getenv # What image is the user asking for? container = getenv("SINGULARITY_CONTAINER", required=True) pull_folder = getenv("SINGULARITY_PULLFOLDER") image_uri = get_image_uri(container) container = remove_image_uri(container, quiet=True) if image_uri == "shub://": from shub.main import PULL manifest = PULL(image=container, download_folder=pull_folder, layerfile=LAYERFILE) else: bot.error("uri %s is not supported for pull. Exiting." % (image_uri)) sys.exit(1)
def main(): '''this function will run a docker import, returning a list of layers and environmental variables and metadata to the metadata base ''' container = getenv("SINGULARITY_CONTAINER", required=True) image_uri = get_image_uri(container, quiet=True) container = remove_image_uri(container) ######################################################################## # Docker Image ######################################################### ######################################################################## if image_uri == "docker://": bot.debug("\n*** STARTING DOCKER IMPORT PYTHON ****") from sutils import basic_auth_header from defaults import LAYERFILE bot.debug("Docker layers and metadata will be written to: %s" % (LAYERFILE)) username = getenv("SINGULARITY_DOCKER_USERNAME") password = getenv("SINGULARITY_DOCKER_PASSWORD", silent=True) auth = None if username is not None and password is not None: auth = basic_auth_header(username, password) from docker.main import IMPORT manifest = IMPORT(auth=auth, image=container, layerfile=LAYERFILE) ######################################################################## # Singularity Hub ###################################################### ######################################################################## elif image_uri == "shub://": bot.debug("\n*** STARTING SINGULARITY HUB IMPORT PYTHON ****") from defaults import LAYERFILE, LABELFILE from shub.main import IMPORT IMPORT(image=container, layerfile=LAYERFILE, labelfile=LABELFILE) else: bot.error("uri %s is not supported for import. Exiting." % (image_uri)) sys.exit(1)
def test_get_image_uri(self): '''test_get_image_uri ensures that the correct uri is returned for a user specified uri, registry, namespace. ''' from shell import get_image_uri print("Case 1: No image uri should return None") image_uri = get_image_uri('namespace/repo:tag') self.assertEqual(image_uri, None) print("Case 2: testing return of shub://") image_uri = get_image_uri('shub://namespace/repo:tag') self.assertEqual(image_uri, 'shub://') print("Case 3: testing return of docker uri") image_uri = get_image_uri('docker://namespace/repo:tag') self.assertEqual(image_uri, 'docker://') print("Case 4: weird capitalization should return lowercase") image_uri = get_image_uri('DocKer://namespace/repo:tag') self.assertEqual(image_uri, 'docker://')
def main(): '''this function will run a docker import, returning a list of layers and environmental variables and metadata to the metadata base ''' container = getenv("SINGULARITY_CONTAINER", required=True) image_uri = get_image_uri(container, quiet=True) container = remove_image_uri(container) ############################################################################## # Docker Image ############################################################### ############################################################################## if image_uri == "docker://": bot.debug("\n*** STARTING DOCKER IMPORT PYTHON ****") from sutils import basic_auth_header from defaults import LAYERFILE bot.debug( "Docker layers and (env,labels,runscript) will be written to: %s" % LAYERFILE) username = getenv("SINGULARITY_DOCKER_USERNAME") password = getenv("SINGULARITY_DOCKER_PASSWORD", silent=True) auth = None if username is not None and password is not None: auth = basic_auth_header(username, password) from docker.main import IMPORT manifest = IMPORT(auth=auth, image=container, layerfile=LAYERFILE) ############################################################################## # Singularity Hub ############################################################ ############################################################################## elif image_uri == "shub://": bot.debug("\n*** STARTING SINGULARITY HUB IMPORT PYTHON ****") from defaults import LAYERFILE, LABELFILE from shub.main import IMPORT IMPORT(image=container, layerfile=LAYERFILE, labelfile=LABELFILE) else: bot.error( "uri %s is not a currently supported uri for import. Exiting." % image_uri) sys.exit(1)
def main(): '''this function will run the main size functions and call shub clients ''' container = getenv("SINGULARITY_CONTAINER",required=True) image_uri = get_image_uri(container) container = remove_image_uri(container) from defaults import LAYERFILE ############################################################################## # Singularity Hub ############################################################ ############################################################################## if image_uri == "shub://": bot.debug("\n*** STARTING SINGULARITY HUB SIZE PYTHON ****") from shub.main import SIZE SIZE(image=container, contentfile=LAYERFILE) elif image_uri == "docker://": from sutils import basic_auth_header from docker.main import SIZE bot.debug("Docker sizes will be written to: %s" %LAYERFILE) username = getenv("SINGULARITY_DOCKER_USERNAME") password = getenv("SINGULARITY_DOCKER_PASSWORD",silent=True) auth = None if username is not None and password is not None: auth = basic_auth_header(username, password) SIZE(image=container, auth=auth, contentfile=LAYERFILE) else: bot.error("uri %s is not a currently supported uri for size. Exiting." %image_uri) sys.exit(1)