How to use the iotedgedev.buildoptionsparser.BuildOptionsParser function in iotedgedev

To help you get started, we’ve selected a few iotedgedev examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / iotedgedev / tests / test_buildoptionsparser.py View on Github external
'extra_hosts': {
            'github.com': '192.30.255.112',
            'ports.ubuntu.com': '91.189.88.150'
        },
        'cache_from': ['a', 'b'],
        'network_mode': 'bridge',
        'platform': 'Linux',
        'container_limits': {
            'cpushares': '50',
            'memory': '10000000',
        },
        'pull': True,
        'quiet': False,
        'nocache': True
    }
    build_options_parser = BuildOptionsParser(build_options)
    assert sdk_options == build_options_parser.parse_build_options()
github Azure / iotedgedev / tests / test_buildoptionsparser.py View on Github external
def test_invalid_build_options():
    with pytest.raises(KeyError):
        build_options = [
            "--cgroup-parent",
            "--compress",
            "--cpu-period",
            "--cpuset-mems 10",
        ]
        build_options_parser = BuildOptionsParser(build_options)
        build_options_parser.parse_build_options()
github Azure / iotedgedev / tests / test_buildoptionsparser.py View on Github external
def test_parse_val():
    build_options = [
        "--network bridge",
        "--platform Linux",
        "--shm-size 1000000",
        "--target target"
    ]
    sdk_options = {
        'network_mode': 'bridge',
        'platform': 'Linux',
        'shmsize': '1000000',
        'target': 'target'
    }
    build_options_parser = BuildOptionsParser(build_options)
    assert sdk_options == build_options_parser.parse_build_options()
github Azure / iotedgedev / tests / test_buildoptionsparser.py View on Github external
]
    sdk_options = {
        'extra_hosts': {
            'github.com': '192.30.255.112',
            'ports.ubuntu.com': '91.189.88.150'
        },
        'buildargs': {
            'a': 'b',
            'c': 'd'
        },
        'labels': {
            'e': 'f',
            'g': ''
        }
    }
    build_options_parser = BuildOptionsParser(build_options)
    assert sdk_options == build_options_parser.parse_build_options()
github Azure / iotedgedev / tests / test_buildoptionsparser.py View on Github external
def test_parse_flag():
    build_options = [
        "--pull=true",
        "-q=false",
        "--no-cache"
    ]
    sdk_options = {
        'pull': True,
        'quiet': False,
        'nocache': True
    }
    build_options_parser = BuildOptionsParser(build_options)
    assert sdk_options == build_options_parser.parse_build_options()
github Azure / iotedgedev / tests / test_buildoptionsparser.py View on Github external
def test_parse_to_list():
    build_options = [
        "--cache-from a",
        "--cache-from b"
    ]
    sdk_options = {
        'cache_from': ['a', 'b']
    }
    build_options_parser = BuildOptionsParser(build_options)
    assert sdk_options == build_options_parser.parse_build_options()
github Azure / iotedgedev / iotedgedev / modules.py View on Github external
tags_to_build.add(tag)

        if not no_build or not no_push:
            docker = Docker(self.envvars, self.utility, self.output)
            for tag in tags_to_build:
                if tag in tag_build_profile_map:
                    # BUILD DOCKER IMAGE
                    if not no_build:
                        build_profile = tag_build_profile_map.get(tag)

                        dockerfile = build_profile.dockerfile
                        self.output.info("PROCESSING DOCKERFILE: {0}".format(dockerfile))
                        self.output.info("BUILDING DOCKER IMAGE: {0}".format(tag))

                        build_options = build_profile.extra_options
                        build_options_parser = BuildOptionsParser(build_options)
                        sdk_options = build_options_parser.parse_build_options()

                        context_path = build_profile.context_path

                        # A hack to work around Python Docker SDK's bug with Linux container mode on Windows
                        # https://github.com/docker/docker-py/issues/2127
                        dockerfile_relative = os.path.relpath(dockerfile, context_path)
                        if docker.get_os_type() == "linux" and sys.platform == "win32":
                            dockerfile_relative = dockerfile_relative.replace("\\", "/")

                        build_args = {"tag": tag, "path": context_path, "dockerfile": dockerfile_relative}
                        build_args.update(sdk_options)

                        response = docker.docker_api.build(**build_args)
                        docker.process_api_response(response)
                    if not no_push:
github Azure / iotedgedev / iotedgedev / buildoptionsparser.py View on Github external
def _filter_build_options(self):
        """Remove build options which will be ignored"""
        if self.build_options is None:
            return None

        filtered_build_options = []
        for build_option in self.build_options:
            build_option = build_option.strip()
            cli_key, cli_val = split_build_option(build_option)
            if cli_key:
                if cli_key not in BuildOptionsParser.filter_set:
                    filtered_build_options.append((cli_key, cli_val))
                else:
                    self.output.info('Build option {0} will be ignored.'.format(cli_key))

        return filtered_build_options