Fix Label() usage in genrule_repository (#18711)
Fix Label() usage in genrule_repository (#18711)

Bazel pre-5.0 had a bug where the Label() function, when called from
a WORKSPACE-loaded .bzl file, used no repo mapping. This meant that
the previous logic here calling `Label("@envoy//bazel")` did not
actually recognize that `@envoy` referred to the main repo; it just
considered it "some repo called 'envoy'".

Bazel 5.0 fixes the bug so that this call will recognize that fact,
and hence turn the label into just `//bazel` since `@envoy` is the
main repo. This, however, causes the lookup in `genrule_cmd(label)`
to fail. This commit fixes that by using the Label object itself as
the key in the dict, instead of a string representation, so that
it's always comparing the resolved target label.

I also took this opportunity to fix the weird `ctx.execute("cat")`
workaround, now that we have `ctx.read`.

Signed-off-by: Xudong Yang <be0664aebb38b61a3b1788a4d5408b90e0be220d@google.com>
envoyproxy/envoy,envoyproxy/envoy,envoyproxy/envoy,lyft/envoy,envoyproxy/envoy,envoyproxy/envoy,lyft/envoy,lyft/envoy,envoyproxy/envoy,envoyproxy/envoy,envoyproxy/envoy,lyft/envoy,envoyproxy/envoy,envoyproxy/envoy,envoyproxy/envoy,lyft/envoy,lyft/envoy,envoyproxy/envoy