Repository: jboss-dockerfiles/dogen

Issue:
Remove '--additional-script' argument
There is no use case for this option anymore.

Discussion:

Patch:
diff --git a/dogen/cli.py b/dogen/cli.py
index 2e8930d..6540695 100644
--- a/dogen/cli.py
+++ b/dogen/cli.py
@@ -55,7 +55,6 @@ class CLI(object):
         parser.add_argument('--without-sources', '--ws', action='store_true', help='Do not process sources, only generate Dockerfile')
         parser.add_argument('--skip-ssl-verification', action='store_true', help='Should we skip SSL verification when retrieving data?')
         parser.add_argument('--scripts-path', help='Location of the scripts directory containing script packages.')
-        parser.add_argument('--additional-script', action='append', help='Location of additional script (can be url). Can be specified multiple times.')
         parser.add_argument('--template', help='Path to custom template (can be url)')
 
         parser.add_argument('path', help="Path to yaml descriptor to process")
diff --git a/dogen/generator.py b/dogen/generator.py
index ba48876..52fa501 100644
--- a/dogen/generator.py
+++ b/dogen/generator.py
@@ -28,7 +28,6 @@ class Generator(object):
         self.dockerfile = os.path.join(self.output, "Dockerfile")
         self.template = args.template
         self.scripts_path = args.scripts_path
-        self.additional_scripts = args.additional_script
 
         ssl_verify = None
         if args.skip_ssl_verification:
@@ -133,11 +132,6 @@ class Generator(object):
         if scripts and not self.scripts_path:
             self.scripts_path = scripts
 
-        additional_scripts = dogen_cfg.get('additional_scripts')
-
-        if additional_scripts and not self.additional_scripts:
-            self.additional_scripts = additional_scripts
-
         if self.scripts_path and not os.path.exists(self.scripts_path):
             raise Error("Provided scripts directory '%s' does not exist" % self.scripts_path)
 
@@ -164,24 +158,6 @@ class Generator(object):
                 shutil.copytree(src=src_path, dst=output_path)
                 self.log.debug("Done.")
 
-    def _handle_additional_scripts(self):
-        self.log.info("Additional scripts provided, installing them...")
-        output_scripts = os.path.join(self.output, "scripts")
-
-        if not os.path.exists(output_scripts):
-            os.makedirs(output_scripts)
-
-        for f in self.additional_scripts:
-            self.log.debug("Handling '%s' file..." % f)
-            if Tools.is_url(f):
-                self._fetch_file(f, os.path.join(output_scripts, os.path.basename(f)))
-            else:
-                if not (os.path.exists(f) and os.path.isfile(f)):
-                    raise Error("File '%s' does not exist. Please make sure you specified correct path to a file when specifying additional scripts." % f)
-
-                self.log.debug("Copying '%s' file to target scripts directory..." % f)
-                shutil.copy(f, output_scripts)
-
     def _validate_cfg(self):
         """
         Open and parse the YAML configuration file and ensure it matches
@@ -241,10 +217,6 @@ class Generator(object):
         else:
             self.log.warn("No scripts will be copied, mistake?")
 
-        # Additional scripts (not package scripts)
-        if self.additional_scripts:
-            self._handle_additional_scripts()
-
         self.handle_sources()
         self.render_from_template()
 
diff --git a/dogen/schema/kwalify_schema.yaml b/dogen/schema/kwalify_schema.yaml
index 50ba8a0..a54aa67 100644
--- a/dogen/schema/kwalify_schema.yaml
+++ b/dogen/schema/kwalify_schema.yaml
@@ -54,9 +54,6 @@ map:
       ssl_verify: {type: bool}
       template: {type: str}
       scripts_path: {type: str}
-      additional_scripts:
-        seq:
-          - {type: str}
   scripts:
     seq:
       - map:


Test patch:
diff --git a/tests/test_unit_generate_configuration.py b/tests/test_unit_generate_configuration.py
index 4572a7d..531ee8e 100644
--- a/tests/test_unit_generate_configuration.py
+++ b/tests/test_unit_generate_configuration.py
@@ -19,8 +19,7 @@ class TestConfig(unittest.TestCase):
         self.descriptor = tempfile.NamedTemporaryFile(delete=False)
         self.descriptor.write(self.basic_config.encode())
         self.args = argparse.Namespace(path=self.descriptor.name, output="target", without_sources=False,
-                                       template=None, scripts_path=None, additional_script=None,
-                                       skip_ssl_verification=None)
+                                       template=None, scripts_path=None, skip_ssl_verification=None)
     def tearDown(self):
         os.remove(self.descriptor.name)
 
@@ -31,7 +30,6 @@ class TestConfig(unittest.TestCase):
         self.assertEqual(self.generator.descriptor, self.descriptor.name)
         self.assertEqual(self.generator.template, None)
         self.assertEqual(self.generator.scripts_path, None)
-        self.assertEqual(self.generator.additional_scripts, None)
         self.assertEqual(self.generator.without_sources, False)
         # Set to True in the configure() method later
         self.assertEqual(self.generator.ssl_verify, None)
@@ -121,23 +119,6 @@ class TestConfig(unittest.TestCase):
         mock_patch.assert_called_with('custom-scripts')
         self.assertEqual(generator.scripts_path, "custom-scripts")
 
-    def test_custom_additional_scripts_in_descriptor(self):
-        with self.descriptor as f:
-            f.write("dogen:\n  additional_scripts:\n    - http://host/somescript".encode())
-
-        generator = Generator(self.log, self.args)
-        generator.configure()
-        self.assertEqual(generator.additional_scripts, ["http://host/somescript"])
-
-    def test_custom_additional_scripts_in_cli_should_override_in_descriptor(self):
-        with self.descriptor as f:
-            f.write("dogen:\n  additional_scripts:\n    - http://host/somescript".encode())
-        args = self.args
-        args.additional_script=["https://otherhost/otherscript"]
-        generator = Generator(self.log, args)
-        generator.configure()
-        self.assertEqual(generator.additional_scripts, ["https://otherhost/otherscript"])
-
     @mock.patch('dogen.generator.os.path.exists', return_value=True)
     def helper_test_script_exec(self, exec_to_test, cfg, mock_patch):
         """Helper method for tests around script exec value"""