From d474631e38e182a69d4861b315d1b9a30fa7fb1a Mon Sep 17 00:00:00 2001 From: Nikhita Raghunath Date: Fri, 5 Apr 2019 12:02:40 +0530 Subject: [PATCH] Show all missing deps when publishing-bot has no listed dependencies Before this, it only showed one dependency in the error message. Also, replace godeps.json with go.mod in the error message. --- hack/verify-publishing-bot.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/hack/verify-publishing-bot.py b/hack/verify-publishing-bot.py index e457ca259d..75c22e61a9 100755 --- a/hack/verify-publishing-bot.py +++ b/hack/verify-publishing-bot.py @@ -23,7 +23,7 @@ import json import yaml -def get_godeps_dependencies(rootdir, components): +def get_gomod_dependencies(rootdir, components): all_dependencies = {} for component in components: with open(os.path.join(rootdir, component, "go.mod")) as f: @@ -58,8 +58,9 @@ def main(): components.append(component) components.sort() - godep_dependencies = get_godeps_dependencies(rootdir + '/staging/src/k8s.io/', components) - rules_dependencies = get_rules_dependencies(rootdir + "/staging/publishing/rules.yaml") + rules_file = "/staging/publishing/rules.yaml" + gomod_dependencies = get_gomod_dependencies(rootdir + '/staging/src/k8s.io/', components) + rules_dependencies = get_rules_dependencies(rootdir + rules_file) processed_repos = [] for rule in rules_dependencies["rules"]: @@ -70,10 +71,10 @@ def main(): raise Exception("cannot find master source branch for destination %s" % rule["destination"]) print("processing : %s" % rule["destination"]) - if rule["destination"] not in godep_dependencies: - raise Exception("missing Godeps.json for %s" % rule["destination"]) + if rule["destination"] not in gomod_dependencies: + raise Exception("missing go.mod for %s" % rule["destination"]) processed_repos.append(rule["destination"]) - for dep in set(godep_dependencies[rule["destination"]]): + for dep in set(gomod_dependencies[rule["destination"]]): found = False if "dependencies" in branch: for dep2 in branch["dependencies"]: @@ -84,12 +85,12 @@ def main(): found = True else: raise Exception( - "destination %s does not have any dependencies (looking for %s)" % (rule["destination"], dep)) + "Please add %s as dependencies under destination %s in %s" % (gomod_dependencies[rule["destination"]], rule["destination"], rules_file)) if not found: - raise Exception("destination %s does not have dependency %s" % (rule["destination"], dep)) + raise Exception("Please add %s as a dependency under destination %s in %s" % (dep, rule["destination"], rules_file)) else: print(" found dependency %s" % dep) - items = set(godep_dependencies.keys()) - set(processed_repos) + items = set(gomod_dependencies.keys()) - set(processed_repos) if len(items) > 0: raise Exception("missing rules for %s" % ','.join(str(s) for s in items)) print("Done.")