Skip to content

Commit

Permalink
feat(instill): send requester UID, if present, on model trigger (#202)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jvallesm committed Jul 8, 2024
1 parent 0d08912 commit 31422cd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion ai/instill/v0/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down

0 comments on commit 31422cd

Please sign in to comment.