Skip to content

Commit

Permalink
Add more tags for terraform image
Browse files Browse the repository at this point in the history
  • Loading branch information
HadrienPatte committed Nov 5, 2020
1 parent d6400ea commit 4809979
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 26 deletions.
9 changes: 3 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ container_pull(
repository = "distroless/static-debian10",
)

http_archive(
name = "terraform_0.13.0_linux_amd64",
build_file_content = "exports_files([\"terraform\"])",
sha256 = "9ed437560faf084c18716e289ea712c784a514bdd7f2796549c735d439dbe378",
urls = ["https://releases.hashicorp.com/terraform/0.13.0/terraform_0.13.0_linux_amd64.zip"],
)
load("//terraform:terraform.bzl", "terraform_binaries")

terraform_binaries()
22 changes: 2 additions & 20 deletions terraform/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")
load(":terraform.bzl", "terraform_images")

container_image(
name = "0.13.0",
base = "@distroless//image",
cmd = "help",
directory = "/bin/",
entrypoint = ["/bin/terraform"],
files = ["@terraform_0.13.0_linux_amd64//:terraform"],
mode = "0o755",
repository = "quay.io/hadrienpatte",
)

container_push(
name = "0.13.0_push",
format = "Docker",
image = ":0.13.0",
registry = "quay.io",
repository = "hadrienpatte/{}".format(package_name()),
tag = "0.13.0",
)
terraform_images()
54 changes: 54 additions & 0 deletions terraform/terraform.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@io_bazel_rules_docker//container:container.bzl", "container_image", "container_push")

TERRAFORM_RELEASES = [
{
"version": "0.13.5",
"sha256": "f7b7a7b1bfbf5d78151cfe3d1d463140b5fd6a354e71a7de2b5644e652ca5147",
},
{
"version": "0.13.4",
"sha256": "a92df4a151d390144040de5d18351301e597d3fae3679a814ea57554f6aa9b24",
},
{
"version": "0.13.3",
"sha256": "35c662be9d32d38815cde5fa4c9fa61a3b7f39952ecd50ebf92fd1b2ddd6109b",
},
{
"version": "0.13.0",
"sha256": "9ed437560faf084c18716e289ea712c784a514bdd7f2796549c735d439dbe378",
},
]

def terraform_binaries():
for release in TERRAFORM_RELEASES:
maybe(
http_archive,
name = "terraform_{}_linux_amd64".format(release["version"]),
build_file_content = "exports_files([\"terraform\"])",
sha256 = release["sha256"],
urls = ["https://releases.hashicorp.com/terraform/{}/terraform_{}_linux_amd64.zip".format(release["version"], release["version"])],
)

def terraform_images():
for release in TERRAFORM_RELEASES:
container_image(
name = release["version"],
base = "@distroless//image",
cmd = "help",
directory = "/bin/",
entrypoint = ["/bin/terraform"],
files = ["@terraform_{}_linux_amd64//:terraform".format(release["version"])],
mode = "0o755",
repository = "quay.io/hadrienpatte",
)

container_push(
name = "{}_push".format(release["version"]),
format = "Docker",
image = ":{}".format(release["version"]),
registry = "quay.io",
repository = "hadrienpatte/terraform",
tag = release["version"],
)

0 comments on commit 4809979

Please sign in to comment.