예제 #1
0
파일: run.py 프로젝트: xaleeks/tern
def get_dockerfile_packages():
    '''Given a Dockerfile return an approximate image object. This is mosty
    guess work and shouldn't be relied on for accurate information. Add
    Notice messages indicating as such:
        1. Create an image with a placeholder repotag
        2. For each RUN command, create a package list
        3. Create layer objects with incremental integers and add the package
        list to that layer with a Notice about parsing
        4. Return stub image'''
    stub_image = Image('easteregg:cookie')
    layer_count = 0
    for cmd in dhelper.docker_commands:
        if cmd['instruction'] == 'RUN':
            layer_count = layer_count + 1
            layer = ImageLayer(layer_count)
            install_commands, msg = \
                common.filter_install_commands(cmd['value'])
            if msg:
                layer.origins.add_notice_to_origins(cmd['value'],
                                                    Notice(msg, 'info'))
            pkg_names = []
            for command in install_commands:
                pkg_names.append(common.get_installed_package_names(command))
            for pkg_name in pkg_names:
                pkg = Package(pkg_name)
                # shell parser does not parse version pins yet
                # when that is enabled, Notices for no versions need to be
                # added here
                layer.add_package(pkg)
    return stub_image
예제 #2
0
 def setUp(self):
     '''Test a generic Image class'''
     self.image = Image('1234abcd')
예제 #3
0
 def setUp(self):
     '''Test a generic Image class'''
     self.image1 = Image('1234abcd')
     self.image2 = TestImage('5678efgh')
     self.image3 = TestImage('f380a61e')