Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor go dependencies to a separate bzl file #936

Merged
merged 6 commits into from
Jun 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 77 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,21 @@ docker_toolchain_configure(
client_config="/path/to/docker/client/config",
)

# This is NOT needed when going through the language lang_image
# "repositories" function(s).
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)
container_repositories()

# This is NOT needed when going through the language lang_image
# "repositories" function(s).
load(
"@io_bazel_rules_docker//repositories:go_repositories.bzl",
container_go_deps = "go_deps",
)

container_go_deps()

load(
"@io_bazel_rules_docker//container:container.bzl",
"container_pull",
Expand Down Expand Up @@ -325,6 +332,13 @@ for more details.
To use `cc_image`, add the following to `WORKSPACE`:

```python
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//cc:image.bzl",
_cc_image_repos = "repositories",
Expand Down Expand Up @@ -375,6 +389,13 @@ and see <a href=#go_image-custom-base>go_image (custom base)</a> example below.
To use `py_image`, add the following to `WORKSPACE`:

```python
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//python:image.bzl",
_py_image_repos = "repositories",
Expand Down Expand Up @@ -518,7 +539,13 @@ npm_install(
package_json = "//:package.json",
)

# Download base images, etc.
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//nodejs:image.bzl",
_nodejs_image_repos = "repositories",
Expand Down Expand Up @@ -558,16 +585,13 @@ To use `go_image`, add the following to `WORKSPACE`:
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# You *must* import the Go rules before setting up the go_image rules.
http_archive(
name = "io_bazel_rules_go",
# Replace with a real SHA256 checksum
sha256 = "{SHA256}"
# Replace with a real commit SHA
strip_prefix = "rules_go-{HEAD}",
urls = ["https://github.com/bazelbuild/rules_go/archive/{HEAD}.tar.gz"],
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//go:image.bzl",
_go_image_repos = "repositories",
Expand Down Expand Up @@ -662,6 +686,13 @@ go_image(
To use `java_image`, add the following to `WORKSPACE`:

```python
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//java:image.bzl",
_java_image_repos = "repositories",
Expand Down Expand Up @@ -694,6 +725,13 @@ and see <a href=#go_image-custom-base>go_image (custom base)</a> example.
To use `war_image`, add the following to `WORKSPACE`:

```python
load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//java:image.bzl",
_java_image_repos = "repositories",
Expand Down Expand Up @@ -752,6 +790,13 @@ load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")

scala_repositories()

load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//scala:image.bzl",
_scala_image_repos = "repositories",
Expand Down Expand Up @@ -802,6 +847,13 @@ load("@io_bazel_rules_groovy//groovy:groovy.bzl", "groovy_repositories")

groovy_repositories()

load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//groovy:image.bzl",
_groovy_image_repos = "repositories",
Expand Down Expand Up @@ -852,6 +904,13 @@ load("@io_bazel_rules_rust//rust:repositories.bzl", "rust_repositories")

rust_repositories()

load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//rust:image.bzl",
_rust_image_repos = "repositories",
Expand Down Expand Up @@ -901,6 +960,13 @@ load("@io_bazel_rules_d//d:d.bzl", "d_repositories")

d_repositories()

load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)

container_repositories()

load(
"@io_bazel_rules_docker//d:image.bzl",
_d_image_repos = "repositories",
Expand Down
39 changes: 7 additions & 32 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ load(

container_repositories()

load(
"//repositories:go_repositories.bzl",
container_go_deps = "go_deps",
)

container_go_deps()

load(
"//container:new_pull.bzl",
"new_container_pull",
Expand Down Expand Up @@ -253,26 +260,6 @@ load("@io_bazel_rules_groovy//groovy:groovy.bzl", "groovy_repositories")

groovy_repositories()

# For our go_image test.
http_archive(
name = "io_bazel_rules_go",
sha256 = "f04d2373bcaf8aa09bccb08a98a57e721306c8f6043a2a0ee610fd6853dcde3d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz",
"https://github.com/bazelbuild/rules_go/releases/download/0.18.6/rules_go-0.18.6.tar.gz",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains()

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")

gazelle_dependencies()

# Have the go_image dependencies for testing.
load(
"//go:image.bzl",
Expand Down Expand Up @@ -388,15 +375,3 @@ rbe_autoconfig(
)

# gazelle:repo bazel_gazelle

go_repository(
name = "com_github_google_go_containerregistry",
commit = "6991786f93129be24f857070fe94754a9ea02a0a",
importpath = "github.com/google/go-containerregistry",
)

go_repository(
name = "com_github_pkg_errors",
commit = "27936f6d90f9c8e1145f11ed52ffffbfdb9e0af7",
importpath = "github.com/pkg/errors",
)
8 changes: 4 additions & 4 deletions cc/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ load(
"app_layer",
)
load(
"//repositories:repositories.bzl",
_repositories = "repositories",
"//repositories:go_repositories.bzl",
_go_deps = "go_deps",
)

# Load the resolved digests.
Expand All @@ -35,10 +35,10 @@ load(":cc.bzl", "DIGESTS")
def repositories():
"""Import the dependencies for the cc_image rule.

Call the core "repositories" function to reduce boilerplate. This is
Call the core "go_deps" function to reduce boilerplate. This is
idempotent if folks call it themselves.
"""
_repositories()
_go_deps()

excludes = native.existing_rules().keys()
if "cc_image_base" not in excludes:
Expand Down
2 changes: 1 addition & 1 deletion container/go/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# This cloudbuild.yaml file is used to release the go puller binary.

timeout: 21600s
timeout: 3600s
options:
machineType: "N1_HIGHCPU_32"

Expand Down
8 changes: 4 additions & 4 deletions go/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ load(
"app_layer",
)
load(
"//repositories:repositories.bzl",
_repositories = "repositories",
"//repositories:go_repositories.bzl",
_go_deps = "go_deps",
)

# Load the resolved digests.
Expand All @@ -39,10 +39,10 @@ load(":go.bzl", "DIGESTS")
def repositories():
"""Import the dependencies of the go_image rule.

Call the core "repositories" function to reduce boilerplate. This is
Call the core "go_deps" function to reduce boilerplate. This is
idempotent if folks call it themselves.
"""
_repositories()
_go_deps()
nlopezgi marked this conversation as resolved.
Show resolved Hide resolved

excludes = native.existing_rules().keys()
if "go_image_base" not in excludes:
Expand Down
8 changes: 4 additions & 4 deletions java/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ load(
lang_image = "image",
)
load(
"//repositories:repositories.bzl",
_repositories = "repositories",
"//repositories:go_repositories.bzl",
_go_deps = "go_deps",
)

# Load the resolved digests.
Expand All @@ -48,10 +48,10 @@ load(
def repositories():
"""Import the dependencies of the java_image rule.

Call the core "repositories" function to reduce boilerplate. This is
Call the core "go_deps" function to reduce boilerplate. This is
idempotent if folks call it themselves.
"""
_repositories()
_go_deps()

excludes = native.existing_rules().keys()
if "java_image_base" not in excludes:
Expand Down
8 changes: 4 additions & 4 deletions nodejs/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ load(
lang_image = "image",
)
load(
"//repositories:repositories.bzl",
_repositories = "repositories",
"//repositories:go_repositories.bzl",
_go_deps = "go_deps",
)

# Load the resolved digests.
Expand All @@ -38,10 +38,10 @@ load(":nodejs.bzl", "DIGESTS")
def repositories():
"""Import the dependencies of the nodejs_image rule.

Call the core "repositories" function to reduce boilerplate. This is
Call the core "go_deps" function to reduce boilerplate. This is
idempotent if folks call it themselves.
"""
_repositories()
_go_deps()

excludes = native.existing_rules().keys()
if "nodejs_image_base" not in excludes:
Expand Down
8 changes: 4 additions & 4 deletions python/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ load(
"filter_layer",
)
load(
"//repositories:repositories.bzl",
_repositories = "repositories",
"//repositories:go_repositories.bzl",
_go_deps = "go_deps",
)

# Load the resolved digests.
Expand All @@ -36,10 +36,10 @@ load(":python.bzl", "DIGESTS")
def repositories():
"""Import the dependencies of the py_image rule.

Call the core "repositories" function to reduce boilerplate. This is
Call the core "go_deps" function to reduce boilerplate. This is
idempotent if folks call it themselves.
"""
_repositories()
_go_deps()

# Register the default py_toolchain for containerized execution
native.register_toolchains("@io_bazel_rules_docker//toolchains/python:container_py_toolchain")
Expand Down
8 changes: 4 additions & 4 deletions python3/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ load(
"app_layer",
)
load(
"//repositories:repositories.bzl",
_repositories = "repositories",
"//repositories:go_repositories.bzl",
_go_deps = "go_deps",
)

# Load the resolved digests.
Expand All @@ -35,10 +35,10 @@ load(":python3.bzl", "DIGESTS")
def repositories():
"""Import the dependencies of the py3_image rule.

Call the core "repositories" function to reduce boilerplate. This is
Call the core "go_deps" function to reduce boilerplate. This is
idempotent if folks call it themselves.
"""
_repositories()
_go_deps()

# Register the default py_toolchain for containerized execution
native.register_toolchains("@io_bazel_rules_docker//toolchains/python:container_py_toolchain")
Expand Down
Loading