2

I have several k8s_object rules in my project and I supply each of them with the same cluster name like this:

k8s_object(
  name = "k8s_service",
  kind = "service",
  cluster = "gke_cents-ideas_europe-west3-b_cents-ideas",
  template = ":gateway.service.yaml",
)

So whenever I want to change the cluster name, I have to change it in many different places.

Goal

I would prefer to set the cluster name in a .env file like this:

KUBERNETES_CLUSTER=my-cluster-name

and let Bazel automatically pick up this value.

Florian Ludewig
  • 4,338
  • 11
  • 71
  • 137

1 Answers1

1

https://docs.bazel.build/versions/2.0.0/skylark/tutorial-sharing-variables.html

Create a .bzl file in which you can declare a variable. Import this bzl file in all BUILD files referencing the variable.

Sagre
  • 462
  • 3
  • 12