Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Remove python resolver (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
smukherj1 authored and rbe-toolchains-pr-bot committed Oct 29, 2019
1 parent 673d896 commit 80a1b55
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 476 deletions.
38 changes: 0 additions & 38 deletions k8s/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,6 @@ exports_files([
"describe.sh.tpl",
])

py_library(
name = "resolver_lib",
srcs = [
"__init__.py",
"resolver.py",
"//:__init__.py",
],
deps = [
"@com_github_yaml_pyyaml//:yaml",
"@containerregistry",
],
)

py_test(
name = "resolver_test",
srcs = ["resolver_test.py"],
data = [
"//examples/hellogrpc/cc/server:server.tar",
],
python_version = "PY2",
deps = [
":resolver_lib",
"@mock",
],
)

par_binary(
name = "resolver",
srcs = ["resolver.py"],
main = "resolver.py",
python_version = "PY2",
visibility = ["//visibility:public"],
deps = [
"@com_github_yaml_pyyaml//:yaml",
"@containerregistry",
],
)

par_binary(
name = "stamper",
srcs = ["stamper.py"],
Expand Down
6 changes: 3 additions & 3 deletions k8s/k8s.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ py_library(
if "io_bazel_rules_docker" not in excludes:
http_archive(
name = "io_bazel_rules_docker",
sha256 = "5fcad5748a03d961c457ae15348684aa6eceb8f1cd6ae5fd7271fb5a271acdaf",
strip_prefix = "rules_docker-7476c25fcf188dbfc4eb154ad309eda7df24652c",
urls = ["https://github.com/bazelbuild/rules_docker/archive/7476c25fcf188dbfc4eb154ad309eda7df24652c.tar.gz"],
sha256 = "14ac30773fdb393ddec90e158c9ec7ebb3f8a4fd533ec2abbfd8789ad81a284b",
strip_prefix = "rules_docker-0.12.1",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.12.1/rules_docker-v0.12.1.tar.gz"],
)
if "bazel_skylib" not in excludes:
http_archive(
Expand Down
47 changes: 14 additions & 33 deletions k8s/object.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,17 @@ def _impl(ctx):
image_spec["digest"] = ",".join([_runfiles(ctx, f) for f in blobsums])
all_inputs += blobsums

if not ctx.attr.use_legacy_resolver:
# Add additional files about the image used by the Go resolver
# to load the image more efficiently.
diff_ids = image.get("diff_id", [])
image_spec["diff_id"] = ",".join([_runfiles(ctx, f) for f in diff_ids])
all_inputs += diff_ids

blobs = image.get("zipped_layer", [])
image_spec["compressed_layer"] = ",".join([_runfiles(ctx, f) for f in blobs])
all_inputs += blobs

uncompressed_blobs = image.get("unzipped_layer", [])
image_spec["uncompressed_layer"] = ",".join([_runfiles(ctx, f) for f in uncompressed_blobs])
all_inputs += uncompressed_blobs
else:
blobs = image.get("zipped_layer", [])
image_spec["layer"] = ",".join([_runfiles(ctx, f) for f in blobs])
all_inputs += blobs
diff_ids = image.get("diff_id", [])
image_spec["diff_id"] = ",".join([_runfiles(ctx, f) for f in diff_ids])
all_inputs += diff_ids

blobs = image.get("zipped_layer", [])
image_spec["compressed_layer"] = ",".join([_runfiles(ctx, f) for f in blobs])
all_inputs += blobs

uncompressed_blobs = image.get("unzipped_layer", [])
image_spec["uncompressed_layer"] = ",".join([_runfiles(ctx, f) for f in uncompressed_blobs])
all_inputs += uncompressed_blobs

image_spec["config"] = _runfiles(ctx, image["config"])
all_inputs += [image["config"]]
Expand Down Expand Up @@ -136,7 +129,7 @@ def _impl(ctx):
for spec in image_specs
]),
"%{resolver_args}": " ".join(ctx.attr.resolver_args or []),
"%{resolver}": _runfiles(ctx, ctx.executable.resolver if ctx.attr.use_legacy_resolver else ctx.executable.go_resolver),
"%{resolver}": _runfiles(ctx, ctx.executable.resolver),
"%{stamp_args}": stamp_args,
"%{yaml}": _runfiles(ctx, ctx.outputs.substituted),
},
Expand All @@ -148,7 +141,6 @@ def _impl(ctx):
runfiles = ctx.runfiles(
files = [
ctx.executable.resolver,
ctx.executable.go_resolver,
ctx.outputs.substituted,
] + all_inputs,
transitive_files = ctx.attr.resolver[DefaultInfo].default_runfiles.files,
Expand All @@ -172,7 +164,7 @@ def _resolve(ctx, string, output):
)

def _common_impl(ctx):
files = [ctx.executable.resolver, ctx.executable.go_resolver]
files = [ctx.executable.resolver]

cluster_arg = ctx.attr.cluster
cluster_arg = ctx.expand_make_variables("cluster", cluster_arg, {})
Expand Down Expand Up @@ -272,12 +264,6 @@ _common_attrs = {
# don't expose the extra actions.
"cluster": attr.string(),
"context": attr.string(),
"go_resolver": attr.label(
default = Label("//k8s/go/cmd/resolver"),
cfg = "host",
executable = True,
allow_files = True,
),
"image_chroot": attr.string(),
# This is only needed for describe.
"kind": attr.string(),
Expand All @@ -286,18 +272,13 @@ _common_attrs = {
),
"namespace": attr.string(),
"resolver": attr.label(
default = Label("//k8s:resolver"),
default = Label("//k8s/go/cmd/resolver"),
cfg = "host",
executable = True,
allow_files = True,
),
# Extra arguments to pass to the resolver.
"resolver_args": attr.string_list(),
"use_legacy_resolver": attr.bool(
default = False,
doc = "Use the legacy python resolver if True. Use the experimental" +
" Go resolver if false.",
),
"user": attr.string(),
"_stamper": attr.label(
default = Label("//k8s:stamper"),
Expand Down
242 changes: 0 additions & 242 deletions k8s/resolver.py

This file was deleted.

0 comments on commit 80a1b55

Please sign in to comment.