0

I'm new to Bazel so I would love some help with getting this working cross-platform

I have this code in BUILD.bazel. It seems to work fine on Linux and OSX, but it breaks for the devs who are using Windows as their dev environment.

I assume it has something to do with the fact that gcloud config is stored under %APPDATA%\gcloud on windows and ~/.config/gcloud on OSX/Linux. My best guess is that on OSX/Linux, Bazel moves the config into its own sandbox, but given that the gcloud config on windows is under %APPDATA%\gcloud it doesn't get included in the sandbox so gcloud always returns an error as it thinks there is no active account selected

BUILD.bazel


genrule(
    name = "auth_key_consumer",
    srcs = [],
    outs = ["auth_key_consumer.txt"],
    cmd = "gcloud secrets versions access projects/docs/secrets/td-build-auth-key-consumer/versions/latest > $@",
    tags = ["no-sandbox"],
)

nodejs_binary(
    name = "download_consumer",
    data = [
        ":auth_key_consumer",
        "@npm//tdbuild-lib",
    ],
    entry_point = ":download.js",
    env = {
        "AUTH_KEY_PATH": "$(rootpath :auth_key_consumer)",
    },
    templated_args = [
        "12345",
    ],
)

Error Message:

ERROR: (gcloud.secrets.versions.access) You do not currently have an active account selected.
Please run:

  $ gcloud auth login

to obtain new credentials.

If you have already logged in with a different account:

    $ gcloud config set account ACCOUNT

to select an already authenticated account to use.

When running gcloud auth list manually I do have an active account.

When running gcloud auth list via genrules in Bazel, there is no credentials

How do I include gcloud config inside Bazel? or if that is not the issue, how do I get gcloud working correctly on Windows platform

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
Tomasz Golinski
  • 743
  • 5
  • 25

0 Answers0