Skip to content

Commit d474631

Browse files
committed
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.
1 parent e9ca60b commit d474631

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

hack/verify-publishing-bot.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import yaml
2424

2525

26-
def get_godeps_dependencies(rootdir, components):
26+
def get_gomod_dependencies(rootdir, components):
2727
all_dependencies = {}
2828
for component in components:
2929
with open(os.path.join(rootdir, component, "go.mod")) as f:
@@ -58,8 +58,9 @@ def main():
5858
components.append(component)
5959
components.sort()
6060

61-
godep_dependencies = get_godeps_dependencies(rootdir + '/staging/src/k8s.io/', components)
62-
rules_dependencies = get_rules_dependencies(rootdir + "/staging/publishing/rules.yaml")
61+
rules_file = "/staging/publishing/rules.yaml"
62+
gomod_dependencies = get_gomod_dependencies(rootdir + '/staging/src/k8s.io/', components)
63+
rules_dependencies = get_rules_dependencies(rootdir + rules_file)
6364

6465
processed_repos = []
6566
for rule in rules_dependencies["rules"]:
@@ -70,10 +71,10 @@ def main():
7071
raise Exception("cannot find master source branch for destination %s" % rule["destination"])
7172

7273
print("processing : %s" % rule["destination"])
73-
if rule["destination"] not in godep_dependencies:
74-
raise Exception("missing Godeps.json for %s" % rule["destination"])
74+
if rule["destination"] not in gomod_dependencies:
75+
raise Exception("missing go.mod for %s" % rule["destination"])
7576
processed_repos.append(rule["destination"])
76-
for dep in set(godep_dependencies[rule["destination"]]):
77+
for dep in set(gomod_dependencies[rule["destination"]]):
7778
found = False
7879
if "dependencies" in branch:
7980
for dep2 in branch["dependencies"]:
@@ -84,12 +85,12 @@ def main():
8485
found = True
8586
else:
8687
raise Exception(
87-
"destination %s does not have any dependencies (looking for %s)" % (rule["destination"], dep))
88+
"Please add %s as dependencies under destination %s in %s" % (gomod_dependencies[rule["destination"]], rule["destination"], rules_file))
8889
if not found:
89-
raise Exception("destination %s does not have dependency %s" % (rule["destination"], dep))
90+
raise Exception("Please add %s as a dependency under destination %s in %s" % (dep, rule["destination"], rules_file))
9091
else:
9192
print(" found dependency %s" % dep)
92-
items = set(godep_dependencies.keys()) - set(processed_repos)
93+
items = set(gomod_dependencies.keys()) - set(processed_repos)
9394
if len(items) > 0:
9495
raise Exception("missing rules for %s" % ','.join(str(s) for s in items))
9596
print("Done.")

0 commit comments

Comments
 (0)