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

Add pipeline task approve logic #359

Closed
callmevladik opened this issue Sep 3, 2024 · 0 comments · Fixed by #360
Closed

Add pipeline task approve logic #359

callmevladik opened this issue Sep 3, 2024 · 0 comments · Fixed by #360
Assignees
Labels
enhancement New feature or request feature New functionality

Comments

@callmevladik
Copy link
Contributor

callmevladik commented Sep 3, 2024

This task aims to implement approval functionality within the Portal UI, enabling users to Approve or Reject approval tasks directly from the interface. This functionality is critical for streamlining the approval process in our deployment pipelines, particularly when using Tekton pipelines with custom tasks for deployment approvals.

{}Pre-requisites{}:

Deploy the environment with the latest Tekton pipeline using the 'deploy-with-approve' deployment template.

{}Technical Details{}:

  1. It is essential to identify custom Tasks in the Tekton Pipeline, distinguishing between traditional and custom tasks based on their 'taskRef' properties.
  2. The Portal UI should display "Approve" and "Reject" buttons for identified custom tasks. The exact location of these buttons within the UI needs discussion and finalization.
  3. Upon user interaction (Approve/Reject), the Portal UI should modify the corresponding custom resource 'ApprovalTask' to reflect the user's decision. This modification is based on identifying the 'ApprovalTask' resource using labels.
  4. The status and visual presentation of the approval task within the UI should derive from the 'CustomRun' resource, identifiable through labels or owner references. States of task https://github.com/KubeRocketCI/tekton-custom-task/blob/main/deploy-templates/crds/edp.epam.com_approvaltasks.yaml

spec.action set to: Approved/Rejected

{}Acceptance Criteria{}

  1. The Portal UI successfully identifies custom tasks within Tekton Pipelines, specifically those marked as 'ApprovalTask'.
  2. "Approve" and "Reject" buttons are correctly displayed within the Portal UI for each identified custom task.
  3. User interactions with the "Approve" or "Reject" buttons appropriately modify the 'ApprovalTask' custom resource to reflect the chosen action.
  4. The visual presentation and status of approval tasks within the Portal UI accurately reflect the current state of the task, derived from the 'CustomRun' resource.
  5. Comprehensive documentation is provided detailing the implementation process, user interaction flow, and any necessary configuration steps.

Examples:

Pipeline:

  - name: deploy-app
    params:           - name: PIPELINE
        value: sktest
      - name: STAGE
        value: dev
      - name: APPLICATIONS_PAYLOAD
        value: '{"demo":{"imageTag":"0.1.0-SNAPSHOT.2","customValues":false}}'
    runAfter:           - pre-deploy
    taskRef:           kind: Task
      name: deploy-applicationset-cli
  - name: promote-approve
    runAfter:           - deploy-app
    taskRef:           apiVersion: edp.epam.com/v1alpha1
      kind: ApprovalTask
      name: promote-approve

ApprovalTask

apiVersion: edp.epam.com/v1alpha1
kind: ApprovalTask
metadata: creationTimestamp: '2024-08-29T16:00:49Z'
generation: 1
labels: tekton.dev/pipeline: deploy-with-approve
tekton.dev/pipelineRun: deploy-sktest-dev7njvq
tekton.dev/pipelineTask: promote-approve
managedFields: - apiVersion: edp.epam.com/v1alpha1
fieldsType: FieldsV1
fieldsV1:
f:metadata: f:labels: .: {}
f:tekton.dev/pipeline: {}
f:tekton.dev/pipelineRun: {}
f:tekton.dev/pipelineTask: {}
f:ownerReferences: .: {}
k:{"uid":"6b7032d6-7796-401c-9522-39b8fbab575e"}: {}
f:spec: .: {}
f:action: {}
f:description: {}
manager: manager
operation: Update
time: '2024-08-29T16:00:49Z'
name: deploy-sktest-dev7njvq-promote-approve-approval
namespace: edp-delivery-tekton-dev
ownerReferences: - apiVersion: tekton.dev/v1beta1
blockOwnerDeletion: true
controller: true
kind: CustomRun
name: deploy-sktest-dev7njvq-promote-approve
uid: 6b7032d6-7796-401c-9522-39b8fbab575e
resourceVersion: '1532494482'
uid: a67b6dd8-1902-4849-b153-557b6aec8290
selfLink: >-
/apis/edp.epam.com/v1alpha1/namespaces/edp-delivery-tekton-dev/approvaltasks/deploy-sktest-dev7njvq-promote-approve-approval
spec: action: Approved
description: Proceed

