Skip to content

Commit

Permalink
Support kind blacklist in pruned deployments (#2551)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarketm authored Mar 25, 2020
1 parent 927b358 commit 7a9d5c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
7 changes: 2 additions & 5 deletions prow/Makefile.gcloud.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ configure-docker: activate-serviceaccount

get%api-resources:
$(eval PRUNE_WL=$(shell KUBECONFIG=$(KUBECONFIG) \
python3 "$(current_dir)/api-resources.py" \
--delimiter=" " \
--format="--prune-whitelist='%s'" \
--group-blacklist "authentication.k8s.io" "authorization.k8s.io"\
))
python3 "$(current_dir)/api-resources.py" --delimiter=" " --format="--prune-whitelist='%s'" \
))

get%cluster-credentials: save-kubeconfig activate-serviceaccount
gcloud container clusters get-credentials "$(CLUSTER)" --project="$(PROJECT)" --zone="$(ZONE)"
17 changes: 13 additions & 4 deletions prow/api-resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@ def fetch_versions():
return {}


def main(delimiter, format, group_blacklist):
def main(delimiter, format, group_blacklist, kind_blacklist):
resources = fetch_resources()
versions = fetch_versions()
group_blacklist = set(group_blacklist)
kind_blacklist = set(kind_blacklist)
r = []

for name, _, group, _, kind in resources:
if group in group_blacklist:
if kind in kind_blacklist or group in group_blacklist:
continue

for version in versions.get(group, []):
Expand All @@ -104,7 +106,7 @@ def main(delimiter, format, group_blacklist):
help="delimiter string for the list of api resources.",
)
parser.add_argument(
"--format", type=str, default="%s", help="format string for each api resources."
"--format", type=str, default="%s", help="format string for each api resource."
)
parser.add_argument(
"--group-blacklist",
Expand All @@ -113,5 +115,12 @@ def main(delimiter, format, group_blacklist):
default=["authentication.k8s.io", "authorization.k8s.io"],
help="set of api groups to blacklist.",
)
parser.add_argument(
"--kind-blacklist",
type=str,
nargs="*",
default=["Binding"],
help="set of api kinds to blacklist.",
)
args = parser.parse_args()
print(main(args.delimiter, args.format, args.group_blacklist))
print(main(args.delimiter, args.format, args.group_blacklist, args.kind_blacklist))

0 comments on commit 7a9d5c2

Please sign in to comment.