Repository: opensearch-project/opensearch-build

Issue:
[Bug]: Updated input manifests creates old version manifests part of `legacy-manifests/` folder
### Describe the bug

With the change to move the old input manifests to [legacy-manifests folder](url) in build repo, the [auto generate manifest workflow ](https://github.com/opensearch-project/opensearch-build/blob/main/.github/workflows/versions.yml) creates even the manifests part of the legacy-manifests folder assuming they does not exist.
Sample PR.
https://github.com/opensearch-project/opensearch-build/pull/2389/files

### To reproduce

The workflow PR
https://github.com/opensearch-project/opensearch-build/pull/2389/files

### Expected behavior

The `./manifest.sh update` logic should be modified:
1) Either it should create manifests greater than the version number from the manifests inside the [legacy manifest folder](https://github.com/opensearch-project/opensearch-build/tree/main/legacy-manifests)
2) Logic to compare both manifests and legacy-manifests folder.

### Screenshots

If applicable, add screenshots to help explain your problem.

### Host / Environment

_No response_

### Additional context

_No response_

### Relevant log output

_No response_


Discussion:

Resolving patch:
diff --git a/src/manifests_workflow/input_manifests.py b/src/manifests_workflow/input_manifests.py
--- a/src/manifests_workflow/input_manifests.py
+++ b/src/manifests_workflow/input_manifests.py
@@ -29,6 +29,10 @@ def __init__(self, name: str) -> None:
     def manifests_path(self) -> str:
         return os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "manifests"))
 
+    @classmethod
+    def legacy_manifests_path(self) -> str:
+        return os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "legacy-manifests"))
+
     @classmethod
     def jenkins_path(self) -> str:
         return os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "jenkins"))
@@ -40,11 +44,12 @@ def cron_jenkinsfile(self) -> str:
     @classmethod
     def files(self, name: str) -> List:
         results = []
-        for filename in glob.glob(os.path.join(self.manifests_path(), f"**/{name}-*.yml")):
-            # avoids the -maven manifest
-            match = re.search(rf"^{name}-([0-9.]*).yml$", os.path.basename(filename))
-            if match:
-                results.append(filename)
+        for path in [self.manifests_path(), self.legacy_manifests_path()]:
+            for filename in glob.glob(os.path.join(path, f"**/{name}-*.yml")):
+                # avoids the -maven manifest
+                match = re.search(rf"^{name}-([0-9.]*).yml$", os.path.basename(filename))
+                if match:
+                    results.append(filename)
         return results
 
     @abstractmethod


Test patch:
diff --git a/tests/tests_manifests_workflow/test_input_manifests.py b/tests/tests_manifests_workflow/test_input_manifests.py
--- a/tests/tests_manifests_workflow/test_input_manifests.py
+++ b/tests/tests_manifests_workflow/test_input_manifests.py
@@ -16,6 +16,24 @@ def test_manifests_path(self) -> None:
         path = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "manifests"))
         self.assertEqual(path, InputManifests.manifests_path())
 
+    def test_legacy_manifests_path(self) -> None:
+        path = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..", "legacy-manifests"))
+        self.assertEqual(path, InputManifests.legacy_manifests_path())
+
+    def test_files(self) -> None:
+        files = InputManifests.files("invalid")
+        self.assertEqual(len(files), 0)
+
+    def test_files_opensearch(self) -> None:
+        files = InputManifests.files("opensearch")
+        self.assertTrue(os.path.join(InputManifests.manifests_path(), os.path.join("1.3.0", "opensearch-1.3.0.yml")) in files)
+        self.assertTrue(os.path.join(InputManifests.legacy_manifests_path(), os.path.join("1.2.1", "opensearch-1.2.1.yml")) in files)
+
+    def test_files_opensearch_dashboards(self) -> None:
+        files = InputManifests.files("opensearch-dashboards")
+        self.assertTrue(os.path.join(InputManifests.manifests_path(), os.path.join("1.3.3", "opensearch-dashboards-1.3.3.yml")) in files)
+        self.assertTrue(os.path.join(InputManifests.legacy_manifests_path(), os.path.join("1.2.1", "opensearch-dashboards-1.2.1.yml")) in files)
+
     def test_create_manifest_opensearch(self) -> None:
         input_manifests = InputManifests("OpenSearch")
         input_manifest = input_manifests.create_manifest("1.2.3", [])