def teardown(config):
    """
    Teardown the build directory structure created to deploy the environment.
    Modifies the dictionary passed in, then returns it.

    Args:
        config: dictionary containing all variable settings required
                to run terraform with
    Returns:
        config

    Raises:
        MissingConfigurationParameterException if 'tmpdir' is unset.
    """
    logger.debug("Removing tmpdir: {}".format(config['tmpdir']))
    workdir.options.path = config.get('tmpdir')
    if not workdir.options.path:
        msg = "tmpdir variable is not set. Can not destroy tmpdir location"
        raise MissingConfigurationParameterException(msg)

    workdir.remove()

    if not utils.git_url(config['terraform']):
        workdir.options.path = config.get('tf_root')
        workdir.remove()

    return config
Exemple #2
0
def setup_teardown(scope="function"):
    passed_config = {
        "terraform": "[email protected]:group/project.git?branch=made_up_branch",
        "tmpdir": "/tmp/test_tmp_dir",
        "tfvars": "/tmp/test_tmp_dir/vars.tf",
        "tf_state_dir": "myenvname-a",
        "tf_state_bucket": "123456789012-myproj-tfstate",
        "project_config": "123456789012-myproj-data",
        "env_folder": "myenvname-a",
        "route53_tld": "subdomain.toplevel.domain"
    }
    workdir.options.path = passed_config['tmpdir']
    workdir.remove()

    yield passed_config
    # Make sure we clean up if anything else actually creates it
    workdir.options.path = passed_config['tmpdir']
    workdir.remove()
Exemple #3
0
def setup_teardown(scope="function"):
    # Make sure test environment doesn't exist
    mock_config = {
        "terraform":
        "[email protected]:group/project.git?branch=made_up_branch",
        "aws_profile":
        "veracode-random",
        "aws_region":
        "us-east-1",
        "availability_zones":
        ['us-east-1b', 'us-east-1c', 'us-east-1d', 'us-east-1e'],
        "account_id":
        "555828001259",
        "environment": {
            "name": "myenvname",
            "version": "a",
        },
        "env_name":
        "myenvname-a",
        "tf_state":
        "555828001259-unittests-my_env_name-a-tfstate",
        "project_config":
        "555828001259-unittests-data",
        "project":
        'myproj'
    }

    tmpdir = '/tmp/test_tmp_dir'
    tmpfile = os.path.join(tmpdir, "test_vars.json")

    workdir.options.path = tmpdir
    workdir.create()
    with open(tmpfile, 'w') as tfile:
        json.dump(mock_config, tfile, indent=2)

    yield {'mock_config': mock_config, 'filename': tmpfile}
    # Make sure we clean up if anything else actually creates it
    workdir.options.path = tmpdir
    workdir.remove()
Exemple #4
0
def test_remove(tmpdir):
    with tmpdir.as_cwd():
        workdir.options.path = 'test_remove'
        os.mkdir(workdir.options.path)
        workdir.remove()
        assert not os.path.exists(workdir.options.path)
Exemple #5
0
def task_clean(args):
    workdir.remove()