Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v0.43.x] Fix for Create PipelineRun specifying ServiceAccount with v1 API #3291

Merged
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
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