in marketplace/deployer_util/process_helm_hooks.py [0:0]
def main():
parser = ArgumentParser()
parser.add_argument(
"--manifest", help="the manifest file location to be cleared of tests")
parser.add_argument(
"--deploy_tests",
action="store_true",
help="indicates whether tests should be deployed")
args = parser.parse_args()
manifest = args.manifest
resources = load_resources_yaml(manifest)
filtered_resources = []
for resource in resources:
helm_hook = deep_get(resource, "metadata", "annotations", _HELM_HOOK_KEY)
if helm_hook is None:
filtered_resources.append(resource)
elif helm_hook in _HOOK_SUCCESS:
if args.deploy_tests:
annotations = deep_get(resource, "metadata", "annotations")
del annotations[_HELM_HOOK_KEY]
annotations[GOOGLE_CLOUD_TEST] = "test"
filtered_resources.append(resource)
elif helm_hook in _HOOK_FAILURE:
if args.deploy_tests:
raise Exception("Helm hook {} is not supported".format(helm_hook))
else:
raise Exception("Helm hook {} is not supported".format(helm_hook))
with open(manifest, "w", encoding='utf-8') as out:
yaml.dump_all(
filtered_resources, out, default_flow_style=False, explicit_start=True)