Skip to content

Commit 7f53c16

Browse files
fix(ppl): Add label to schedule wf via api request (#436)
## 📝 Description branch "run" conditions rely of pipeline label to determine what is the current branhc, and we were not setting up labels at all when triggering wfs via API. renderedtext/tasks#8281 ## ✅ Checklist - [x] I have tested this change - [ ] This change requires documentation update
1 parent b8b892f commit 7f53c16

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

public-api/v1alpha/lib/pipelines_api/workflow_client/wf_request_formatter.ex

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ defmodule PipelinesAPI.WorkflowClient.WFRequestFormatter do
1414
def form_schedule_request(params) when is_map(params) do
1515
%{
1616
service: service_type(params["repository"].integration_type),
17+
label: params |> Map.get("reference", "") |> label(),
1718
repo: %{
1819
branch_name: params |> Map.get("reference", "") |> branch_name(),
1920
commit_sha: params |> Map.get("commit_sha", "")
@@ -59,6 +60,12 @@ defmodule PipelinesAPI.WorkflowClient.WFRequestFormatter do
5960
defp branch_name("refs/heads/" <> branch_name), do: branch_name
6061
defp branch_name(name), do: name
6162

63+
defp label(""), do: ""
64+
defp label("refs/tags/" <> tag), do: tag
65+
defp label("refs/pull/" <> number), do: number
66+
defp label("refs/heads/" <> branch_name), do: branch_name
67+
defp label(name), do: name
68+
6269
# Terminate
6370

6471
def form_terminate_request(wf_id, requester_id) when is_binary(wf_id) do

public-api/v1alpha/test/workflow_client_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ defmodule PipelinesAPI.WorkflowClient.Test do
5555

5656
assert {:ok, request} = WFRequestFormatter.form_schedule_request(params)
5757
assert request.service == ServiceType.value(:GIT_HUB)
58+
assert request.label == "main"
5859
assert request.repo.branch_name == "main"
5960
assert request.repo.commit_sha == "773d5c953bd68cc97efa81d2e014449336265fb4"
6061
assert {:ok, _} = UUID.info(request.request_token)

0 commit comments

Comments
 (0)