Repository: bsquizz/ocdeployer

Issue:
AttributeError: 'LegacyEnvConfigHandler' object has no attribute 'env_dir_name'
ocdeployer deploy -f --sets vmaas --template-dir buildfactory -e builder-env.yml vmaas-qe --secrets-local-dir secrets/sanitized

```
INFO:ocdeployer.deploy:Handling config for service set 'vmaas'

Traceback (most recent call last):

  File "/iqe_venv/bin/ocdeployer", line 8, in <module>

    sys.exit(main())

  File "/iqe_venv/lib64/python3.6/site-packages/click/core.py", line 764, in __call__

    return self.main(*args, **kwargs)

  File "/iqe_venv/lib64/python3.6/site-packages/click/core.py", line 717, in main

    rv = self.invoke(ctx)

  File "/iqe_venv/lib64/python3.6/site-packages/click/core.py", line 1137, in invoke

    return _process_result(sub_ctx.command.invoke(sub_ctx))

  File "/iqe_venv/lib64/python3.6/site-packages/click/core.py", line 956, in invoke

    return ctx.invoke(self.callback, **ctx.params)

  File "/iqe_venv/lib64/python3.6/site-packages/click/core.py", line 555, in invoke

    return callback(*args, **kwargs)

  File "/iqe_venv/lib64/python3.6/site-packages/ocdeployer/__main__.py", line 375, in deploy_to_project

    dry_run=False,

  File "/iqe_venv/lib64/python3.6/site-packages/ocdeployer/deploy.py", line 523, in run

    all_processed_templates[service_set] = self._deploy_service_set(service_set)

  File "/iqe_venv/lib64/python3.6/site-packages/ocdeployer/deploy.py", line 430, in _deploy_service_set

    set_cfg = self._get_service_set_cfg(service_set, dir_path)

  File "/iqe_venv/lib64/python3.6/site-packages/ocdeployer/deploy.py", line 421, in _get_service_set_cfg

    set_env_cfg = self.env_config_handler.get_service_set_env_cfg(dir_path, service_set)

  File "/iqe_venv/lib64/python3.6/site-packages/ocdeployer/env.py", line 190, in get_service_set_env_cfg

    self._get_service_set_vars(service_set_dir, service_set), service_set=service_set

  File "/iqe_venv/lib64/python3.6/site-packages/ocdeployer/env.py", line 139, in _get_service_set_vars

    path = os.path.join(service_set_dir, self.env_dir_name)

AttributeError: 'LegacyEnvConfigHandler' object has no attribute 'env_dir_name'
```

Discussion:

Patch:
diff --git a/ocdeployer/env.py b/ocdeployer/env.py
index 7ef3e7a..c644e9a 100644
--- a/ocdeployer/env.py
+++ b/ocdeployer/env.py
@@ -277,15 +277,12 @@ class LegacyEnvConfigHandler(EnvConfigHandler):
     def _get_env_name(file_path):
         return os.path.splitext(os.path.basename(file_path))[0]
 
-    def __init__(self, env_files):
+    def __init__(self, env_files, env_dir_name="env"):
         self.env_files = env_files
-        self._last_service_set = None
         _env_names = [self._get_env_name(fp) for fp in self.env_files]
-        self.env_names = _dedupe_preserve_order(_env_names)
-        if len(_env_names) != len(self.env_names):
-            log.warning("Duplicate env names provided: %s", _env_names)
+        super().__init__(_env_names, env_dir_name)
 
-    def _load_vars_per_env(self):
+    def _load_vars_per_env(self, path=None):
         data = {}
 
         for file_path in self.env_files:


Test patch:
diff --git a/tests/test_deploy.py b/tests/test_deploy.py
index ae53a1e..fcff4f4 100644
--- a/tests/test_deploy.py
+++ b/tests/test_deploy.py
@@ -10,7 +10,7 @@ def patched_runner(env_values, mock_load_vars_per_env, legacy=False):
     if not env_values:
         handler = None
     elif legacy:
-        handler = LegacyEnvConfigHandler(env_files=env_values)
+        handler = LegacyEnvConfigHandler(env_files=env_values, env_dir_name="envTEST")
         handler.env_names = env_values
     else:
         handler = EnvConfigHandler(env_names=env_values, env_dir_name="envTEST")