From 31422cda00c507e6a53a3f288de16dba2ca9e6cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Vall=C3=A9s?= <3977183+jvallesm@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:26:09 +0200 Subject: [PATCH] feat(instill): send requester UID, if present, on model trigger (#202) Because - Instill Model will [use the requester UID,](https://github.com/instill-ai/model-backend/pull/619/files) when present, in model execution. This commit - Adds the requester header to the trigger model call in the `instill` component. --- ai/instill/v0/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ai/instill/v0/main.go b/ai/instill/v0/main.go index 5aa87541..f1332e1e 100644 --- a/ai/instill/v0/main.go +++ b/ai/instill/v0/main.go @@ -68,6 +68,10 @@ func getInstillUserUID(vars map[string]any) string { return vars["__PIPELINE_USER_UID"].(string) } +func getInstillRequesterUID(vars map[string]any) string { + return vars["__PIPELINE_REQUESTER_UID"].(string) +} + func getModelServerURL(vars map[string]any) string { if v, ok := vars["__MODEL_BACKEND"]; ok { return v.(string) @@ -83,11 +87,17 @@ func getMgmtServerURL(vars map[string]any) string { } func getRequestMetadata(vars map[string]any) metadata.MD { - return metadata.Pairs( + md := metadata.Pairs( "Authorization", getHeaderAuthorization(vars), "Instill-User-Uid", getInstillUserUID(vars), "Instill-Auth-Type", "user", ) + + if requester := getInstillRequesterUID(vars); requester != "" { + md.Set("Instill-Requester-Uid", requester) + } + + return md } func (e *execution) Execute(ctx context.Context, inputs []*structpb.Struct) ([]*structpb.Struct, error) {