mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
Currently, RBAC YAML files in helm-chart/kuberay-operator/templates and ray-operator/config/rbac should be synchronized manually. We have pointed this out in DEVELOPMENT.md, but it is not easy for users to find the messages. Hence, we need to make this information become more explicit in both DEVELOPMENT.md and rbac-check.py.
31 lines
984 B
Python
31 lines
984 B
Python
import os
|
|
import sys
|
|
from yaml import load, CLoader as Loader
|
|
from deepdiff import DeepDiff
|
|
|
|
def compare_two_yaml(yaml1, yaml2):
|
|
diff = DeepDiff(yaml1['rules'], yaml2['rules'])
|
|
if diff:
|
|
print(diff)
|
|
return not diff
|
|
|
|
if __name__ == "__main__":
|
|
curr_dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
helm_rbac_dir = curr_dir_path + '/tmp/'
|
|
kustomize_rbac_dir = curr_dir_path + '/../ray-operator/config/rbac/'
|
|
|
|
os.system(f"{curr_dir_path}/helm-render-yaml.sh")
|
|
files = os.listdir(helm_rbac_dir)
|
|
diff_files = []
|
|
|
|
for f in files:
|
|
yaml1 = load(open(helm_rbac_dir + f, 'r'), Loader=Loader)
|
|
yaml2 = load(open(kustomize_rbac_dir + f, 'r'), Loader=Loader)
|
|
if not compare_two_yaml(yaml1, yaml2):
|
|
diff_files.append(f)
|
|
|
|
if diff_files:
|
|
sys.exit(f"{diff_files} are out of synchronization! RBAC YAML files in" +
|
|
"\'helm-chart/kuberay-operator/templates\' and \'ray-operator/config/rbac\'" +
|
|
"should be synchronized manually. See DEVELOPMENT.md for more details.")
|