Skip to content

Commit

Permalink
Fix for Create PipelineRun specifying ServiceAccount with v1 API
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanGreene authored and tekton-robot committed Feb 6, 2024
1 parent 5362394 commit f595311
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/api/pipelineRuns.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -95,8 +95,10 @@ export function getPipelineRunPayload({
timeoutsPipeline,
timeoutsTasks
}) {
const pipelinesAPIVersion = getTektonPipelinesAPIVersion();

const payload = {
apiVersion: `tekton.dev/${getTektonPipelinesAPIVersion()}`,
apiVersion: `tekton.dev/${pipelinesAPIVersion}`,
kind: 'PipelineRun',
metadata: {
name: pipelineRunName,
Expand Down Expand Up @@ -128,7 +130,13 @@ export function getPipelineRunPayload({
};
}
if (serviceAccount) {
payload.spec.serviceAccountName = serviceAccount;
if (pipelinesAPIVersion === 'v1') {
payload.spec.taskRunTemplate = {
serviceAccountName: serviceAccount
};
} else {
payload.spec.serviceAccountName = serviceAccount;
}
}
if (timeoutsFinally || timeoutsPipeline || timeoutsTasks) {
payload.spec.timeouts = {
Expand Down
10 changes: 7 additions & 3 deletions src/api/pipelineRuns.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -74,7 +74,9 @@ describe('createPipelineRun', () => {
name,
value: params[name]
})),
serviceAccountName: serviceAccount,
taskRunTemplate: {
serviceAccountName: serviceAccount
},
timeouts: {
pipeline: timeout
}
Expand Down Expand Up @@ -128,7 +130,9 @@ describe('createPipelineRun', () => {
disk: 'ssd'
}
},
serviceAccountName: serviceAccount,
taskRunTemplate: {
serviceAccountName: serviceAccount
},
timeouts: {
pipeline: timeout
}
Expand Down

0 comments on commit f595311

Please sign in to comment.