Skip to content

Commit

Permalink
Rename delegated driver to default
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Jul 10, 2023
1 parent 480c6dc commit 091c63e
Show file tree
Hide file tree
Showing 37 changed files with 78 additions and 87 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ changelog = "https://github.com/ansible-community/molecule/releases"
molecule = "molecule.__main__:main"

[project.entry-points."molecule.driver.next"]
delegated = "molecule.driver.delegated:Delegated"
default = "molecule.driver.delegated:Delegated"

[project.entry-points."molecule.verifier.next"]
testinfra = "molecule.verifier.testinfra:Testinfra"
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
MOLECULE_DIRECTORY = "molecule"
MOLECULE_FILE = "molecule.yml"
MOLECULE_KEEP_STRING = "MOLECULE_"
DEFAULT_DRIVER = "delegated"
DEFAULT_DRIVER = "default"

MOLECULE_EMBEDDED_DATA_DIR = os.path.dirname(data_module)

Expand Down Expand Up @@ -383,7 +383,7 @@ def _get_defaults(self) -> MutableMapping:
"env": {},
},
"driver": {
"name": "delegated",
"name": "default",
"provider": {"name": None},
"options": {"managed": True},
"ssh_connection_options": [],
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/data/driver.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"MoleculeDriverModel": {
"properties": {
"name": {
"enum": ["delegated"],
"enum": ["delegated", "default"],
"title": "Name",
"type": "string"
},
Expand Down
1 change: 1 addition & 0 deletions src/molecule/data/molecule.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"azure",
"ec2",
"delegated",
"default",
"docker",
"containers",
"openstack",
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/driver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ def safe_files(self):

@property
def delegated(self):
"""Is the driver delegated and returns a bool.
"""Is the dedriver delegated and returns a bool.
:returns: bool
"""
return self.name == "delegated"
return self.name == "default"

@property
def managed(self):
Expand Down
14 changes: 7 additions & 7 deletions src/molecule/driver/delegated.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@


class Delegated(Driver):
r"""The class responsible for managing delegated instances.
r"""The class responsible for managing default instances.
Delegated is `not` the default driver used in Molecule.
Expand All @@ -40,7 +40,7 @@ class Delegated(Driver):
``` yaml
driver:
name: delegated
name: de
```
However, the developer must adhere to the instance-config API. The
Expand Down Expand Up @@ -81,7 +81,7 @@ class Delegated(Driver):
``` yaml
driver:
name: delegated
name: default
options:
managed: False
login_cmd_template: 'docker exec -ti {instance} bash'
Expand All @@ -107,7 +107,7 @@ class Delegated(Driver):
``` yaml
driver:
name: delegated
name: default
options:
managed: False
login_cmd_template: 'ssh {instance} -F /tmp/ssh-config'
Expand All @@ -122,15 +122,15 @@ class Delegated(Driver):
``` yaml
driver:
name: delegated
name: default
safe_files:
- foo
```
And in order to use localhost as molecule's target:
``` yaml
driver:
name: delegated
name: default
options:
managed: False
ansible_connection_options:
Expand All @@ -141,7 +141,7 @@ class Delegated(Driver):
def __init__(self, config=None) -> None:
"""Construct Delegated."""
super().__init__(config)
self._name = "delegated"
self._name = "default"

@property
def name(self):
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/a_unit/command/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def command_patched_ansible_create(mocker):
def command_driver_delegated_section_data():
x = {
"driver": {
"name": "delegated",
"name": "default",
"options": {
"managed": False,
},
Expand All @@ -42,4 +42,4 @@ def command_driver_delegated_section_data():

@pytest.fixture()
def command_driver_delegated_managed_section_data():
return {"driver": {"name": "delegated", "managed": True}}
return {"driver": {"name": "default", "managed": True}}
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/init/test_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@pytest.fixture()
def _command_args():
return {
"driver_name": "delegated",
"driver_name": "default",
"role_name": "test-role",
"scenario_name": "test-scenario",
"subcommand": __name__,
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/command/test_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_execute(
assert "default" in caplog.text
assert "converge" in caplog.text

assert config_instance.state.driver == "delegated"
assert config_instance.state.driver == "default"

command_patched_ansible_create.assert_called_once_with()

Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/a_unit/command/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def test_execute(capsys, config_instance: config.Config):
x = [
base.Status(
instance_name="instance-1",
driver_name="delegated",
driver_name="default",
provisioner_name="ansible",
scenario_name="default",
created="false",
converged="false",
),
base.Status(
instance_name="instance-2",
driver_name="delegated",
driver_name="default",
provisioner_name="ansible",
scenario_name="default",
created="false",
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _molecule_dependency_galaxy_section_data():

@pytest.fixture()
def _molecule_driver_section_data():
return {"driver": {"name": "delegated", "options": {"managed": True}}}
return {"driver": {"name": "default", "options": {"managed": True}}}


@pytest.fixture()
Expand Down
2 changes: 1 addition & 1 deletion src/molecule/test/a_unit/cookiecutter/test_molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _role_directory():
def _command_args():
return {
"dependency_name": "galaxy",
"driver_name": "delegated",
"driver_name": "default",
"provisioner_name": "ansible",
"scenario_name": "default",
"role_name": "test-role",
Expand Down
10 changes: 5 additions & 5 deletions src/molecule/test/a_unit/driver/test_delegated.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
def _driver_managed_section_data():
return {
"driver": {
"name": "delegated",
"name": "default",
"options": {
"managed": True,
},
Expand All @@ -44,7 +44,7 @@ def _driver_managed_section_data():
def _driver_unmanaged_section_data():
return {
"driver": {
"name": "delegated",
"name": "default",
"options": {
"managed": False,
},
Expand All @@ -69,7 +69,7 @@ def test_testinfra_options_property(_instance):


def test_name_property(_instance):
assert _instance.name == "delegated"
assert _instance.name == "default"


@pytest.mark.parametrize(
Expand Down Expand Up @@ -317,14 +317,14 @@ def test_status(mocker: MockerFixture, _instance):
assert len(result) == 2

assert result[0].instance_name == "instance-1"
assert result[0].driver_name == "delegated"
assert result[0].driver_name == "default"
assert result[0].provisioner_name == "ansible"
assert result[0].scenario_name == "default"
assert result[0].created == "false"
assert result[0].converged == "false"

assert result[1].instance_name == "instance-2"
assert result[1].driver_name == "delegated"
assert result[1].driver_name == "default"
assert result[1].provisioner_name == "ansible"
assert result[1].scenario_name == "default"
assert result[1].created == "false"
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/a_unit/model/v2/test_driver_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def _model_driver_section_data():
return {
"driver": {
"name": "delegated",
"name": "default",
"provider": {"name": None},
"options": {"managed": True},
"ssh_connection_options": ["foo", "bar"],
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_driver_provider_name_nullable(_config):

@pytest.fixture()
def _model_driver_allows_delegated_section_data():
return {"driver": {"name": "delegated"}}
return {"driver": {"name": "default"}}


@pytest.fixture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_cleanup_property_is_optional(_instance):

@pytest.mark.skip(reason="create not running for delegated")
def test_create_property(_instance):
x = os.path.join(_instance._get_playbook_directory(), "delegated", "create.yml")
x = os.path.join(_instance._get_playbook_directory(), "default", "create.yml")

assert x == _instance._config.provisioner.playbooks.create

Expand All @@ -56,7 +56,7 @@ def test_converge_property(_instance):

@pytest.mark.skip(reason="destroy not running for delegated")
def test_destroy_property(_instance):
x = os.path.join(_instance._get_playbook_directory(), "delegated", "destroy.yml")
x = os.path.join(_instance._get_playbook_directory(), "default", "destroy.yml")

assert x == _instance._config.provisioner.playbooks.destroy

Expand Down Expand Up @@ -93,7 +93,7 @@ def test_get_playbook_returns_bundled_driver_playbook_when_local_not_found(
tmpdir,
_instance,
):
x = os.path.join(_instance._get_playbook_directory(), "delegated", "create.yml")
x = os.path.join(_instance._get_playbook_directory(), "default", "create.yml")

assert x == _instance._get_playbook("create")

Expand Down
6 changes: 3 additions & 3 deletions src/molecule/test/a_unit/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

def test_api_molecule_drivers_as_attributes():
results = api.drivers()
assert hasattr(results, "delegated")
assert isinstance(results.delegated, api.Driver)
assert hasattr(results, "default")
assert isinstance(results.default, api.Driver)


def test_api_drivers():
Expand All @@ -34,7 +34,7 @@ def test_api_drivers():
for result in results:
assert isinstance(result, api.Driver)

assert "delegated" in results
assert "default" in results


def test_api_verifiers():
Expand Down
6 changes: 3 additions & 3 deletions src/molecule/test/a_unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_dependency_property_is_shell(config_instance: config.Config):

@pytest.fixture()
def _config_driver_delegated_section_data():
return {"driver": {"name": "delegated", "options": {"managed": False}}}
return {"driver": {"name": "default", "options": {"managed": False}}}


def test_env(config_instance: config.Config):
Expand All @@ -124,7 +124,7 @@ def test_env(config_instance: config.Config):
"MOLECULE_PROJECT_DIRECTORY": config_instance.project_directory,
"MOLECULE_INSTANCE_CONFIG": config_instance.driver.instance_config,
"MOLECULE_DEPENDENCY_NAME": "galaxy",
"MOLECULE_DRIVER_NAME": "delegated",
"MOLECULE_DRIVER_NAME": "default",
"MOLECULE_PROVISIONER_NAME": "ansible",
"MOLECULE_SCENARIO_NAME": "default",
"MOLECULE_STATE_FILE": config_instance.state.state_file,
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_get_driver_name_from_cli(config_instance: config.Config):


def test_get_driver_name(config_instance: config.Config):
assert config_instance._get_driver_name() == "delegated"
assert config_instance._get_driver_name() == "default"


def test_get_driver_name_raises_when_different_driver_used(
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/a_unit/test_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_interpolate_with_molecule_yaml(_instance):
dependency:
name: $DEPENDENCY_NAME
driver:
name: delegated
name: default
platforms:
- name: instance-1
provisioner:
Expand All @@ -116,7 +116,7 @@ def test_interpolate_with_molecule_yaml(_instance):
dependency:
name: galaxy
driver:
name: delegated
name: default
platforms:
- name: instance-1
provisioner:
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/b_functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def with_scenario(request, scenario_to_test, driver_name, scenario_name, skip_te
def skip_test(request, driver_name):
msg_tmpl = "Skipped '{}' not supported"
support_checks_map = {
"delegated": lambda: True,
"default": lambda: True,
}
try:
check_func = support_checks_map[driver_name]
Expand Down Expand Up @@ -189,7 +189,7 @@ def login(login_args, scenario_name="default"):

def run_test(driver_name, scenario_name="default", parallel=False):
cmd = ["molecule", "test", "--scenario-name", scenario_name]
if driver_name != "delegated":
if driver_name != "default":
if scenario_name is None:
cmd.append("--all")
if parallel:
Expand Down
Loading

0 comments on commit 091c63e

Please sign in to comment.