Update hack scripts to use go mod

This commit is contained in:
Jordan Liggitt
2019-03-04 00:27:03 -05:00
parent 7f246d461b
commit 2ea3cbdcbc
24 changed files with 596 additions and 629 deletions

View File

@@ -23,18 +23,23 @@ import json
import yaml
def get_godeps_dependencies(godeps):
def get_godeps_dependencies(rootdir, components):
all_dependencies = {}
for arg in godeps:
with open(arg) as f:
data = json.load(f)
dependencies = []
for dep in data["Deps"]:
if dep['Rev'].startswith('xxxx') and dep['ImportPath'].startswith("k8s.io"):
package = "/".join(dep['ImportPath'].split('/')[0:2])
if package not in dependencies:
dependencies.append(package.split('/')[1])
all_dependencies[(data["ImportPath"].split('/')[1])] = dependencies
for component in components:
with open(os.path.join(rootdir, component, "go.mod")) as f:
print(component + " dependencies")
all_dependencies[component] = []
lines = list(set(f))
lines.sort()
for line in lines:
for dep in components:
if dep == component:
continue
if ("k8s.io/" + dep + " v0.0.0") not in line:
continue
print("\t"+dep)
if dep not in all_dependencies[component]:
all_dependencies[component].append(dep)
return all_dependencies
@@ -48,12 +53,12 @@ def main():
rootdir = os.path.dirname(__file__) + "/../"
rootdir = os.path.abspath(rootdir)
godeps = []
for root, dirnames, filenames in os.walk(rootdir + '/staging/'):
for filename in fnmatch.filter(filenames, 'Godeps.json'):
godeps.append(os.path.join(root, filename))
components = []
for component in os.listdir(rootdir + '/staging/src/k8s.io/'):
components.append(component)
components.sort()
godep_dependencies = get_godeps_dependencies(godeps)
godep_dependencies = get_godeps_dependencies(rootdir + '/staging/src/k8s.io/', components)
rules_dependencies = get_rules_dependencies(rootdir + "/staging/publishing/rules.yaml")
processed_repos = []