Ejemplo n.º 1
0
    def driver(self):
        driver_name = self._get_driver_name()
        driver = None

        driver = molecule_drivers(as_dict=True, config=self)[driver_name]
        driver.name = driver_name

        return driver
Ejemplo n.º 2
0
    def driver(self):
        driver_name = self._get_driver_name()
        driver = None

        driver = molecule_drivers(as_dict=True)[driver_name].load(self)
        driver.name = driver_name

        return driver
Ejemplo n.º 3
0
def test_api_molecule_drivers():
    results = molecule_drivers()

    assert isinstance(results, list)

    for result in results:
        assert isinstance(result, str)

    assert 'delegated' in results
Ejemplo n.º 4
0
def drivers(ctx, format):  # pragma: no cover
    """ Lists drivers. """

    drivers = [[x] for x in molecule_drivers()]

    headers = ['name']
    table_format = 'simple'
    if format == 'plain':
        headers = []
        table_format = format
    _print_tabulate_data(headers, drivers, table_format)
Ejemplo n.º 5
0
def test_api_molecule_drivers_as_dict():
    results = molecule_drivers(as_dict=True)

    assert isinstance(results, dict)

    for result in results:
        assert isinstance(result, str)

    assert 'delegated' in results

    for driver in results.values():
        assert isinstance(driver, Base)
Ejemplo n.º 6
0
def test_molecule_drivers(caplog):
    x = [
        'delegated',
        'digitalocean',
        'docker',
        'ec2',
        'gce',
        'hetznercloud',
        'linode',
        'lxc',
        'lxd',
        'openstack',
        'podman',
        'vagrant',
    ]

    assert x == sorted(molecule_drivers())
    assert not caplog.records
Ejemplo n.º 7
0
        msg = 'Initialized role in {} successfully.'.format(role_directory)
        LOG.success(msg)


@click.command()
@click.pass_context
@click.option(
    '--dependency-name',
    type=click.Choice(['galaxy']),
    default='galaxy',
    help='Name of dependency to initialize. (galaxy)',
)
@click.option(
    '--driver-name',
    '-d',
    type=click.Choice(molecule_drivers()),
    default='docker',
    help='Name of driver to initialize. (docker)',
)
@click.option(
    '--lint-name',
    type=click.Choice(['yamllint']),
    default='yamllint',
    help='Name of lint to initialize. (yamllint)',
)
@click.option(
    '--provisioner-name',
    type=click.Choice(['ansible']),
    default='ansible',
    help='Name of provisioner to initialize. (ansible)',
)
Ejemplo n.º 8
0
def pre_validate_base_schema(env, keep_string):
    return {
        'dependency': {
            'type': 'dict',
            'schema': {
                'name': {
                    'type': 'string',
                    'molecule_env_var': True,
                    'allowed': ['galaxy', 'gilt', 'shell'],
                }
            },
        },
        'driver': {
            'type': 'dict',
            'schema': {
                'name': {
                    'type': 'string',
                    'molecule_env_var': True,
                    'allowed': molecule_drivers(),
                    # NOTE(retr0h): Some users use an environment variable to
                    # change the driver name.  May add this coercion to rest of
                    # config using allowed validation.
                    'coerce': (str, functools.partial(coerce_env, env, keep_string)),
                }
            },
        },
        'lint': {
            'type': 'dict',
            'schema': {
                'name': {
                    'type': 'string',
                    'molecule_env_var': True,
                    'allowed': ['yamllint'],
                }
            },
        },
        'platforms': {
            'type': 'list',
            'schema': {
                'type': 'dict',
                'schema': {
                    'registry': {
                        'type': 'dict',
                        'schema': {
                            'credentials': {
                                'type': 'dict',
                                'schema': {'password': {'type': 'string'}},
                            }
                        },
                    }
                },
            },
        },
        'provisioner': {
            'type': 'dict',
            'schema': {
                'name': {
                    'type': 'string',
                    'molecule_env_var': True,
                    'allowed': ['ansible'],
                },
                'lint': {
                    'type': 'dict',
                    'schema': {
                        'name': {
                            'type': 'string',
                            'molecule_env_var': True,
                            'allowed': ['ansible-lint'],
                        }
                    },
                },
            },
        },
        'scenario': {
            'type': 'dict',
            'schema': {'name': {'type': 'string', 'molecule_env_var': True}},
        },
        'verifier': {
            'type': 'dict',
            'schema': {
                'name': {
                    'type': 'string',
                    'molecule_env_var': True,
                    'allowed': ['testinfra', 'inspec', 'goss', 'ansible'],
                },
                'lint': {
                    'type': 'dict',
                    'schema': {
                        'name': {
                            'type': 'string',
                            'molecule_env_var': True,
                            'allowed': [
                                'flake8',
                                'pre-commit',
                                'rubocop',
                                'yamllint',
                                'ansible-lint',
                            ],
                        }
                    },
                },
            },
        },
    }
Ejemplo n.º 9
0
 def drivers(self):
     return molecule_drivers(config=self)
Ejemplo n.º 10
0
 def drivers(self):
     return molecule_drivers()