Skip to content

Commit

Permalink
Add Ytt toolchain. (#1)
Browse files Browse the repository at this point in the history
* Use Ytt tool as a toolchain.
* Clean up dependencies.
* Bumped Ytt version: 0.45.0 => 0.46.2.
* Use Bazel 6.4.0.
* Deprecate `image` attribute.
* Change the repo structure.
* Update tests.
  • Loading branch information
ekhabarov authored Dec 9, 2023
1 parent 5462454 commit 20c0521
Show file tree
Hide file tree
Showing 30 changed files with 421 additions and 2,193 deletions.
3 changes: 0 additions & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
build --verbose_failures
test --test_output=errors

try-import %workspace%/.bazelrc.local

2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.1
6.4.0
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,35 @@ Add to `WORKSPACE` file.
```starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# The actual snippet see in Releases.
http_archive(
name = "com_github_ebay_rules_ytt",
sha256 = "0232522fd7a07d2eb0a47fe4ec3a6dc8bc8e0bcbaa8abd658c6be53a34f5bd76",
strip_prefix = "rules_ytt-0.1.0",
name = "rules_ytt",
sha256 = "<sha256>",
strip_prefix = "rules_ytt-X.Y.Z",
urls = [
"https://github.com/eBay/rules_ytt/releases/download/v0.1.0/rules_ytt-0.1.0.zip",
"https://github.com/ekhabarov/rules_ytt/releases/download/vX.Y.X/rules_ytt-X.Y.Z.zip",
],
)

load("@com_github_ebay_rules_ytt//:deps.bzl", "ytt_rules_dependencies")
load("@rules_ytt//ytt:repositories.bzl",
"rules_ytt_dependencies",
"ytt_register_toolchains",
)

rules_ytt_dependencies()

ytt_rules_dependencies()
ytt_register_toolchains()
```

## Usage

Add to `BUILD` file:

```starlark
load("@com_github_ebay_rules_ytt//:def.bzl", "ytt")
load("@rules_ytt//:defs.bzl", "ytt")

# Build an image with rules_docker

load("@io_bazel_rules_docker//go:image.bzl", "go_image")

go_image(
Expand All @@ -34,13 +43,26 @@ go_image(
importpath = "...",
)

# or with rules_oci

load("@rules_oci//oci:defs.bzl", "oci_image")

oci_image(
name = "image",
...
)

# Generate YAML manifests

ytt(
name = "manifests",
srcs = [
":base.yaml",
":defaults.yaml",
":values.yaml",
],
# or
# srcs = glob(["*.yaml"]),
image = ":image.digest",
)
```
Expand All @@ -57,10 +79,6 @@ ytt -f base.yaml -f defaults.yaml -f values.yaml --dangerous-allow-all-symlink-d

Image digest is available inside yaml templates as `data.values.image_digest`.

## Commands

[Here](./ytt.md)

## LICENSE

Copyright 2023 eBay Inc. Developer: Evgeny Khabarov
Expand Down
40 changes: 8 additions & 32 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
workspace(name = "com_github_ebay_rules_ytt")
workspace(name = "rules_ytt")

load(":deps.bzl", "ytt_rules_dependencies")

ytt_rules_dependencies()

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

go_rules_dependencies()

go_register_toolchains(version = "1.20.3")

load("@io_bazel_stardoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

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

load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
load("//ytt:repositories.bzl",
"rules_ytt_dependencies",
"rules_ytt_internal_dependencies",
"ytt_register_toolchains",
)

container_repositories()

load("@io_bazel_rules_docker//go:image.bzl", _go_image_repos = "repositories")
rules_ytt_dependencies()

_go_image_repos()
rules_ytt_internal_dependencies()

ytt_register_toolchains()
Loading

0 comments on commit 20c0521

Please sign in to comment.