Last active
November 15, 2018 22:34
-
-
Save steeve/cb37a50196e076733755e2d0be6cccb2 to your computer and use it in GitHub Desktop.
Bazel + rules_jsonnet + ksonnet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load("@io_bazel_rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_to_json") | |
jsonnet_to_json( | |
name = "mytest", | |
src = "mytest.jsonnet", | |
outs = ["mytest.json"], | |
deps = ["@com_github_ksonnet_ksonnet_lib//:ksonnet.beta.2"], | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package(default_visibility = ["//visibility:public"]) | |
load("@io_bazel_rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_library") | |
[ | |
jsonnet_library( | |
name = "ksonnet.%s" % version, | |
imports = [""], | |
srcs = glob(["ksonnet.%s/**/*.libsonnet" % version]), | |
) | |
for version in ["alpha.1", "beta.1", "beta.2", "beta.3"] | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local k = import "ksonnet.beta.2/k.libsonnet"; | |
// Specify the import objects that we need | |
local container = k.extensions.v1beta1.deployment.mixin.spec.template.spec.containersType; | |
local containerPort = container.portsType; | |
local deployment = k.extensions.v1beta1.deployment; | |
local targetPort = 80; | |
local podLabels = {app: "nginx"}; | |
local nginxContainer = | |
container.new("nginx", "nginx:1.7.9") + | |
container.ports(containerPort.containerPort(targetPort)); | |
local nginxDeployment = | |
deployment.new("nginx-deployment", 2, nginxContainer, podLabels); | |
k.core.v1.list.new(nginxDeployment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | |
http_archive( | |
name = "io_bazel_rules_jsonnet", | |
urls = ["https://codeload.github.com/bazelbuild/rules_jsonnet/tar.gz/f0a8f80dac072d67aebccd8ffb34e0d8858c29f0"], | |
strip_prefix = "rules_jsonnet-f0a8f80dac072d67aebccd8ffb34e0d8858c29f0", | |
type = "tar.gz", | |
) | |
load("@io_bazel_rules_jsonnet//jsonnet:jsonnet.bzl", "jsonnet_repositories") | |
jsonnet_repositories() | |
http_archive( | |
name = "com_github_ksonnet_ksonnet_lib", | |
urls = ["https://codeload.github.com/ksonnet/ksonnet-lib/tar.gz/d03da231d6c8bd74437b74a1e9e8b966f13dffa2"], | |
strip_prefix = "ksonnet-lib-d03da231d6c8bd74437b74a1e9e8b966f13dffa2", | |
type = "tar.gz", | |
build_file = "//:third_party/com_github_ksonnet_ksonnet_lib/BUILD.bazel.in", | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment