1+ import os
2+ import yaml
3+ import sys
4+
5+ os .makedirs ('plugins/OpenShift' , exist_ok = True )
6+
7+ if os .path .exists ("index.yml" ):
8+ file = open ("index.yml" ,"r" )
9+ not_present = 1
10+ index = yaml .safe_load (file )
11+ for plugin in index ['plugins' ]:
12+ if plugin ['name' ] == 'OpenShiftPlugin' :
13+ not_present = 0
14+ break
15+ if not_present :
16+ index ['plugins' ].append ({"name" : "OpenShiftPlugin" , "path" : "https://github.com/%s/crane-plugins/raw/main/plugins/OpenShift/index.yaml" % sys .argv [1 ]})
17+ file = open ("index.yml" ,"w" )
18+ yaml .dump (index , file )
19+ file .close ()
20+
21+ else :
22+ file = open ("index.yml" ,"a+" )
23+
24+ index = yaml .safe_load (file )
25+
26+ index = {}
27+ index ['kind' ] = 'PluginIndex'
28+ index ['apiServer' ] = 'konveyor.io/v1alpha1'
29+ index ['plugins' ] = []
30+
31+ index ['plugins' ].append ({"name" : "OpenShiftPlugin" , "path" : "https://github.com/%s/crane-plugins/raw/main/plugins/OpenShift/index.yaml" % sys .argv [2 ]})
32+
33+ yaml .dump (index , file )
34+ file .close ()
35+
36+ # create or append in plugin index
37+ if os .path .exists ('plugins/OpenShift/index.yml' ):
38+
39+ file = open ("plugins/OpenShift/index.yml" ,"r" )
40+
41+ index = yaml .safe_load (file )
42+
43+ index ['versions' ].append ({})
44+ index ['versions' ][- 1 ] = {
45+ 'name' : 'OpenShiftPlugin' ,
46+ 'shortDescription' : 'OpenShiftPlugin' ,
47+ 'description' : 'this is OpenShiftPlugin' ,
48+ 'version' : sys .argv [1 ],
49+ 'binaries' : [
50+ {
51+ 'os' : 'linux' ,
52+ 'arch' : 'amd64' ,
53+ 'uri' : "https://github.com/%s/releases/download/%s/amd64-linux-openshiftplugin-%s" % (sys .argv [3 ], sys .argv [1 ],sys .argv [1 ]),
54+ },
55+ {
56+ 'os' : 'darwin' ,
57+ 'arch' : 'amd64' ,
58+ 'uri' : "https://github.com/%s/releases/download/%s/amd64-darwin-openshiftplugin-%s" % (sys .argv [3 ], sys .argv [1 ],sys .argv [1 ]),
59+ },
60+ {
61+ 'os' : 'darwin' ,
62+ 'arch' : 'arm64' ,
63+ 'uri' : "https://github.com/%s/releases/download/%s/arm64-darwin-openshiftplugin-%s" % (sys .argv [3 ], sys .argv [1 ],sys .argv [1 ]),
64+ },
65+ ],
66+ }
67+
68+ file = open ("plugins/OpenShift/index.yml" ,"w" )
69+
70+ yaml .dump (index , file )
71+ file .close ()
72+
73+ else :
74+ file = open ("plugins/OpenShift/index.yml" ,"a+" )
75+
76+ index = yaml .safe_load (file )
77+
78+ index = {}
79+ index ['kind' ] = 'Plugin'
80+ index ['apiServer' ] = 'konveyor.io/v1alpha1'
81+ index ['versions' ] = []
82+
83+ index ['versions' ].append ({})
84+ index ['versions' ][0 ] = {
85+ 'name' : 'OpenShiftPlugin' ,
86+ 'shortDescription' : 'OpenShiftPlugin' ,
87+ 'description' : 'this is OpenShiftPlugin' ,
88+ 'version' : sys .argv [1 ],
89+ 'binaries' : [
90+ {
91+ 'os' : 'linux' ,
92+ 'arch' : 'amd64' ,
93+ 'uri' : "https://github.com/%s/releases/download/%s/amd64-linux-openshiftplugin-%s" % (sys .argv [3 ], sys .argv [1 ],sys .argv [1 ]),
94+ },
95+ {
96+ 'os' : 'darwin' ,
97+ 'arch' : 'amd64' ,
98+ 'uri' : "https://github.com/%s/releases/download/%s/amd64-darwin-openshiftplugin-%s" % (sys .argv [3 ], sys .argv [1 ],sys .argv [1 ]),
99+ },
100+ {
101+ 'os' : 'darwin' ,
102+ 'arch' : 'arm64' ,
103+ 'uri' : "https://github.com/%s/releases/download/%s/arm64-darwin-openshiftplugin-%s" % (sys .argv [3 ], sys .argv [1 ],sys .argv [1 ]),
104+ },
105+ ],
106+ }
107+
108+ yaml .dump (index , file )
109+ file .close ()
0 commit comments