Пример #1
0
def check_terraform_version():
    if not is_command_available(TERRAFORM_BIN):
        return False, None

    ver_string = run([TERRAFORM_BIN, "-version"])
    ver_string = re.search(r"v(\d+\.\d+\.\d+)", ver_string).group(1)
    if ver_string is None:
        return False, None
    return True, ver_string
Пример #2
0
def check_terraform_version():
    if not is_command_available("terraform"):
        return False, None

    ver_string = run("terraform -version")
    ver_string = re.search(r"v(\d+\.\d+\.\d+)", ver_string).group(1)
    if ver_string is None:
        return False, None
    return version.parse(ver_string) < version.parse("0.15"), ver_string
Пример #3
0
def check_terraform_version():
    if not is_command_available('terraform'):
        return False, None

    ver_string = run('terraform -version')
    ver_string = re.search(r'v(\d+\.\d+\.\d+)', ver_string).group(1)
    if ver_string is None:
        return False, None
    return version.parse(ver_string) < version.parse('0.15'), ver_string
Пример #4
0
    def init_async(cls):
        if not is_command_available('terraform'):
            return

        def _run(*args):
            with (INIT_LOCK):
                base_dir = cls.get_base_dir()
                if not os.path.exists(os.path.join(base_dir, '.terraform')):
                    run('cd %s; terraform init -input=false' % base_dir)
                run('cd %s; terraform plan -out=tfplan -input=false' %
                    base_dir)

        start_worker_thread(_run)
Пример #5
0
def test_validate_config_syntax_error(runner, monkeypatch, tmp_path):
    if not is_command_available("docker-compose"):
        pytest.skip("config validation needs the docker-compose command")

    file = tmp_path / "docker-compose.yml"
    file.touch()

    file.write_text("foobar.---\n")

    result = runner.invoke(cli, ["config", "validate", "--file", str(file)])

    assert result.exit_code == 1
    assert "error" in result.output
Пример #6
0
    def init_async(cls):
        if not is_command_available('terraform'):
            return

        def _run(*args):
            with (INIT_LOCK):
                base_dir = cls.get_base_dir()
                if not os.path.exists(
                        os.path.join(base_dir, '.terraform', 'plugins')):
                    run('cd %s; terraform init -input=false' % base_dir)
                # remove any cache files from previous runs
                for tf_file in [
                        'tfplan', 'terraform.tfstate',
                        'terraform.tfstate.backup'
                ]:
                    rm_rf(os.path.join(base_dir, tf_file))
                # create TF plan
                run('cd %s; terraform plan -out=tfplan -input=false' %
                    base_dir)

        start_worker_thread(_run)
Пример #7
0
def test_validate_config(runner, monkeypatch, tmp_path):
    if not is_command_available("docker-compose"):
        pytest.skip("config validation needs the docker-compose command")

    file = tmp_path / "docker-compose.yml"
    file.touch()

    file.write_text(
        """version: "3.3"
services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack
    network_mode: bridge
    ports:
      - "127.0.0.1:53:53"
      - "127.0.0.1:53:53/udp"
      - "127.0.0.1:443:443"
      - "127.0.0.1:4566:4566"
      - "127.0.0.1:4571:4571"
    environment:
      - SERVICES=${SERVICES- }
      - DEBUG=${DEBUG- }
      - DATA_DIR=${DATA_DIR- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
      - LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY- }
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOST_TMP_FOLDER=${TMPDIR}
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"
"""
    )

    result = runner.invoke(cli, ["config", "validate", "--file", str(file)])

    assert result.exit_code == 0
    assert "config valid" in result.output
Пример #8
0
 def test_is_command_available(self):
     assert common.is_command_available("python3")
     assert not common.is_command_available("hopefullydoesntexist")
Пример #9
0
 def test_is_command_available(self):
     self.assertTrue(common.is_command_available("python3"))
     self.assertFalse(common.is_command_available("hopefullydoesntexist"))