-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanifest.py
More file actions
executable file
·109 lines (92 loc) · 2.53 KB
/
manifest.py
File metadata and controls
executable file
·109 lines (92 loc) · 2.53 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python3
"""Utility script to generate a Solution manifest from given arguments."""
import argparse
import sys
import yaml
def parse_arguments():
"""Parse arguments from the CLI."""
parser = argparse.ArgumentParser()
parser.add_argument(
'-a',
'--annotation',
nargs=2,
action='append',
dest='annotations',
default=[],
metavar=('KEY', 'VALUE'),
help="add an annotation to the Solution manifest metadata",
)
parser.add_argument(
'-e',
'--extra-image',
nargs=2,
action='append',
dest='extra_images',
default=[],
metavar=('NAME', 'TAG'),
help="add an image to the list of images shipped by the Solution",
)
parser.add_argument(
'-l',
'--label',
nargs=2,
action='append',
dest='labels',
default=[],
metavar=('KEY', 'VALUE'),
help="add a label to the Solution manifest metadata",
)
parser.add_argument(
'-n',
'--name',
required=True,
metavar='SOLUTION_NAME',
help="set the name of the Solution",
)
parser.add_argument(
'-o',
'--operator-image',
required=True,
nargs=2,
metavar=('NAME', 'TAG'),
help="set the Operator image name and tag in the manifest spec",
)
parser.add_argument(
'-v',
'--version',
required=True,
help="version of the Solution",
)
return parser.parse_args()
def build_manifest(args):
"""Build manifest from arguments provided on the CLI."""
return {
'apiVersion': 'solutions.metalk8s.scality.com/v1alpha1',
'kind': 'Solution',
'metadata': {
'name': args.name,
'annotations': dict(args.annotations),
'labels': dict(args.labels),
},
'spec': {
'images': list(set(
':'.join(image) for image in (
args.extra_images + [args.operator_image]
)
)),
'operator': {
'image': dict(zip(('name', 'tag'), args.operator_image)),
'metrics': {
'enabled': True,
}
},
'version': args.version,
},
}
def main(stream=sys.stdout):
"""Script entrypoint."""
args = parse_arguments()
manifest = build_manifest(args)
yaml.safe_dump(manifest, stream, default_flow_style=False)
if __name__ == '__main__':
main()