Skip to content

Commit

Permalink
publishing: use deps in replace directive in rules
Browse files Browse the repository at this point in the history
The list of dependencies for a repo right now is equal to the list of deps
mentioned in the require directive in the repo's go.mod file.
This means that we loose all transitive deps mentioned in the replace
directive in go.mod files.

So instead use all deps mentioned in the replace directive, and prune
any extra dependencies.

Also add a test for this in verify-publishing-bot.py
  • Loading branch information
nikhita committed Jun 24, 2019
1 parent 2109c1a commit ab3cdd5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
7 changes: 6 additions & 1 deletion hack/verify-publishing-bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_gomod_dependencies(rootdir, components):
for dep in components:
if dep == component:
continue
if ("k8s.io/" + dep + " v0.0.0") not in line:
if ("k8s.io/" + dep + " =>") not in line:
continue
print("\t"+dep)
if dep not in all_dependencies[component]:
Expand Down Expand Up @@ -80,10 +80,12 @@ def main():
if rule["destination"] not in gomod_dependencies:
raise Exception("missing go.mod for %s" % rule["destination"])
processed_repos.append(rule["destination"])
processed_deps = []
for dep in set(gomod_dependencies[rule["destination"]]):
found = False
if "dependencies" in branch:
for dep2 in branch["dependencies"]:
processed_deps.append(dep2["repository"])
if dep2["branch"] != "master":
raise Exception("Looking for master branch and found : %s for destination", dep2,
rule["destination"])
Expand All @@ -96,6 +98,9 @@ def main():
raise Exception("Please add %s as a dependency under destination %s in %s" % (dep, rule["destination"], rules_file))
else:
print(" found dependency %s" % dep)
extraDeps = set(processed_deps) - set(gomod_dependencies[rule["destination"]])
if len(extraDeps) > 0:
raise Exception("extra dependencies in rules for %s: %s" % (rule["destination"], ','.join(str(s) for s in extraDeps)))
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))
Expand Down
28 changes: 8 additions & 20 deletions staging/publishing/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ rules:
branch: master
- repository: code-generator
branch: master
- repository: component-base
branch: master
required-packages:
- k8s.io/code-generator
- source:
Expand All @@ -234,8 +232,6 @@ rules:
branch: release-12.0
- repository: code-generator
branch: release-1.15
- repository: component-base
branch: release-1.15
required-packages:
- k8s.io/code-generator
smoke-test: |
Expand Down Expand Up @@ -354,8 +350,6 @@ rules:
branch: master
- repository: client-go
branch: master
- repository: component-base
branch: master
- source:
branch: release-1.15
dir: staging/src/k8s.io/sample-cli-plugin
Expand All @@ -370,8 +364,6 @@ rules:
branch: release-1.15
- repository: client-go
branch: release-12.0
- repository: component-base
branch: release-1.15
- destination: kube-proxy
library: true
branches:
Expand Down Expand Up @@ -406,8 +398,6 @@ rules:
branch: master
- repository: api
branch: master
- repository: component-base
branch: master
- source:
branch: release-1.15
dir: staging/src/k8s.io/kubelet
Expand All @@ -418,8 +408,6 @@ rules:
branch: release-1.15
- repository: api
branch: release-1.15
- repository: component-base
branch: release-1.15
- destination: kube-scheduler
library: true
branches:
Expand All @@ -430,8 +418,6 @@ rules:
dependencies:
- repository: apimachinery
branch: master
- repository: apiserver
branch: master
- repository: component-base
branch: master
- source:
Expand All @@ -442,8 +428,6 @@ rules:
dependencies:
- repository: apimachinery
branch: release-1.15
- repository: apiserver
branch: release-1.15
- repository: component-base
branch: release-1.15
- destination: kube-controller-manager
Expand All @@ -456,8 +440,6 @@ rules:
dependencies:
- repository: apimachinery
branch: master
- repository: apiserver
branch: master
- repository: component-base
branch: master
- source:
Expand All @@ -468,8 +450,6 @@ rules:
dependencies:
- repository: apimachinery
branch: release-1.15
- repository: apiserver
branch: release-1.15
- repository: component-base
branch: release-1.15
- destination: cluster-bootstrap
Expand Down Expand Up @@ -532,6 +512,8 @@ rules:
branch: master
- repository: apimachinery
branch: master
- repository: client-go
branch: master
- repository: cloud-provider
branch: master
- source:
Expand All @@ -544,6 +526,8 @@ rules:
branch: release-1.15
- repository: apimachinery
branch: release-1.15
- repository: client-go
branch: release-12.0
- repository: cloud-provider
branch: release-1.15
- destination: legacy-cloud-providers
Expand Down Expand Up @@ -630,6 +614,8 @@ rules:
dir: staging/src/k8s.io/kubectl
name: master
dependencies:
- repository: api
branch: master
- repository: apimachinery
branch: master
- repository: client-go
Expand All @@ -640,6 +626,8 @@ rules:
name: release-1.15
go: 1.12.5
dependencies:
- repository: api
branch: release-1.15
- repository: apimachinery
branch: release-1.15
- repository: client-go
Expand Down

0 comments on commit ab3cdd5

Please sign in to comment.