23
23
import yaml
24
24
25
25
26
- def get_godeps_dependencies (rootdir , components ):
26
+ def get_gomod_dependencies (rootdir , components ):
27
27
all_dependencies = {}
28
28
for component in components :
29
29
with open (os .path .join (rootdir , component , "go.mod" )) as f :
@@ -58,8 +58,9 @@ def main():
58
58
components .append (component )
59
59
components .sort ()
60
60
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 )
63
64
64
65
processed_repos = []
65
66
for rule in rules_dependencies ["rules" ]:
@@ -70,10 +71,10 @@ def main():
70
71
raise Exception ("cannot find master source branch for destination %s" % rule ["destination" ])
71
72
72
73
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" ])
75
76
processed_repos .append (rule ["destination" ])
76
- for dep in set (godep_dependencies [rule ["destination" ]]):
77
+ for dep in set (gomod_dependencies [rule ["destination" ]]):
77
78
found = False
78
79
if "dependencies" in branch :
79
80
for dep2 in branch ["dependencies" ]:
@@ -84,12 +85,12 @@ def main():
84
85
found = True
85
86
else :
86
87
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 ))
88
89
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 ))
90
91
else :
91
92
print (" found dependency %s" % dep )
92
- items = set (godep_dependencies .keys ()) - set (processed_repos )
93
+ items = set (gomod_dependencies .keys ()) - set (processed_repos )
93
94
if len (items ) > 0 :
94
95
raise Exception ("missing rules for %s" % ',' .join (str (s ) for s in items ))
95
96
print ("Done." )
0 commit comments