Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions pkg/reconciler/taskrun/resources/taskref.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ func GetTaskFunc(ctx context.Context, k8s kubernetes.Interface, tekton clientset
// It also requires a kubeclient, tektonclient, requester in case it needs to find that task in
// cluster or authorize against an external repository. It will figure out whether it needs to look in the cluster or in
// a remote location to fetch the reference.
func GetStepActionFunc(tekton clientset.Interface, k8s kubernetes.Interface, requester remoteresource.Requester, tr *v1.TaskRun, taskSpec v1.TaskSpec, step *v1.Step) GetStepAction {
func GetStepActionFunc(tekton clientset.Interface, k8s kubernetes.Interface, requester remoteresource.Requester, tr *v1.TaskRun, taskSpec v1.TaskSpec, step *v1.Step, taskNamespace string) GetStepAction {
trName := tr.Name
namespace := tr.Namespace
if step.Ref != nil && step.Ref.Resolver != "" && requester != nil {
// Return an inline function that implements GetStepAction by calling Resolver.Get with the specified StepAction type and
// casting it to a StepAction.
Expand All @@ -149,18 +148,18 @@ func GetStepActionFunc(tekton clientset.Interface, k8s kubernetes.Interface, req
ApplyParameterSubstitutionInResolverParams(tr, taskSpec, step)
resolverPayload := remoteresource.ResolverPayload{
Name: trName,
Namespace: namespace,
Namespace: taskNamespace,
ResolutionSpec: &resolutionV1beta1.ResolutionRequestSpec{
Params: step.Ref.Params,
URL: step.Ref.Name,
},
}
resolver := resolution.NewResolver(requester, tr, string(step.Ref.Resolver), resolverPayload)
return resolveStepAction(ctx, resolver, name, namespace, k8s, tekton)
return resolveStepAction(ctx, resolver, name, taskNamespace, k8s, tekton)
}
}
local := &LocalStepActionRefResolver{
Namespace: namespace,
Namespace: taskNamespace,
Tektonclient: tekton,
}
return local.GetStepAction
Expand Down
16 changes: 15 additions & 1 deletion pkg/reconciler/taskrun/resources/taskspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,24 @@ func GetTaskData(ctx context.Context, taskRun *v1.TaskRun, getTask GetTask) (*re
// GetStepActionsData extracts the StepActions and merges them with the inlined Step specification.
func GetStepActionsData(ctx context.Context, taskSpec v1.TaskSpec, taskRun *v1.TaskRun, tekton clientset.Interface, k8s kubernetes.Interface, requester remoteresource.Requester) ([]v1.Step, error) {
steps := []v1.Step{}

// Get the task's namespace from the taskRun's status
taskNamespace := taskRun.Namespace
if taskRun.Status.TaskSpec != nil {
// If this is a referenced Task, use its namespace
if taskRun.Spec.TaskRef != nil && taskRun.Spec.TaskRef.Name != "" {
// Get the Task to find its namespace
task, err := tekton.TektonV1().Tasks(taskRun.Namespace).Get(ctx, taskRun.Spec.TaskRef.Name, metav1.GetOptions{})
if err == nil {
taskNamespace = task.Namespace
}
}
}

for i, step := range taskSpec.Steps {
s := step.DeepCopy()
if step.Ref != nil {
getStepAction := GetStepActionFunc(tekton, k8s, requester, taskRun, taskSpec, s)
getStepAction := GetStepActionFunc(tekton, k8s, requester, taskRun, taskSpec, s, taskNamespace)
stepAction, source, err := getStepAction(ctx, s.Ref.Name)
if err != nil {
return nil, err
Expand Down
Loading