feat(grpc): allow files to be read by add_metadata_jmespath_expression - #263
Conversation
|
2545ed4 to
11c2e5a
Compare
|
Hey Thomas, I'd be open to having a feature like this, but I do think that if we add it, it shouldn't be restricted to just this single place. What makes this place so special that we may accept files, while others cannot? There are also some features related to JMESPath that we should eventually consider adding. For example, it would be nice if any JMESPath expression in config may be accompanied with test vectors that are validated during startup. What are your thoughts on adding a message File {
...
}
// No need to add it now, but would be logical to provide eventually:
message TestVector {
google.protobuf.Value input = 1;
google.protobuf.Value expected_output = 2;
}
message Expression {
string expression = 1;
repeated File files = 2;
repeated TestVector test_vectors = 3;
}What are your thoughts on this? |
|
Hi Ed, That's true - there's nothing special about this. I like your idea. Are you happy for me to migrate all of them? I think this might be the existing list: I presume the intent is that all of those will change type to be |
|
Exactly! Feel free to change all of them. |
0e1a76d to
c4368a8
Compare
|
I've gone ahead and made this change, and I've also added the test vectors whilst I was at it. I'd find that useful. The code now optionally takes a program.Group. This is wired into a few places, but not into the overall grpc Client construction as that's a larger refactor. One thing to note here is that the Search function that I have exposed takes a |
be99295 to
8fba4a3
Compare
|
Thanks for the review - I've marked the conversations as resolved when I've done the corresponding thing. If you'd prefer a different workflow please let me know. |
c084f22 to
22ba9e1
Compare
a892e34 to
add8296
Compare
EdSchouten
left a comment
There was a problem hiding this comment.
Thanks for continuing to work on this, @tomgr!
add8296 to
712b2e1
Compare
EdSchouten
left a comment
There was a problem hiding this comment.
Hey Thomas,
Thanks again for working on this. I have one small comment, and once that's dealt with we can merge this.
This allows allow jmespath expressions to refer to the contents of
certain pre-declared files which are reloaded on a user-specified
schedule. For example, if you want to use k8s bound service
account tokens you could add the following to your Pod:
volumes:
- name: token-vol
projected:
sources:
- serviceAccountToken:
audience: my-buildbarn-instance
expirationSeconds: 3600
path: buildbarn
Assuming this is mounted at '/tokens', you could then specify in your
buildbarn config:
addMetadataJmespathExpression: {
expression: |||
{
"authorization": [std.format('bearer %s', files.token)]
}
|||,
files: [
{
key: "token",
path: "/tokens/buildbarn",
refreshInterval: "1800s",
}
]
},
This is quite useful for k8s service account tokens, as the maximum
validity is often capped. Likewise this can also be used for Google
service account id tokens, which also have a relatively short maximum
validity.
712b2e1 to
6877348
Compare

The motivation for this change is that I would like to be able k8s bound service account tokens and gcloud service account id tokens into outgoing grpc requests. However, these tokens often have relatively short maximum validities and therefore I need a way to get buildbarn to reload these periodically, like it does for TLS certificates. This PR implements a general file-based mechanism for injecting file contents into outgoing gRPC requests. This seemed to me like a reasonably general way of doing it, but it's just an initial idea -- I'm open to doing this in a different way.
This allows add_metadata_jmespath_expression to refer to the contents of certain pre-declared files which are reloaded on a user-specified schedule. For example, if you want to use k8s bound service account tokens you could add the following to your Pod:
Assuming this is mounted at '/tokens', you could then specify in your buildbarn config:
This is quite useful for k8s service account tokens, as the maximum validity is often capped. Likewise this can also be used for Google service account id tokens, which also have a relatively short maximum validity.