11package kubeinteraction
22
33import (
4- "context"
54 "fmt"
65 "strconv"
76
87 "github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode"
98 "github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode/keys"
109 apipac "github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode/v1alpha1"
1110 "github.com/openshift-pipelines/pipelines-as-code/pkg/formatting"
11+ "github.com/openshift-pipelines/pipelines-as-code/pkg/params"
1212 "github.com/openshift-pipelines/pipelines-as-code/pkg/params/info"
1313 "github.com/openshift-pipelines/pipelines-as-code/pkg/params/version"
1414 tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
@@ -21,13 +21,13 @@ const (
2121 StateFailed = "failed"
2222)
2323
24- func AddLabelsAndAnnotations (ctx context. Context , event * info.Event , pipelineRun * tektonv1.PipelineRun , repo * apipac.Repository , providerinfo * info.ProviderConfig ) error {
24+ func AddLabelsAndAnnotations (event * info.Event , pipelineRun * tektonv1.PipelineRun , repo * apipac.Repository , providerConfig * info.ProviderConfig , paramsRun * params. Run ) error {
2525 if event == nil {
2626 return fmt .Errorf ("event should not be nil" )
2727 }
28- // Add labels on the soon to be created pipelinerun so UI/CLI can easily
28+ paramsinfo := paramsRun .Info
29+ // Add labels on the soon-to-be created pipelinerun so UI/CLI can easily
2930 // query them.
30- paramsinfo := info .GetInfo (ctx , info .GetCurrentControllerName (ctx ))
3131 labels := map [string ]string {
3232 // These keys are used in LabelSelector query so we are keeping in Labels as it is.
3333 // But adding same keys to Annotations so UI/CLI can fetch the actual value instead of modified value
@@ -44,7 +44,7 @@ func AddLabelsAndAnnotations(ctx context.Context, event *info.Event, pipelineRun
4444 // In PAC v0.20.x releases we will remove these keys from Labels
4545 keys .Sender : formatting .CleanValueKubernetes (event .Sender ),
4646 keys .Branch : formatting .CleanValueKubernetes (event .BaseBranch ),
47- keys .GitProvider : providerinfo .Name ,
47+ keys .GitProvider : providerConfig .Name ,
4848 }
4949
5050 annotations := map [string ]string {
@@ -58,7 +58,7 @@ func AddLabelsAndAnnotations(ctx context.Context, event *info.Event, pipelineRun
5858 keys .EventType : event .EventType ,
5959 keys .Branch : event .BaseBranch ,
6060 keys .Repository : repo .GetName (),
61- keys .GitProvider : providerinfo .Name ,
61+ keys .GitProvider : providerConfig .Name ,
6262 keys .State : StateStarted ,
6363 keys .ControllerInfo : fmt .Sprintf (`{"name":"%s","configmap":"%s","secret":"%s"}` , paramsinfo .Controller .Name , paramsinfo .Controller .Configmap , paramsinfo .Controller .Secret ),
6464 }
@@ -69,7 +69,7 @@ func AddLabelsAndAnnotations(ctx context.Context, event *info.Event, pipelineRun
6969 }
7070
7171 // TODO: move to provider specific function
72- if providerinfo .Name == "github" || providerinfo .Name == "github-enterprise" {
72+ if providerConfig .Name == "github" || providerConfig .Name == "github-enterprise" {
7373 if event .InstallationID != - 1 {
7474 annotations [keys .InstallationID ] = strconv .FormatInt (event .InstallationID , 10 )
7575 }
0 commit comments