CustomRun

apiVersion: tekton.dev/v1beta1
kind: CustomRun
metadata: creationTimestamp: '2024-08-29T16:00:49Z'
generation: 1
labels: app.edp.epam.com/cdpipeline: sktest
app.edp.epam.com/cdstage: sktest-dev
app.edp.epam.com/pipelinetype: deploy
argocd.argoproj.io/instance-edp: edp-delivery_tekton-dev-edp-tekton
tekton.dev/memberOf: tasks
tekton.dev/pipeline: deploy-with-approve
tekton.dev/pipelineRun: deploy-sktest-dev7njvq
tekton.dev/pipelineTask: promote-approve
managedFields: - apiVersion: tekton.dev/v1beta1
fieldsType: FieldsV1
fieldsV1:
f:metadata: f:labels: .: {}
f:app.edp.epam.com/cdpipeline: {}
f:app.edp.epam.com/cdstage: {}
f:app.edp.epam.com/pipelinetype: {}
f:argocd.argoproj.io/instance-edp: {}
f:tekton.dev/memberOf: {}
f:tekton.dev/pipeline: {}
f:tekton.dev/pipelineRun: {}
f:tekton.dev/pipelineTask: {}
f:ownerReferences: .: {}
k:{"uid":"65faac81-2d60-486e-993e-1dbfde224228"}: {}
f:spec: .: {}
f:customRef: .: {}
f:apiVersion: {}
f:kind: {}
f:name: {}
f:serviceAccountName: {}
manager: controller
operation: Update
time: '2024-08-29T16:00:49Z'
- apiVersion: tekton.dev/v1beta1
fieldsType: FieldsV1
fieldsV1:
f:status: .: {}
f:completionTime: {}
f:conditions: {}
f:extraFields: {}
f:startTime: {}
manager: manager
operation: Update
subresource: status
time: '2024-08-29T16:03:29Z'
name: deploy-sktest-dev7njvq-promote-approve
namespace: edp-delivery-tekton-dev
ownerReferences: - apiVersion: tekton.dev/v1
blockOwnerDeletion: true
controller: true
kind: PipelineRun
name: deploy-sktest-dev7njvq
uid: 65faac81-2d60-486e-993e-1dbfde224228
resourceVersion: '1532498443'
uid: 6b7032d6-7796-401c-9522-39b8fbab575e
selfLink: >-
/apis/tekton.dev/v1beta1/namespaces/edp-delivery-tekton-dev/customruns/deploy-sktest-dev7njvq-promote-approve
status: completionTime: '2024-08-29T16:03:29Z'
conditions: - lastTransitionTime: '2024-08-29T16:03:29Z'
message: Pipeline run was approved
reason: Approved
status: 'True'
type: Succeeded
extraFields: null
startTime: '2024-08-29T16:00:49Z'
spec: customRef: apiVersion: edp.epam.com/v1alpha1
kind: ApprovalTask
name: promote-approve
serviceAccountName: tekton

test

@callmevladik callmevladik converted this from a draft issue Sep 3, 2024
@callmevladik callmevladik self-assigned this Sep 3, 2024
@callmevladik callmevladik added enhancement New feature or request feature New functionality labels Sep 3, 2024
@SergK SergK closed this as completed in #360 Sep 3, 2024
SergK pushed a commit that referenced this issue Sep 3, 2024
@github-project-automation github-project-automation bot moved this from Todo to Done in KubeRocketCI Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature New functionality
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant