forked from opensearch-project/opensearch-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifests_args.py
54 lines (49 loc) · 1.85 KB
/
manifests_args.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
import argparse
import logging
from manifests_workflow.input_manifests_opensearch import InputManifestsOpenSearch
from manifests_workflow.input_manifests_opensearch_dashboards import InputManifestsOpenSearchDashboards
class ManifestsArgs:
def __init__(self):
parser = argparse.ArgumentParser(description="Manifest management")
parser.add_argument("action", choices=["list", "update"], help="Operation to perform.")
parser.add_argument(
"--type",
dest="type",
choices=["opensearch", "opensearch-dashboards"],
help="Only list manifests of a specific type.",
)
parser.add_argument(
"--keep",
dest="keep",
action="store_true",
help="Do not delete the working temporary directory.",
)
parser.add_argument(
"-v",
"--verbose",
help="Show more verbose output.",
action="store_const",
default=logging.INFO,
const=logging.DEBUG,
dest="logging_level",
)
args = parser.parse_args()
self.logging_level = args.logging_level
self.action = args.action
self.keep = args.keep
self.manifests = ManifestsArgs.__get_manifests(args.type)
@classmethod
def __get_manifests(self, type):
if type == "opensearch":
return [InputManifestsOpenSearch]
elif type == "opensearch-dashboards":
return [InputManifestsOpenSearchDashboards]
elif type is None:
return [InputManifestsOpenSearch, InputManifestsOpenSearchDashboards]
else:
raise ValueError(type)